MobileNetV2-SSDLite运行

Github-pytorch-ssd

ssd.py中,将39行self.priors = config.priors.to(self.device)中的to(device)给删除了,避免发生expected backend CPU and dtype but got backend CUDA and dtype float的报错

修改完毕后,run_ssd_live_demo.py可实时运行,这个是一个摄像头检测的demo

后来在执行eval_ssd.py时又出现了

RuntimeError: expected backend CUDA and dtype Float but got backend CPU and dtype Float,所以我又把删掉的地方加上去了

一、数据集准备

就普通的VOC数据集,别忘了在VOC2007的根目录下新建一个labels.txt

添加上一行:

person

(这里不用加BACKGROUND,代码里会自动加上)

二、训练

wget -P models https://storage.googleapis.com/models-hao/mb2-ssd-lite-mp-0_686.pth

python train_ssd.py --datasets /home/peter/GJ/Dataset/coco_voc/ --validation_dataset /home/peter/GJ/Dataset/coco_voc/ --net mb2-ssd-lite --base_net models/mb2-imagenet-71_8.pth --batch_size 24 --num_epochs 200 --scheduler cosine --lr 0.01 --t_max 200

三、评价

python eval_ssd.py --net mb2-ssd-lite --dataset /home/peter/GJ/Dataset/coco_voc/ --trained_model models/mb2-ssd-lite-Epoch-145-Loss-2.873947295020608.pth --label_file models/voc-model-labels.txt

mb2-ssd-lite-Epoch-100-Loss-3.23428569541258.pth

person: 0.4083668227750662

mb2-ssd-lite-Epoch-145-Loss-2.873947295020608.pth

person: 0.4408083332903108

mb2-ssd-lite-Epoch-180-Loss-2.612840238038231.pth:

Average Precision Per-class:
person: 0.4668954479561219

mb2-ssd-lite-Epoch-190-Loss-2.599642198226031.pth

Average Precision Per-class:
person: 0.46770448868067593

四、跑实时Demo

python run_ssd_live_demo.py mb2-ssd-lite models/mb2-ssd-lite-Epoch-180-Loss-2.612840238038231.pth models/voc-model-labels.txt 

五、跑单张图

这个改一下就能跑多张图了

python run_ssd_example.py mb1-ssd models/gun_model_2.21.pth models/open-images-model-labels.txt ~/Downloads/big.JPG

你可能感兴趣的:(MobileNetV2-SSDLite运行)