Yet-Another-EfficientDet-Pytorch
Yet-Another-EfficientDet-Pytorch copied to clipboard
can not load model weights
Thanks for sharing your code. When I loaded the code weights, I found that the dimensions were wrong, but I strictly followed your code to load.
` def get. net():
nun_classes = 7
anchors_ratios = '[(1.0, 1.0),(1.4, 0.7),(0.7, 1.4)]'
anchors_scales = '[2 ** 0, 2 ** (1.0 1 3.0), 2 ** (2.0 / 3.0)] '
compound_coef = 2
my_model = EfficientDetBackbone(nun_ classes = nun_ classes, compound_coef =
compound_coef, ratios = eval(anchors_ ratios), scales = eval(anchor))
weights_path = ' ./efficientdet-d2 . pth'
my_model.load_state_dict(torch. load(weights_ path), strict = False)
return my_model
if __ name__== "__ main__" : model = get_net() `
RuntineError: Error(s) in loading state_ dict for EfficientDetBackbone: size mismatch for classifier .header . pointwise_ conv . conv . weight : copying a paran with shape torch.size([810, 112,1,1]) from checkpoint, the shape in current moJdeil is torch. size([63, 112, 1, 1]). size mismatch for classifier .header . pointwise conv. conv. bias: copying a param with shape torch. Size([810]) from checkpoint, the shape in current model is torch. Size([63]).
Please provide more info
Please provide more info
OK, as shown above
There is no method or function named 'get_net' in this repo.
You can try this.
state_dict = torch.load(weights_path) state_dict.pop('classifier.header.pointwise_conv.conv.weight') state_dict.pop('classifier.header.pointwise_conv.conv.bias') model.load_state_dict(state_dict, strict=False)
check num_classes
or obj_list
810 = 9*90 = num_anchors * num_classes
I guess you use your own dataset but you wanted to use pretrained model. The point is num_classes is not the same. According to your issues, your dataset seems to have 7 classes, but coco pretrained model have 80 classes. Maybe you can try to use only the backbone.
It doesn't matter, the training program will skip the classifier's header if num_classes don't match while loading weights.
I used my own data to train(two classes) and got similar problem:
Traceback (most recent call last):
File "coco_eval.py", line 156, in
It confused me,how to solve this?
pls provide more info
Thank you for your reply
Traceback (most recent call last):
File "coco_eval.py", line 156, in
the rest is too long this happened when I run coco_eval.py(used the model I trained)
pls provide more info @BenBerCao I met the same problems @wanghuajia
pls provide more info @BenBerCao I met the same problems @wanghuajia
I tried auther's EfficientDet Training On A Custom Dataset(https://github.com/zylo117/Yet-Another-EfficientDet-Pytorch/blob/master/tutorial/train_shape.ipynb) , I trained it and evalled successfully, However,when I evalled my own model ,I still have this problem, if you have any solutions,please reply to me,thanks a lot.
pls provide more info @BenBerCao I met the same problems @wanghuajia
I tried auther's EfficientDet Training On A Custom Dataset(https://github.com/zylo117/Yet-Another-EfficientDet-Pytorch/blob/master/tutorial/train_shape.ipynb) , I trained it and evalled successfully, However,when I evalled my own model ,I still have this problem, if you have any solutions,please reply to me,thanks a lot.
i met the same problem as well, After training on a custom dataset with 2 objects . I used the efficientdet_test_video.py script to test the models. D0 seems to work fine but D1,D2,.. gives this error.
any fix?
you need to specify the network architecture before inference, loading a d1 weights into a d0 network is not possible
Go through your imports , some where in them you might be still using d0 rather than d1,d2.... Change it as required and it might solve this.
Go through your imports , some where in them you might be still using d0 rather than d1,d2.... Change it as required and it might solve this.
Found it, Thank you ;)
Hi all, I have the same problem and I could not find a way to solve it. I downloaded efficiendet_d0.pth and I want to use d0. @williamscott701 @ManojKesani
Hi all, I have the same problem and I could not find a way to solve it. I downloaded efficiendet_d0.pth and I want to use d0. @williamscott701 @ManojKesani
It's been a while since I used this, as far as I remember you need to go through the impots and somewhere in those scripts there will be places u need to change the model u want. Hope this helps.
Hi all, I have the same problem and I could not find a way to solve it. I downloaded efficiendet_d0.pth and I want to use d0. @williamscott701 @ManojKesani
It's been a while since I used this, as far as I remember you need to go through the impots and somewhere in those scripts there will be places u need to change the model u want. Hope this helps.
thank you so much @ManojKesani
Hi all, I have the same problem and I could not find a way to solve it. I downloaded efficiendet_d0.pth and I want to use d0. @williamscott701 @ManojKesani
Hi all, i find the problem. This error rise when we use wrong image size. for me i should set image size to 512 to run without any error.