pytorch_yolov3实验记录

pytorch_yolov3实验记录

  • 安装
    • git项目
    • 配置coco数据集
    • 修改data/coco2014.data文件
    • 模型测试
      • 输出
    • 测试结果展示
    • 小结

安装

环境介绍
Ubuntu18.04	 
Anaconda  
Python 3.7.7 
GCC 7.3.0	
torch 1.5 	
pycocotools 2.0 
*必须使用numpy ==1.17.5
GPU 2070S 8G
pip install -r requirements.txt


git项目

git clone https://github.com/ultralytics/yolov3.git

配置coco数据集

cd yolov3
mkdir coco
coco路径展示
-------coco
      /images
       		/trian2014
        	/val2014
      /label
       		/train2014
       		/val2014
      |--5k.part
      |--tranvalo5k.part
cd coco
coco2014下载路径:https://pjreddie.com/media/files/train2014.zip
				https://pjreddie.com/media/files/val2014.zip
			这个是Darknet的镜像路径,使用迅雷下载,速度比官方的速度快
解压文件:unzip -q train2014.zip
		unzip -q val2014.zip
下载注释文件:https://pjreddie.com/media/files/instances_train-val2014.zip
			https://pjreddie.com/media/files/coco/5k.part
	 		https://pjreddie.com/media/files/coco/trainvalno5k.part
			https://pjreddie.com/media/files/coco/labels.tgz
			tar xzf labels.tgz
			unzip -q instances_train-val2014.zip
			
*在coco文件夹下执行
paste <(awk "{print \"$PWD\"}" <5k.part) 5k.part | tr -d '\t' > 5k.txt
paste <(awk "{print \"$PWD\"}" <trainvalno5k.part) trainvalno5k.part | tr -d '\t' > trainvalno5k.txt

修改data/coco2014.data文件

原来内容展示
classes=80
train=../coco/train2014.txt
valid=../coco/val2014.txt
names=data/coco.names
**修改路径,建议使用绝对路径
train= ../coco/trainvalno5k.txt
valid= ../coco/5k.txt

模型测试

cd yolov3
python3 test.py --data data/coco2014.data --cfg cfg/yolov3-spp.cfg --weights weights/yolov3/yolov3-spp.pt --save-json --img-size 320

输出

Namespace(augment=False, batch_size=16, cfg='cfg/yolov3.cfg', conf_thres=0.001, data='data/coco2014.data', device='', img_size=320, iou_thres=0.6, save_json=True, single_cls=False, task='test', weights='weights/yolov3/yolov3.pt')
Using CUDA device0 _CudaDeviceProperties(name='GeForce RTX 2070 SUPER', total_memory=7979MB)
Model Summary: 222 layers, 6.19491e+07 parameters, 6.19491e+07 gradients
Fusing layers...
Model Summary: 150 layers, 6.19228e+07 parameters, 6.19228e+07 gradients
Caching labels /home/gob/yolov3/coco/labels/val2014.npy (4954 found, 0 missing, 46 empty, 197 duplicate, for 5000 images): 100%|█████████████████| 5000/5000 [00:00<00:00, 26131.86it/s]
               Class    Images   Targets         P         R   [email protected]        F1: 100%|███████████████████████████████████████████████████████████████| 313/313 [00:51<00:00,  6.05it/s]

测试结果展示

yolov3-spp测试结果
Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.314
Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.534
Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.331
Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.105
Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.348
Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.489
Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.278
Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.446
Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.490
Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.250
Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.558
Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.688

yolov3测试结果
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.295
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.521
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.306
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.111
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.331
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.455
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.265
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.430
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.474
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.236
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.545
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.661

小结

之前下载了来路不明的coco数据集,确缺少了很多图片。在这里也遇到了很多报错,但都一步步的解决了,除了基本的配置问题,路径问题之外,也对test.py和train.py文件的代码进行了修改。后期还会继续记录实验过程。。。。

你可能感兴趣的:(pytorch_yolov3实验记录)