Pytorch-yolov3: i have trained it on VOC2007 and can't achieved a good result though the loss converged.any suggestions?

Created on 22 Jun 2018  ·  27Comments  ·  Source: eriklindernoren/PyTorch-YOLOv3

All 27 comments

can you share the code?thanks.

Me too!! I have tried yolov3.cfg and yolov3-voc.cfg in the experiments. They could not achieve the good results as the paper. The other question is that the performance of yolov3.cfg is better than yolov3-voc.cfg on VOC2007, though it has 80 classes.

hello,I want to ask how to train on VOC2007 dataset

I have met the same problem when training on VOC.I have trained it for 90 epochs but the confindece of the ture object is very low.Does anyone have a same problem and fix it? thanks!

@RebornL I change the dataloader for VOCdataset and then change the yolov3.cfg for 20 classes in VOC.

@wushuang01 ok, I will make a try now. Thanks!^^

@wushuang01 How to change the dataloader for VOCdataset? I don't find it in the dataset.py.

I used a training pipeline similar to the one in this repo and got a mAP of 0.47 when traning on VOC using the latest mAP evaluation module in the repo. Can you give more information about you mean when you say you don't have good results ? I suspect the mAP module to not be exactly correct since the visualization of my results don't "feel" like 0.47 mAP to me, maybe more a 0.30 or something.

@PiggyGenius I got a worse result of 0.32 mAP.Can I ask how many epochs you train on the VOC and have you change anything during training.I just change the loss_cls calculate as follow because it seems that the loss_cls value is too small:
loss_cls = self.bce_loss(pred_cls[cls_mask==1], tcls[cls_mask==1])

@RebornL I take some reference from the pull requests.

@wushuang01 Thanks! I solve this problem in another way by modifing the datasets.py code about the label file path and use the voc_label.py from darknet project to convert VOC data to a suitable format.

I used the pretrained darknet-53 weights and got 0.70 mAP on Voc2007.

img_20180717_111624

@wushuang01

This is the loss of my VOC2007 training process, batchsize 32. Why can't I detect anything after training?

@feifeiwei I use the func: save_weights to save my model parameters on the first,but when I test the model on test images,it can't detect anything.Then I change the way of saving weights,using torch.save(model.state_dict()). After doing that it can detect some objects but mAP is not good after 100 epochs.So I use the pretrained model and it seems working.There may be a bug on saving_weights function but I havn't figured it out,if you can find something please tell me.Thanks!

I have the same problem as @wushuang01 ,after trained get a model,but it seems can not work,can not detect anything

I have the same problem, too. The train model doesn' t detect anything.

@RebornL you can try to change the code in train.py . use line "model.load_weights(opt.weights_path)" to replace line "model.apply(weights_init_normal)",it may work.

@zhangjunyi1225054736 ok,I make a try now. use line "model.load_weights(opt.weights_path)" to replace line "model.apply(weights_init_normal)", and I combind the @wushuang01 saving model way to use torch.save() method to save model. If work, I will tell yourselves.^^

@zhangjunyi1225054736 When I use load_weight method to load datrknet, it show an error below:
Traceback (most recent call last): File "/home/gmy/lqb/PyTorch-YOLOv3/train.py", line 59, in <module> model.load_weights(opt.weights_path) File "/home/gmy/lqb/PyTorch-YOLOv3/models.py", line 242, in load_weights bn_b = torch.from_numpy(weights[ptr:ptr + num_b]).view_as(bn_layer.bias) File "/home/gmy/anaconda3/lib/python3.6/site-packages/torch/tensor.py", line 230, in view_as return self.view(tensor.size()) RuntimeError: invalid argument 2: size '[512]' is invalid for input with 0 elements at /opt/conda/conda-bld/pytorch_1524586445097/work/aten/src/TH/THStorage.c:41

@Reborn Lwhere was your model from ,download ?

@zhangjunyi1225054736 I fail to load “darknet53.conv.74” pretrain model, but I load "yolov3.weights" is ok. Any differences between darknet53 and yolov3.weight?

@RebornL I also use yolov3.weights,haven't try pretrain model by now ,t will tell you result if i did

I just do as you say, but why do I detect most of the object categories that are person? @wushuang01

@RebornL , The darknet53.conv.74 has weights upto conv73. #73 . I'm thinking we need to initialize the weights randomly first. Then load the pretrained weights upto conv73 using the pretrained darknet53.conv.74 weights. Then train the remaining layers freezing the initial layer or keeping the lr for initial layers low. @eriklindernoren , Would it be a correct way to train object detection for a small dataset?

Like @wushuang01 mentioned there is probably something wrong with Darknet.save_weights. Saving and loading state dicts seem to work well though, and I can now get the model to converge during training and get good results on test images.

Was this page helpful?
0 / 5 - 0 ratings