10/03/2018

show all PYTHONPATH in command line (tip)



python -c "import sys; print(sys.path)"
or
echo $PYTHONPATH

has type str, but expected one of: bytes (tf.train.Example)

make str to bytes

for example
#String to bytes
my_str = "file name"
my_str_as_bytes = str.encode(my_str)
type(my_str_as_bytes) # ensure it is byte representation
#byte to string
my_decoded_str = my_str_as_bytes.decode()
type(my_decoded_str) # ensure it is string representation

Pandas simple tip

import pandas

read csv file without header
df = pandas.read_csv('./train.csv', header=None, index_col=False)
print(df)

                0     1     2     3     4      5
0    0101_003.png   770   946  2070  2973  table
1    0110_099.png   270  1653  2280  2580  table
2    0113_013.png   303   343  2273  2953  table
3    0140_007.png   664  1782  1814  2076  table
4    0146_281.png   704   432  1744  1552  table
5    0146_281.png   682  1740  1800  2440  table
6    0147_090.png   326   413  2106  1616  table
7    0147_090.png   760  1843  1643  2393  table
8    0147_125.png   310   338  2310   912  table
9    0147_125.png   754  1184  1798  1514  table
10   0147_256.png   590   366  1940  1520  table
..            ...   ...   ...   ...   ...    ...
410  9529_050.png   104  2234  2040  2512  table
411  9530_051.png    90   470  2394  1682  table
412  9531_070.png   166   368  2328  1088  table
413  9531_070.png   148  1100  2340  1788  table
414  9531_073.png    50   260  2336  2876  table
415  9532_146.png   563   490  2440  2853  table
416  9533_038.png  1278   454  2326  1358  table
417  9533_038.png  1270  1774  2328  2368  table

[418 rows x 6 columns]

several way to read first column
print(df[0].tolist())
print(df.values.tolist()[:][0])
print(df.iloc[:,0].values.tolist())

['0101_003.png', '0110_099.png', '0113_013.png', '0140_007.png', '0146_281.png', '0146_281.png', '0147_090.png', '0147_090.png', '0147_125.png', '0147_125.png', '0147_256.png', '0147_256.png', '0148_271.png', '0148_479.png', '0151_180.png', '0151_208.png', '0154_080.png', '0154_474.png', '0155_081.png', '0199_384.png', '0203_075.png', '0206_007.png', '0206_048.png',
...
'9522_041.png', '9522_055.png', '9522_055.png', '9525_037.png', '9525_043.png', '9525_043.png', '9525_043.png', '9526_017.png', '9526_028.png', '9526_028.png', '9526_028.png', '9527_018.png', '9527_024.png', '9527_024.png', '9528_043.png', '9528_043.png', '9528_061.png', '9528_061.png', '9528_061.png', '9529_050.png', '9529_050.png', '9529_050.png', '9530_051.png', '9531_070.png', '9531_070.png', '9531_073.png', '9532_146.png', '9533_038.png', '9533_038.png']

pandas for each row
for index, row in df.iterrows():
print(index, row[0], row[1])

0 0101_003.png 770
1 0110_099.png 270
2 0113_013.png 303
3 0140_007.png 664
4 0146_281.png 704
5 0146_281.png 682
6 0147_090.png 326
7 0147_090.png 760
8 0147_125.png 310
9 0147_125.png 754
10 0147_256.png 590
11 0147_256.png 368
...



10/02/2018

Jupyter notebook ip and port setting (tip)

ipython notebook --ip=0.0.0.0 --port=80
or
jupyter notebook --ip=0.0.0.0 --port=80


object_detection/protos/*.proto: No such file or directory

move to this directory :
cd models/research

and try it again
protoc object_detection/protos/*.proto --python_out=.
good luck!