3 计算机视觉-阅读笔记(6)
2019-04-27 本文已影响0人
深度学习模型优化
3.5 Faster R-CNN代码简介
这里的Faster R-CNN用的是pytorch实现的。下面将文章中重要的信息摘录下来,以备查询。
安装
两个地方下载源代码,当然还是git clone github上的源代码,感谢开源!
git clone https://github.com/jwyang/faster-rcnn.pytorch.git
git clone https://github.com/fancyerii/faster-rcnn.pytorch.git
数据准备
使用VOC数据进行训练
cd faster-rcnn.pytorch
wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtrainval_06-Nov-2007.tar
wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtest_06-Nov-2007.tar
wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCdevkit_08-Jun-2007.tar
解压这3个tar包,创建data目录并且建立符号链接。
tar xvf VOCtrainval_06-Nov-2007.tar
tar xvf VOCtest_06-Nov-2007.tar
tar xvf VOCdevkit_08-Jun-2007.tar
# mkdir data && cd data
ln -s ../VOCdevkit VOCdevkit2007
训练
python trainval_net.py --dataset pascal_voc --net res101 --bs 1 --nw 1 --lr 0.0004 --lr_decay_step 8 --cuda
测试
python test_net.py --dataset pascal_voc --net res101 \
--checksession 1 --checkepoch 20 --checkpoint 10021 \
--cuda
Saving cached annotations to /bigdata/lili/faster-rcnn.pytorch/data/VOCdevkit2007/VOC2007/ImageSets/Main/test.txt_annots.pkl
AP for aeroplane = 0.7534
AP for bicycle = 0.8044
AP for bird = 0.7760
AP for boat = 0.6076
AP for bottle = 0.5756
AP for bus = 0.8021
AP for car = 0.8283
AP for cat = 0.8664
AP for chair = 0.5332
AP for cow = 0.8147
AP for diningtable = 0.6709
AP for dog = 0.8700
AP for horse = 0.8561
AP for motorbike = 0.7939
AP for person = 0.7834
AP for pottedplant = 0.4588
AP for sheep = 0.7238
AP for sofa = 0.7499
AP for train = 0.7524
AP for tvmonitor = 0.6907
Mean AP = 0.7356
python demo.py --net res101 \
--checksession 1 --checkepoch 20 --checkpoint 10021 \
--cuda --load_dir models --image_dir testimgs
预测
python demo.py --net res101 --checksession 1 --checkepoch 20 --checkpoint 10021 --cuda --load_dir models --image_dir testimgs