GithubHelp home page GithubHelp logo

shaoshengsong / mobilenetv3-ssd Goto Github PK

View Code? Open in Web Editor NEW
266.0 7.0 87.0 151 KB

MobileNetV3-SSD for object detection and implementation in PyTorch

Python 100.00%
mobilenetv3-ssd mobilenetv3 mobilenet-ssd onnx ssd mobilenet

mobilenetv3-ssd's People

Contributors

shaoshengsong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mobilenetv3-ssd's Issues

V3是否有在imagenet预训练过?没有预训练的效果很差

Average Precision Per-class:
aeroplane: 0.5286851217064079
bicycle: 0.5684498038841389
bird: 0.2951959818198857
boat: 0.3374119115412078
bottle: 0.11274539710602145
bus: 0.5840837968782298
car: 0.5631029936677479
cat: 0.5605063414099851
chair: 0.24291365433556902
cow: 0.2908948526148929
diningtable: 0.4292561103683377
dog: 0.47845551032801703
horse: 0.6137629939581943
motorbike: 0.6033233235496501
person: 0.5106418290063527
pottedplant: 0.13170114489968404
sheep: 0.3551660800668141
sofa: 0.4682129143642543
train: 0.6344977720902926
tvmonitor: 0.4312501217962447

Average Precision Across All Classes:0.4370128827695964

PASCAL 数据集训练

11.19更新:
训练集:VOC07+12,测试集:VOC07-test,
使用SGDR学习率调整策略,初始学习率为0.01,学习率调整周期为100个epoches,总共训练610个epoches,
预训练模型:mb3-ssd-lite-Epoch-149-Loss-5.782852862012213.pth,
batch_size:32,
能得到的最好的Loss是4.07,请问怎样进一步调整学习策略?

原提问:
你好,当我使用您提供的PASCAL的预训练模型(mb3-ssd-lite-Epoch-149-Loss-5.782852862012213.pth)对几张图片进行检测时,每张图片都检测不到任何一个物体。
然后,我在上述检查点的基础上进行finetune,使用VOC2007+VOC2012数据集训练了100个epoch,batch_size=32,lr=0.0005+multistep([40,80,]),使用新训练的模型再次检测,部分图片能检测到物体,但是准确度还是比较低。
对此,我有两个问题想请教您:

  1. 您在使用上述PASCAL模型进行检测时效果如何?是我操作不当还是模型本身专准确度就不高?
  2. 如果想进一步提高准确度,我需要如何训练?比如是否应该加大数据集或改进训练参数。

Why it takes so long to train?

Thanks for the great work. I trained it on Titan V, but it is very slow. Do you have any idea of how to train it faster?

请问这个怎么改?

Traceback (most recent call last):
File "run_ssd_live_demo.py", line 73, in
boxes, labels, probs = predictor.predict(image, 10, 0.4)
File "/home/yajun/github/MobileNetV3-SSD/vision/ssd/predictor.py", line 37, in predict
scores, boxes = self.net.forward(images)
File "/home/yajun/github/MobileNetV3-SSD/vision/ssd/ssd.py", line 100, in forward
locations, self.priors, self.config.center_variance, self.config.size_variance
File "/home/yajun/github/MobileNetV3-SSD/vision/utils/box_utils.py", line 104, in convert_locations_to_boxes
locations[..., :2] * center_variance * priors[..., 2:] + priors[..., :2],
RuntimeError: expected backend CPU and dtype Float but got backend CUDA and dtype Float

在VOC数据集上训练遇见报错

raise self.exc_type(msg)

ValueError: Caught ValueError in DataLoader worker process 7.
Original Traceback (most recent call last):
File "/home/yww/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
data = fetcher.fetch(index)
File "/home/yww/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/yww/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/yww/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/torch/utils/data/dataset.py", line 207, in getitem
return self.datasets[dataset_idx][sample_idx]
File "/home/yww/MobileNetV3-SSD/vision/datasets/voc_dataset.py", line 65, in getitem
image, boxes, labels = self.transform(image, boxes, labels)
File "/home/yww/MobileNetV3-SSD/vision/ssd/data_preprocessing.py", line 34, in call
return self.augment(img, boxes, labels)
File "/home/yww/MobileNetV3-SSD/vision/transforms/transforms.py", line 55, in call
img, boxes, labels = t(img, boxes, labels)
File "/home/yww/MobileNetV3-SSD/vision/transforms/transforms.py", line 278, in call
if overlap.min() < min_iou and max_iou < overlap.max():
File "/home/yww/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/numpy/core/_methods.py", line 29, in _amin
return umr_minimum(a, axis, None, out, keepdims)
ValueError: zero-size array to reduction operation minimum which has no identity

