Faster R-CNN + Resnet to train your own data set (CPU) (1)
Using the source code of XinLei Chen's faster rcnn: https://github.com/endernewton/tf-faster-rcnn
It is recommended that if there is a problem, read the readme document in the code carefully to have unexpected gains.
参考blog:https://blog.csdn.net/sinat_33486980/article/details/81045315
1. Environment
Virtual machine VMvare + Ubuntu 18.04
No GPU acceleration
tensorflow1.14.0
python3.6.2
Cython0.25.2
opencv-python3.4.1.15
easydict1.6
Before downloading the code, please configure the environment to avoid unnecessary errors during runtime! (It is recommended to use conda to manage various libraries, conda list to view the library)
2. Download the code
Download directly from https://github.com/endernewton/tf-faster-rcnn
Or open the terminal in the directory you specified and clone the code:
git clone https://github.com/endernewton/tf-faster-rcnn.git
It is recommended to read the README.txt file carefully
3. Set CPU parameters and compile
Since my computer does not have a GPU, according to the readme tips:
1. Open lib / setup.py to modify:
Comment out the red line in the figure
2、lib/model/nms_wrapper.py:
3、lib/model/config.py:
Change __C.USE_GPU_NUM from TRUE to False
After modifying the relevant code, you can connect to Cython and compile it. Enter the lib directory and type the following command in the terminal:
python setup.py build_ext --inplace
make clean
make
cd ..
If the previous code is modified correctly, the compilation should not go wrong
4. Install the data set API
Open the terminal in the root directory of faste rcnn and type the command:
cd data git clone https://github.com/pdollar/coco.git cd coco/PythonAPI make cd ../../..
5. Download and train the model, and run demo.py while testing the VOC2007 data set
1. Download Resnet and training model
There is a corresponding download address in the readme file, but the domestic downloading probability is not acceptable. Thanks to Baidu cloud backup of @ 村民 的 菜 瓶: https://pan.baidu.com/s/1kWkF3fT , and put it in the data file after download Just unzip.
2. Create the output file:
In the faster rcnn directory, create the following folder output / res101 / voc_2007_trainval + voc_2012_trainval / default. Finally, put the decompressed model from the data into the created file.
3. Conduct a demo
With the pre-trained model, you can give a small demonstration of the pictures in the data / demo file.
There are 5 pictures in the demo:
Go back to the faster rcnn directory, open the terminal and enter the command:
./tools/demo.py
The results are shown in the figure: