# For CPU pip install tensorflow # For GPU pip install tensorflow-gpu
sudo apt-get update sudo apt-get -y install protobuf-compiler python-pil python-lxml python-tk pip install --user Cython contextlib2 pillow lxml jupyter matplotlib pandas opencv-python
mkdir ~/Desktop/tensorflow cd ~/Desktop/tensorflow git clone https://github.com/tensorflow/models.git
# 最後加上這行 export PYTHONPATH=$PYTHONPATH:~/Desktop/tensorflow/models/research:~/Desktop/tensorflow/models/research/slim
git clone https://github.com/cocodataset/cocoapi.git cd cocoapi/PythonAPI make cp -r pycocotools ~/Desktop/tensorflow/models/research
# 原 extra_compile_args=['-Wno-cpp', '-Wno-unused-function', '-std=c99'], # 改為 extra_compile_args=['-std=c99'],
python setup.py install
# From 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=.
bin\protoc --python_out=. .\object_detection\protos\anchor_generator.proto .\object_detection\protos\argmax_matcher.proto .\object_detection\protos\bipartite_matcher.proto .\object_detection\protos\box_coder.proto .\object_detection\protos\box_predictor.proto .\object_detection\protos\eval.proto .\object_detection\protos\faster_rcnn.proto .\object_detection\protos\faster_rcnn_box_coder.proto .\object_detection\protos\grid_anchor_generator.proto .\object_detection\protos\hyperparams.proto .\object_detection\protos\image_resizer.proto .\object_detection\protos\input_reader.proto .\object_detection\protos\losses.proto .\object_detection\protos\matcher.proto .\object_detection\protos\mean_stddev_box_coder.proto .\object_detection\protos\model.proto .\object_detection\protos\optimizer.proto .\object_detection\protos\pipeline.proto .\object_detection\protos\post_processing.proto .\object_detection\protos\preprocessor.proto .\object_detection\protos\region_similarity_calculator.proto .\object_detection\protos\square_box_coder.proto .\object_detection\protos\ssd.proto .\object_detection\protos\ssd_anchor_generator.proto .\object_detection\protos\string_int_label_map.proto .\object_detection\protos\train.proto .\object_detection\protos\keypoint_box_coder.proto .\object_detection\protos\multiscale_anchor_generator.proto .\object_detection\protos\graph_rewriter.proto
python setup.py build python setup.py install
# From tensorflow/models/research/ python object_detection/builders/model_builder_test.py
# From tensorflow/models/research/ wget http://www.robots.ox.ac.uk/~vgg/data/pets/data/images.tar.gz wget http://www.robots.ox.ac.uk/~vgg/data/pets/data/annotations.tar.gz tar -xvf images.tar.gz tar -xvf annotations.tar.gz
# From tensorflow/models/research/ python object_detection/dataset_tools/create_pet_tf_record.py \ --label_map_path=object_detection/data/pet_label_map.pbtxt \ --data_dir=`pwd` \ --output_dir=`pwd`
# From tensorflow/models/research/ mkdir data cp pet_faces_train.record-* data/ cp pet_faces_val.record-* data/ cp object_detection/data/pet_label_map.pbtxt data/pet_label_map.pbtxt
# From tensorflow/models/research/ wget http://storage.googleapis.com/download.tensorflow.org/models/object_detection/faster_rcnn_resnet101_coco_11_06_2017.tar.gz tar -xvf faster_rcnn_resnet101_coco_11_06_2017.tar.gz cp faster_rcnn_resnet101_coco_11_06_2017/model.ckpt.* data/
# From tensorflow/models/research/ # 編輯以下檔案,並將 PATH_TO_BE_CONFIGURED 修改為所在的目錄 # object_detection/samples/configs/faster_rcnn_resnet101_pets.config # Copy edited template to cloud. cp object_detection/samples/configs/faster_rcnn_resnet101_pets.config \ data/faster_rcnn_resnet101_pets.config
# From tensorflow/models/research/ bash object_detection/dataset_tools/create_pycocotools_package.sh /tmp/pycocotools python setup.py sdist (cd slim && python setup.py sdist)
# From the tensorflow/models/research/ directory PIPELINE_CONFIG_PATH={path to pipeline config file} MODEL_DIR={path to model directory} NUM_TRAIN_STEPS=50000 SAMPLE_1_OF_N_EVAL_EXAMPLES=1 python object_detection/model_main.py \ --pipeline_config_path=${PIPELINE_CONFIG_PATH} \ --model_dir=${MODEL_DIR} \ --num_train_steps=${NUM_TRAIN_STEPS} \ --sample_1_of_n_eval_examples=$SAMPLE_1_OF_N_EVAL_EXAMPLES \ --alsologtostderr
tensorboard --logdir=${MODEL_DIR}
<annotation> <folder>OXIIIT</folder> <filename>Abyssinian_100.jpg</filename> <source> <database>OXFORD-IIIT Pet Dataset</database> <annotation>OXIIIT</annotation> <image>flickr</image> </source> <size> <width>394</width> <height>500</height> <depth>3</depth> </size> <segmented>0</segmented> <object> <name>cat</name> <pose>Frontal</pose> <truncated>0</truncated> <occluded>0</occluded> <bndbox> <xmin>151</xmin> <ymin>71</ymin> <xmax>335</xmax> <ymax>267</ymax> </bndbox> <difficult>0</difficult> </object> </annotation>