怀疑是数据集的处理过程中出现0-size 的batch

Loss does not go down

Hello,
Thank you for your repo.
I have used your pretrained model, trained it one more time with VOC dataset for 100 epochs but Loss does not go less than 4.8, and the model accuracy is not good at all. I have used VOC 2012 and 2007 dataset for training and 2007 for testing. Do you have any idea what it could be happened?
Regards

MobilenetV3SSD vs YOLOV3

你好,请问要在嵌入式部署这两种OD网络,哪个更好一些啊~他们的速度和精度能有多大差距呢

AttributeError: Can't pickle local object 'TrainAugmentation.__init__.<locals>.<lambda>'

Can somebody help me?

(py3.6) D:\winfred\mobilenetv3_ssd>python train_ssd.py --dataset_type voc --datasets ./data/VOC2007 ./data/VOC2012 --validation_dataset ./data/test/VOC2007 --net mb3-ssd-lite --pretrained_ssd ./models/mb3-ssd-lite-Epoch-149-Loss-5.782852862012213.pth
2019-10-25 17:22:45,411 - root - INFO - Namespace(balance_data=False, base_net=None, base_net_lr=None, batch_size=32, checkpoint_folder='models/', dataset_type='voc', datasets=['./data/VOC2007', './data/VOC2012'], debug_steps=100, extra_layers_lr=None, freeze_base_net=False, freeze_net=False, gamma=0.1, lr=0.001, mb2_width_mult=1.0, milestones='80,100', momentum=0.9, net='mb3-ssd-lite', num_epochs=120, num_workers=4, pretrained_ssd='./models/mb3-ssd-lite-Epoch-149-Loss-5.782852862012213.pth', resume=None, scheduler='multi-step', t_max=120, use_cuda=True, validation_dataset='./data/test/VOC2007', validation_epochs=5, weight_decay=0.0005)
2019-10-25 17:22:45,413 - root - INFO - Prepare training datasets.
2019-10-25 17:22:45,415 - root - INFO - No labels file, using default VOC classes.
2019-10-25 17:22:45,418 - root - INFO - No labels file, using default VOC classes.
2019-10-25 17:22:45,419 - root - INFO - Stored labels into file models/voc-model-labels.txt.
2019-10-25 17:22:45,420 - root - INFO - Train dataset size: 16551
2019-10-25 17:22:45,420 - root - INFO - Prepare Validation datasets.
2019-10-25 17:22:45,422 - root - INFO - No labels file, using default VOC classes.
2019-10-25 17:22:45,424 - root - INFO - validation dataset size: 4952
2019-10-25 17:22:45,428 - root - INFO - Build network.
SSD(
(base_net): Sequential(
(0): Conv2d(3, 16, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
(1): BatchNorm2d(16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): h_swish()
(3): MobileBlock(
(conv): Sequential(
(0): Conv2d(16, 16, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU(inplace)
)
(depth_conv): Sequential(
(0): Conv2d(16, 16, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), groups=16)
(1): BatchNorm2d(16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
(squeeze_block): SqueezeBlock(
(avg_pool): AdaptiveAvgPool2d(output_size=1)
(dense): Sequential(
(0): Linear(in_features=16, out_features=4, bias=True)
(1): ReLU(inplace)
(2): Linear(in_features=4, out_features=16, bias=True)
(3): h_sigmoid()
)
)
(point_conv): Sequential(
(0): Conv2d(16, 16, kernel_size=(1, 1), stride=(1, 1))
(1): BatchNorm2d(16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU(inplace)
)
)
(4): MobileBlock(
(conv): Sequential(
(0): Conv2d(16, 72, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(72, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU(inplace)
)
(depth_conv): Sequential(
(0): Conv2d(72, 72, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), groups=72)
(1): BatchNorm2d(72, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
(point_conv): Sequential(
(0): Conv2d(72, 24, kernel_size=(1, 1), stride=(1, 1))
(1): BatchNorm2d(24, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU(inplace)
)
)
(5): MobileBlock(
(conv): Sequential(
(0): Conv2d(24, 88, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(88, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU(inplace)
)
(depth_conv): Sequential(
(0): Conv2d(88, 88, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), groups=88)
(1): BatchNorm2d(88, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
(point_conv): Sequential(
(0): Conv2d(88, 24, kernel_size=(1, 1), stride=(1, 1))
(1): BatchNorm2d(24, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU(inplace)
)
)
(6): MobileBlock(
(conv): Sequential(
(0): Conv2d(24, 96, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(96, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU(inplace)
)
(depth_conv): Sequential(
(0): Conv2d(96, 96, kernel_size=(5, 5), stride=(2, 2), padding=(2, 2), groups=96)
(1): BatchNorm2d(96, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
(squeeze_block): SqueezeBlock(
(avg_pool): AdaptiveAvgPool2d(output_size=1)
(dense): Sequential(
(0): Linear(in_features=96, out_features=24, bias=True)
(1): ReLU(inplace)
(2): Linear(in_features=24, out_features=96, bias=True)
(3): h_sigmoid()
)
)
(point_conv): Sequential(
(0): Conv2d(96, 40, kernel_size=(1, 1), stride=(1, 1))
(1): BatchNorm2d(40, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU(inplace)
)
)
(7): MobileBlock(
(conv): Sequential(
(0): Conv2d(40, 240, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(240, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU(inplace)
)
(depth_conv): Sequential(
(0): Conv2d(240, 240, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2), groups=240)
(1): BatchNorm2d(240, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
(squeeze_block): SqueezeBlock(
(avg_pool): AdaptiveAvgPool2d(output_size=1)
(dense): Sequential(
(0): Linear(in_features=240, out_features=60, bias=True)
(1): ReLU(inplace)
(2): Linear(in_features=60, out_features=240, bias=True)
(3): h_sigmoid()
)
)
(point_conv): Sequential(
(0): Conv2d(240, 40, kernel_size=(1, 1), stride=(1, 1))
(1): BatchNorm2d(40, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU(inplace)
)
)
(8): MobileBlock(
(conv): Sequential(
(0): Conv2d(40, 240, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(240, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU(inplace)
)
(depth_conv): Sequential(
(0): Conv2d(240, 240, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2), groups=240)
(1): BatchNorm2d(240, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
(squeeze_block): SqueezeBlock(
(avg_pool): AdaptiveAvgPool2d(output_size=1)
(dense): Sequential(
(0): Linear(in_features=240, out_features=60, bias=True)
(1): ReLU(inplace)
(2): Linear(in_features=60, out_features=240, bias=True)
(3): h_sigmoid()
)
)
(point_conv): Sequential(
(0): Conv2d(240, 40, kernel_size=(1, 1), stride=(1, 1))
(1): BatchNorm2d(40, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU(inplace)
)
)
(9): MobileBlock(
(conv): Sequential(
(0): Conv2d(40, 120, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(120, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): h_swish()
)
(depth_conv): Sequential(
(0): Conv2d(120, 120, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2), groups=120)
(1): BatchNorm2d(120, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
(squeeze_block): SqueezeBlock(
(avg_pool): AdaptiveAvgPool2d(output_size=1)
(dense): Sequential(
(0): Linear(in_features=120, out_features=30, bias=True)
(1): ReLU(inplace)
(2): Linear(in_features=30, out_features=120, bias=True)
(3): h_sigmoid()
)
)
(point_conv): Sequential(
(0): Conv2d(120, 48, kernel_size=(1, 1), stride=(1, 1))
(1): BatchNorm2d(48, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): h_swish()
)
)
(10): MobileBlock(
(conv): Sequential(
(0): Conv2d(48, 144, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(144, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): h_swish()
)
(depth_conv): Sequential(
(0): Conv2d(144, 144, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2), groups=144)
(1): BatchNorm2d(144, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
(squeeze_block): SqueezeBlock(
(avg_pool): AdaptiveAvgPool2d(output_size=1)
(dense): Sequential(
(0): Linear(in_features=144, out_features=36, bias=True)
(1): ReLU(inplace)
(2): Linear(in_features=36, out_features=144, bias=True)
(3): h_sigmoid()
)
)
(point_conv): Sequential(
(0): Conv2d(144, 48, kernel_size=(1, 1), stride=(1, 1))
(1): BatchNorm2d(48, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): h_swish()
)
)
(11): MobileBlock(
(conv): Sequential(
(0): Conv2d(48, 288, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(288, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): h_swish()
)
(depth_conv): Sequential(
(0): Conv2d(288, 288, kernel_size=(5, 5), stride=(2, 2), padding=(2, 2), groups=288)
(1): BatchNorm2d(288, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
(squeeze_block): SqueezeBlock(
(avg_pool): AdaptiveAvgPool2d(output_size=1)
(dense): Sequential(
(0): Linear(in_features=288, out_features=72, bias=True)
(1): ReLU(inplace)
(2): Linear(in_features=72, out_features=288, bias=True)
(3): h_sigmoid()
)
)
(point_conv): Sequential(
(0): Conv2d(288, 96, kernel_size=(1, 1), stride=(1, 1))
(1): BatchNorm2d(96, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): h_swish()
)
)
(12): MobileBlock(
(conv): Sequential(
(0): Conv2d(96, 576, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(576, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): h_swish()
)
(depth_conv): Sequential(
(0): Conv2d(576, 576, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2), groups=576)
(1): BatchNorm2d(576, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
(squeeze_block): SqueezeBlock(
(avg_pool): AdaptiveAvgPool2d(output_size=1)
(dense): Sequential(
(0): Linear(in_features=576, out_features=144, bias=True)
(1): ReLU(inplace)
(2): Linear(in_features=144, out_features=576, bias=True)
(3): h_sigmoid()
)
)
(point_conv): Sequential(
(0): Conv2d(576, 96, kernel_size=(1, 1), stride=(1, 1))
(1): BatchNorm2d(96, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): h_swish()
)
)
(13): MobileBlock(
(conv): Sequential(
(0): Conv2d(96, 576, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(576, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): h_swish()
)
(depth_conv): Sequential(
(0): Conv2d(576, 576, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2), groups=576)
(1): BatchNorm2d(576, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
(squeeze_block): SqueezeBlock(
(avg_pool): AdaptiveAvgPool2d(output_size=1)
(dense): Sequential(
(0): Linear(in_features=576, out_features=144, bias=True)
(1): ReLU(inplace)
(2): Linear(in_features=144, out_features=576, bias=True)
(3): h_sigmoid()
)
)
(point_conv): Sequential(
(0): Conv2d(576, 96, kernel_size=(1, 1), stride=(1, 1))
(1): BatchNorm2d(96, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): h_swish()
)
)
(14): Conv2d(96, 576, kernel_size=(1, 1), stride=(1, 1))
(15): SqueezeBlock(
(avg_pool): AdaptiveAvgPool2d(output_size=1)
(dense): Sequential(
(0): Linear(in_features=576, out_features=144, bias=True)
(1): ReLU(inplace)
(2): Linear(in_features=144, out_features=576, bias=True)
(3): h_sigmoid()
)
)
(16): BatchNorm2d(576, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(17): h_swish()
(18): Conv2d(576, 1280, kernel_size=(1, 1), stride=(1, 1))
(19): h_swish()
)
(extras): ModuleList(
(0): InvertedResidual(
(conv): Sequential(
(0): Conv2d(1280, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU6(inplace)
(3): Conv2d(256, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), groups=256, bias=False)
(4): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(5): ReLU6(inplace)
(6): Conv2d(256, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)
(7): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
)
(1): InvertedResidual(
(conv): Sequential(
(0): Conv2d(512, 128, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU6(inplace)
(3): Conv2d(128, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), groups=128, bias=False)
(4): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(5): ReLU6(inplace)
(6): Conv2d(128, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
(7): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
)
(2): InvertedResidual(
(conv): Sequential(
(0): Conv2d(256, 128, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU6(inplace)
(3): Conv2d(128, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), groups=128, bias=False)
(4): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(5): ReLU6(inplace)
(6): Conv2d(128, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
(7): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
)
(3): InvertedResidual(
(conv): Sequential(
(0): Conv2d(256, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU6(inplace)
(3): Conv2d(64, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), groups=64, bias=False)
(4): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(5): ReLU6(inplace)
(6): Conv2d(64, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
(7): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
)
)
(classification_headers): ModuleList(
(0): Sequential(
(0): Conv2d(288, 288, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), groups=288)
(1): BatchNorm2d(288, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU6()
(3): Conv2d(288, 126, kernel_size=(1, 1), stride=(1, 1))
)
(1): Sequential(
(0): Conv2d(1280, 1280, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), groups=1280)
(1): BatchNorm2d(1280, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU6()
(3): Conv2d(1280, 126, kernel_size=(1, 1), stride=(1, 1))
)
(2): Sequential(
(0): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), groups=512)
(1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU6()
(3): Conv2d(512, 126, kernel_size=(1, 1), stride=(1, 1))
)
(3): Sequential(
(0): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), groups=256)
(1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU6()
(3): Conv2d(256, 126, kernel_size=(1, 1), stride=(1, 1))
)
(4): Sequential(
(0): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), groups=256)
(1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU6()
(3): Conv2d(256, 126, kernel_size=(1, 1), stride=(1, 1))
)
(5): Conv2d(64, 126, kernel_size=(1, 1), stride=(1, 1))
)
(regression_headers): ModuleList(
(0): Sequential(
(0): Conv2d(288, 288, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), groups=288)
(1): BatchNorm2d(288, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU6()
(3): Conv2d(288, 24, kernel_size=(1, 1), stride=(1, 1))
)
(1): Sequential(
(0): Conv2d(1280, 1280, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), groups=1280)
(1): BatchNorm2d(1280, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU6()
(3): Conv2d(1280, 24, kernel_size=(1, 1), stride=(1, 1))
)
(2): Sequential(
(0): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), groups=512)
(1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU6()
(3): Conv2d(512, 24, kernel_size=(1, 1), stride=(1, 1))
)
(3): Sequential(
(0): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), groups=256)
(1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU6()
(3): Conv2d(256, 24, kernel_size=(1, 1), stride=(1, 1))
)
(4): Sequential(
(0): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), groups=256)
(1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU6()
(3): Conv2d(256, 24, kernel_size=(1, 1), stride=(1, 1))
)
(5): Conv2d(64, 24, kernel_size=(1, 1), stride=(1, 1))
)
(source_layer_add_ons): ModuleList()
)
2019-10-25 17:22:48,105 - root - INFO - Init from pretrained ssd ./models/mb3-ssd-lite-Epoch-149-Loss-5.782852862012213.pth
2019-10-25 17:22:49,881 - root - INFO - Took 1.78 seconds to load the model.
2019-10-25 17:22:50,180 - root - INFO - Learning rate: 0.001, Base net learning rate: 0.001, Extra Layers learning rate: 0.001.
2019-10-25 17:22:50,180 - root - INFO - Uses MultiStepLR scheduler.
2019-10-25 17:22:50,181 - root - INFO - Start training from epoch 0.
Traceback (most recent call last):
File "train_ssd.py", line 338, in
device=DEVICE, debug_steps=args.debug_steps, epoch=epoch)
File "train_ssd.py", line 119, in train
for i, data in enumerate(loader):
File "D:\Anaconda3\envs\py3.6\lib\site-packages\torch\utils\data\dataloader.py", line 819, in iter
return _DataLoaderIter(self)
File "D:\Anaconda3\envs\py3.6\lib\site-packages\torch\utils\data\dataloader.py", line 560, in init
w.start()
File "D:\Anaconda3\envs\py3.6\lib\multiprocessing\process.py", line 105, in start
self._popen = self._Popen(self)
File "D:\Anaconda3\envs\py3.6\lib\multiprocessing\context.py", line 223, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "D:\Anaconda3\envs\py3.6\lib\multiprocessing\context.py", line 322, in _Popen
return Popen(process_obj)
File "D:\Anaconda3\envs\py3.6\lib\multiprocessing\popen_spawn_win32.py", line 65, in init
reduction.dump(process_obj, to_child)
File "D:\Anaconda3\envs\py3.6\lib\multiprocessing\reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'TrainAugmentation.init..'

(py3.6) D:\winfred\mobilenetv3_ssd>Traceback (most recent call last):
File "", line 1, in
File "D:\Anaconda3\envs\py3.6\lib\multiprocessing\spawn.py", line 105, in spawn_main
exitcode = _main(fd)
File "D:\Anaconda3\envs\py3.6\lib\multiprocessing\spawn.py", line 115, in _main
self = reduction.pickle.load(from_parent)
EOFError: Ran out of input

model.pth to model.onxx?

I have trained the pytorch model.pth on my dataset, then, I use the convert_to_caffe2_models.py to convert ONXX model, but it raise an error like this:

Traceback (most recent call last):
  File "convert_to_caffe2_models.py", line 50, in <module>
    torch.onnx.export(net, dummy_input, model_path, verbose=False, output_names=['scores', 'boxes'])
  File "/home/tsd/.local/lib/python3.6/site-packages/torch/onnx/__init__.py", line 25, in export
    return utils.export(*args, **kwargs)
  File "/home/tsd/.local/lib/python3.6/site-packages/torch/onnx/utils.py", line 131, in export
    strip_doc_string=strip_doc_string)
  File "/home/tsd/.local/lib/python3.6/site-packages/torch/onnx/utils.py", line 363, in _export
    _retain_param_name, do_constant_folding)
  File "/home/tsd/.local/lib/python3.6/site-packages/torch/onnx/utils.py", line 278, in _model_to_graph
    _disable_torch_constant_prop=_disable_torch_constant_prop)
  File "/home/tsd/.local/lib/python3.6/site-packages/torch/onnx/utils.py", line 188, in _optimize_graph
    graph = torch._C._jit_pass_onnx(graph, operator_export_type)
  File "/home/tsd/.local/lib/python3.6/site-packages/torch/onnx/__init__.py", line 50, in _run_symbolic_function
    return utils._run_symbolic_function(*args, **kwargs)
  File "/home/tsd/.local/lib/python3.6/site-packages/torch/onnx/utils.py", line 589, in _run_symbolic_function
    return fn(g, *inputs, **attrs)
  File "/home/tsd/.local/lib/python3.6/site-packages/torch/onnx/symbolic.py", line 130, in wrapper
    args = [_parse_arg(arg, arg_desc) for arg, arg_desc in zip(args, arg_descriptors)]
  File "/home/tsd/.local/lib/python3.6/site-packages/torch/onnx/symbolic.py", line 130, in <listcomp>
    args = [_parse_arg(arg, arg_desc) for arg, arg_desc in zip(args, arg_descriptors)]
  File "/home/tsd/.local/lib/python3.6/site-packages/torch/onnx/symbolic.py", line 90, in _parse_arg
    raise RuntimeError("Failed to export an ONNX attribute, "
RuntimeError: Failed to export an ONNX attribute, since it's not constant, please try to make things (e.g., kernel size) static if possible

在自己的数据集上训练出错

Traceback (most recent call last):
File "train_ssd.py", line 335, in
device=DEVICE, debug_steps=args.debug_steps, epoch=epoch)
File "train_ssd.py", line 117, in train
for i, data in enumerate(loader):
File "/home/ai/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 801, in next
return self._process_data(data)
File "/home/ai/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 846, in _process_data
data.reraise()
File "/home/ai/anaconda3/lib/python3.6/site-packages/torch/_utils.py", line 385, in reraise
raise self.exc_type(msg)
IndexError: Caught IndexError in DataLoader worker process 3.

IndexError: too many indices for array

利用COCO训练出现问题

没有使用预训练模型,我在coco提取了5类70K图片进行训练,但是loss降到3.6左右就降不下来了,请问有什么策略嘛?

Error Message

Hello,

Whenever I try to run demo, I am having an issue. Could you help me with this? I would be appreciated.

The Error message is:

RuntimeError: Error(s) in loading state_dict for SSD:
size mismatch for classification_headers.0.3.weight: copying a param with shape torch.Size([126, 288, 1, 1]) from checkpoint, the shape in current model is torch.Size([18, 288, 1, 1]).
size mismatch for classification_headers.0.3.bias: copying a param with shape torch.Size([126]) from checkpoint, the shape in current model is torch.Size([18]).
size mismatch for classification_headers.1.3.weight: copying a param with shape torch.Size([126, 1280, 1, 1]) from checkpoint, the shape in current model is torch.Size([18, 1280, 1, 1]).
size mismatch for classification_headers.1.3.bias: copying a param with shape torch.Size([126]) from checkpoint, the shape in current model is torch.Size([18]).
size mismatch for classification_headers.2.3.weight: copying a param with shape torch.Size([126, 512, 1, 1]) from checkpoint, the shape in current model is torch.Size([18, 512, 1, 1]).
size mismatch for classification_headers.2.3.bias: copying a param with shape torch.Size([126]) from checkpoint, the shape in current model is torch.Size([18]).
size mismatch for classification_headers.3.3.weight: copying a param with shape torch.Size([126, 256, 1, 1]) from checkpoint, the shape in current model is torch.Size([18, 256, 1, 1]).
size mismatch for classification_headers.3.3.bias: copying a param with shape torch.Size([126]) from checkpoint, the shape in current model is torch.Size([18]).
size mismatch for classification_headers.4.3.weight: copying a param with shape torch.Size([126, 256, 1, 1]) from checkpoint, the shape in current model is torch.Size([18, 256, 1, 1]).
size mismatch for classification_headers.4.3.bias: copying a param with shape torch.Size([126]) from checkpoint, the shape in current model is torch.Size([18]).
size mismatch for classification_headers.5.weight: copying a param with shape torch.Size([126, 64, 1, 1]) from checkpoint, the shape in current model is torch.Size([18, 64, 1, 1]).
size mismatch for classification_headers.5.bias: copying a param with shape torch.Size([126]) from checkpoint, the shape in current model is torch.Size([18]).

Loss inf when traning

I'm having a problem when training ssd mobilenet v3 lite, I have lost inf at some steps. Does that affect my results?
---2019-08-22 13:54:37,701 - root - INFO - Epoch: 6, Step: 20, Average Loss: inf, Average Regression Loss inf, Average Classification Loss: 3.2975
2019-08-22 13:56:20,223 - root - INFO - Epoch: 6, Step: 30, Average Loss: inf, Average Regression Loss inf, Average Classification Loss: 3.3092
2019-08-22 13:58:55,497 - root - INFO - Epoch: 6, Step: 40, Average Loss: 6.5821, Average Regression Loss 3.2743, Average Classification Loss: 3.3079
2019-08-22 14:00:47,632 - root - INFO - Epoch: 6, Step: 50, Average Loss: 6.5586, Average Regression Loss 3.2818, Average Classification Loss: 3.2768
+I would like to ask if I download pretrain model voc but when I tested it, I did not return the results of the boxes
I thank

RuntimeError: expected backend CPU and dtype Float but got backend CUDA and dtype Float

请问一下,执行run_ssd_example.py脚本报这个错该如何解决? Traceback (most recent call last):
File "run_ssd_example.py", line 57, in
boxes, labels, probs = predictor.predict(image, 10, 0.4)
File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\ssd\predictor.py", line 37, in predict
scores, boxes = self.net.forward(images)
File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\ssd\ssd.py", line 100, in forward
locations, self.priors, self.config.center_variance, self.config.size_variance
File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\utils\box_utils.py", line 104, in convert_locations_to_boxes
locations[..., :2] * center_variance * priors[..., 2:] + priors[..., :2],
RuntimeError: expected backend CPU and dtype Float but got backend CUDA and dtype Float

**预加载之前训练的模型**

你好 !
我按着步骤来 进行 预加载训练.
但是 训练时没有从Epoch150开始 而是直接又从0开始训练了
请问这是怎么回事? 我应该怎么调.

cjd@jordan:~/car_FPN-G-F-MobileNetV3-SSD$ python3.6 train_ssd.py --datasets /home/cjd/ssd.pytorch/data/VOCdevkit/VOC2007 --validation_dataset /home/cjd/ssd.pytorch/data/VOCdevkit/VOC2007 --net mb3-ssd-lite --pretrained_ssd models_new/mb3-ssd-lite-Epoch-149-Loss-2.2059922739140037.pth --scheduler cosine --lr 0.01 --t_max 100 --validation_epochs 5 --num_epochs 300 --base_net_lr 0.0012 --batch_size 5
2020-07-15 17:08:40,220 - root - INFO - Use Cuda.
2020-07-15 17:08:40,220 - root - INFO - Namespace(balance_data=False, base_net=None, base_net_lr=0.0012, batch_size=5, checkpoint_folder='models_new/', dataset_type='voc', datasets=['/home/cjd/ssd.pytorch/data/VOCdevkit/VOC2007'], debug_steps=100, extra_layers_lr=None, freeze_base_net=False, freeze_net=False, gamma=0.1, lr=0.01, mb2_width_mult=1.0, milestones='80,100', momentum=0.9, net='mb3-ssd-lite', num_epochs=300, num_workers=0, pretrained_ssd='models_new/mb3-ssd-lite-Epoch-149-Loss-2.2059922739140037.pth', resume=None, scheduler='cosine', t_max=100.0, use_cuda=True, validation_dataset='/home/cjd/ssd.pytorch/data/VOCdevkit/VOC2007', validation_epochs=5, weight_decay=0.0005)
2020-07-15 17:08:40,233 - root - INFO - Prepare training datasets.
2020-07-15 17:08:40,240 - root - INFO - No labels file, using default VOC classes.
2020-07-15 17:08:40,246 - root - INFO - Stored labels into file models_new/voc-model-labels.txt.
2020-07-15 17:08:40,246 - root - INFO - Train dataset size: 3300
2020-07-15 17:08:40,246 - root - INFO - Prepare Validation datasets.
2020-07-15 17:08:40,248 - root - INFO - No labels file, using default VOC classes.
2020-07-15 17:08:40,248 - root - INFO - validation dataset size: 826
2020-07-15 17:08:40,248 - root - INFO - Build network.
2020-07-15 17:08:40,397 - root - INFO - Init from pretrained ssd models_new/mb3-ssd-lite-Epoch-149-Loss-2.2059922739140037.pth
2020-07-15 17:08:40,519 - root - INFO - Took 0.12 seconds to load the model.
2
2020-07-15 17:08:43,911 - root - INFO - Learning rate: 0.01, Base net learning rate: 0.0012, Extra Layers learning rate: 0.01.
2020-07-15 17:08:43,911 - root - INFO - Uses CosineAnnealingLR scheduler.
2020-07-15 17:08:43,911 - root - INFO - Start training from epoch 0.

one question

when i use voc0712 training,it appears the following error,please help me:
CUDA_VISIBLE_DEVICES=4 python2 train_ssd.py --dataset_type voc --datasets /usr/local/zjc/ActionRecog/VOCdevkit --net mb3-ssd-lite --scheduler cosine --lr 0.01 --t_max 100 --validation_epochs 5 --num_epochs 100 --base_net_lr 0.001 --batch_size 5
File "train_ssd.py", line 223
raise ValueError(f"Dataset tpye {args.dataset_type} is not supported.")
^
SyntaxError: invalid syntax

run_ssd_live_demo.py

Hello, first, thank you for providing pytorch code for MobilenetV3-SSD. I want to ask about video detection. Please answer how to run_ssd_live_demo.py. Thanks.

Mobilenetv3_py is outdated

When I compare the implementation of yours and official paper, I found some differences probably due to the paper update in last November.

Changes are in Mobilenet_v3.py:
line 159
[112, 160, 5, 1, "HS", True, 672] needs to be [112, 160, 5, 2, "HS", True, 672]

line 159
[160, 160, 5, 2, "HS", True, 672] needs to be [160, 160, 5, 1, "HS", True, 960]

If I am not mistaken,
Line 246
out_conv2_out = _make_divisible(1280 * multiplier) needs to be

out_conv2_out = _make_divisible(1024 * multiplier), since this is MobilenetV3_Small.
Mobilenetv3_Large uses 1280.

out_conv2_out = _make_divisible(1280 * multiplier)

pretrained model links

Hello,
thank you for this repo. Could you provide a Google Drive link or something else than Baidu?
Regards

为什么使用mbv3_small的预训练会出现乱码

我使用mbv3_small.pth 加载到这个程序当中为什么会出现乱码 下面是我加载的命令

python3.6 train_ssd.py --datasets /home/cjd/ssd.pytorch/data/VOCdevkit/VOC2007/ --validation_dataset /home/cjd/ssd.pytorch/data/VOCdevkit/VOC2007/ --net mb2-ssd-lite --base_net models/mbv3_small.pth --batch_size 8 --scheduler cosine --lr 0.01 --t_max 200 --validation_epochs 5 --num_epochs 200

就一会出现乱码 报错 不知道是v3的预训练不行还是 此程序不行

请指点下 谢谢
@shaoshengsong

权重下采样

我怎么改,用我的数据,比如 20 类的权重,我只有 5类

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.