junxnone / tio

Log
Other
10 stars 5 forks source link

Tensorflow Object detection #202

Open junxnone opened 5 years ago

junxnone commented 5 years ago

22 #154

Reference

Install

Install Tensorflow Object Detection API

Install depends

sudo apt-get install protobuf-compiler python-pil python-lxml python-tk
pip install --user Cython
pip install --user contextlib2
pip install --user jupyter
pip install --user matplotlib
git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
make
cp -r pycocotools <path_to_tensorflow>/models/research/

If the protoc is 2.x Please Install the protoc 3.x manually

cd tensorflow/models/research/
wget -O protobuf.zip https://github.com/google/protobuf/releases/download/v3.0.0/protoc-3.0.0-linux-x86_64.zip
unzip protobuf.zip
./bin/protoc object_detection/protos/*.proto --python_out=.

Add Libraries to PYTHONPATH

export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim

Protobuf Compilation

protoc object_detection/protos/*.proto --python_out=.

Download and convert the dataset

VOC dataset

wget http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar
tar -xvf VOCtrainval_11-May-2012.tar
python object_detection/dataset_tools/create_pascal_tf_record.py \
--label_map_path=object_detection/data/pascal_label_map.pbtxt \
--data_dir=VOCdevkit --year=VOC2012 --set=train \
--output_path=pascal_train.record
python object_detection/dataset_tools/create_pascal_tf_record.py \
--label_map_path=object_detection/data/pascal_label_map.pbtxt \
--data_dir=VOCdevkit --year=VOC2012 --set=val \
--output_path=pascal_val.record
# ls models/research/*.record
pascal_train.record  pascal_val.record
junxnone commented 5 years ago

https://github.com/tensorflow/models/issues/3803 https://github.com/tensorflow/models/issues/4909

junxnone commented 5 years ago

213

junxnone commented 5 years ago

Error TypeError: can't pickle dict_values objects

File "/home/1T/jun/tf/models/research/object_detection/metrics/coco_tools.py", line 118, in LoadAnnotations results.dataset['categories'] = copy.deepcopy(self.dataset['categories']) File "/home/serverx/.virtualenvs/tfmodel/lib/python3.6/copy.py", line 169, in deepcopy rv = reductor(4) TypeError: can't pickle dict_values objects

ref https://blog.csdn.net/sy20173081277/article/details/84311730

diff --git a/research/object_detection/metrics/coco_tools.py b/research/object_detection/metrics/coco_tools.py

-    results.dataset['categories'] = copy.deepcopy(self.dataset['categories'])
+    results.dataset['categories'] = copy.deepcopy(list(self.dataset['categories']))