SKU110K_CVPR19复现步骤(train and test)


代码参考:https://github.com/eg4000/SKU110K_CVPR19

1.可行环境

1
2
3
4
5
6
7
8
9
10
11
12
ubuntu16.04

python3.5
keras==2.2.4
keras-resnet
six
scipy
Pillow
pandas
tensorflow-gpu
tqdm
opencv-python==3.1.0.4
1
2
3
4
5
6
7
8
9
10
11
12
windows(only cpu)

python3.6
keras==2.2.4
keras-resnet
six
scipy
Pillow
pandas
tensorflow==1.12.0
tqdm
opencv-python==3.2.0.6

将pyhon库(如果不想影响其他地环境地话,可以创建virtualenv虚拟环境),写入新建地requirements.txt。

运行下面命令:

1
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt

2.做以下修改

1
1.copy ./object_detector_retinanet/keras_retinanet/bin/train.py class_mappings.csv to ./

1
cp ./object_detector_retinanet/keras_retinanet/bin/train.py class_mappings.csv  ./

1
2.modify ./object_detector_retinanet/utils.py line42 or 45 to our own datapath

1
3.add 2 lines in ./object_detector_retinanet/utils/image.py line24-25

此处参考:https://github.com/eg4000/SKU110K_CVPR19/issues/23

1
2
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True

1
4.in our datapath/annotations/ delete the first line of csv file

删除标题栏,如下:

1
5.train 1st step run at ./
1
python -u ./train.py csv

指定gpu

1
python -u ./train.py --gpu 3 csv

成功的情况可以去看我开的issue.

可以训练了:

For windows:

For ubuntu16.04:

1
6.train 2nd step run at ./
1
2
cp ./object_detector_retinanet/keras_retinanet/bin/train_iou.py ./
python -u ./train_iou.py --weights snapshot/Tue_May_26_08_17_14_2020/resnet50_csv_05.h5 csv

1
7. copy ./object_detector_retinanet/keras_retinanet_bin/predict.py to ./
1
8.test run at ./
1
may we'll mat this(“ 'dict' object has no attribute 'iteritems' ”):
1
2
3
4
5
6
vim ./object_detector_retinanet/keras_retinanet/utils/CollapsingMoG.py
line 190
change:
for j, t_vals in clusters.iteritems():
to:
for j, t_vals in clusters.items():
1
test
1
python -u ./predict.py csv  "./SKU110K/snapshot/Thu_May_28_02:36:24_2020/iou_resnet50_csv_01.h5" --hard_score_rate=0.5

we'll get detection result demo.

1
First three step I've changed.The second step you need modify yourself.