WongKinYiu / yolor

implementation of paper - You Only Learn One Representation: Unified Network for Multiple Tasks (https://arxiv.org/abs/2105.04206)
GNU General Public License v3.0
1.98k stars 524 forks source link

testing on custom trained model not working #55

Open abdelhak51 opened 2 years ago

abdelhak51 commented 2 years ago

I trained a new model using yolor but when using the new .pt file it is not working and show me this error :

ws

the error is : File "detect.py", line 45, in detect model.load_state_dict(torch.load(weights[0], map_location=device)['model']) TypeError: 'Darknet' object is not subscriptable

so I don't know how to fix this problem and why it is showing this.

WongKinYiu commented 2 years ago

please use best.pt, init.pt only contains initial weights, it can not be used for testing.

abdelhak51 commented 2 years ago

but I had only init.pt that was generated why?

maybe when training the model i used this command python train.py --batch-size 8 --img 1280 1280 --data coco.yaml --cfg cfg/yolor_p6.cfg --weights 'yolor_p6.pt' --device 0 --name yolor_p6 --hyp hyp.scratch.1280.yaml --epochs 300

wherein this training command I used the --weights attribute with yolor_p6.pt

WongKinYiu commented 2 years ago

do u finish 300 epochs training? init.pt is saved before start training, maybe your training is not correctly start.