WongKinYiu / ScaledYOLOv4

Scaled-YOLOv4: Scaling Cross Stage Partial Network
GNU General Public License v3.0
2.02k stars 575 forks source link

should use .pt or .weight ? #177

Closed yenai3726 closed 3 years ago

yenai3726 commented 3 years ago

HI i get some problem need help

in README.md test use .weight and train is use ' ' or .pt i can't understand should use which one !

first i try to train and i get .pt
and this my order: python train.py --device 0 --batch-size 4 --data plate.yaml --cfg yolov4-csp-plate.cfg --weights 'weights/yolov4.conv.137' --name yolov4-csp

when i try to use test.py , i get this error

Model Summary: 327 layers, 6.41154e+07 parameters, 6.41154e+07 gradients Traceback (most recent call last): File "test.py", line 70, in test ckpt['model'] = {k: v for k, v in ckpt['model'].items() if model.state_dict()[k].numel() == v.numel()} File "test.py", line 70, in ckpt['model'] = {k: v for k, v in ckpt['model'].items() if model.state_dict()[k].numel() == v.numel()} KeyError: 'module_list.3.Conv2d.weight' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "test.py", line 297, in opt.verbose) File "test.py", line 73, in test load_darknet_weights(model, weights[0]) File "F:\PyTorch_YOLOv4-master\models\models.py", line 441, in load_darknetweights conv.weight.data.copy(torch.from_numpy(weights[ptr:ptr + nw]).view_as(conv.weight)) RuntimeError: shape '[1024, 512, 3, 3]' is invalid for input of size 3955080

i make sure our cfg already change classes and filters
how can i fix this error?

jaqub-manuel commented 3 years ago

hey @yenai3726 , you trained wrong way. instead of yolov4.conv.137 (yolov4 weights), you should use yolov4-csp weights, download link below, it will be fine.https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v4_pre/yolov4-csp.conv.142

yenai3726 commented 3 years ago

hey @jaqub-manuel Thank you for your attention and answer

oh my mistake I forgot this part about weight and i want to know if i use different yolov4-version weight What effect will it have ?

Duarte-Nunes commented 3 years ago

Hi, im not very tech savvy when it comes to Ai, i'm still learning but from my understanding the weights are tied to the structure of the network, if you use a different weight file on a Yolo version that has a different structure it won't work.

In sum, the weights need to match the yolo version.

yenai3726 commented 3 years ago

I got it thank you for your's answer