argusswift / YOLOv4-pytorch

This is a pytorch repository of YOLOv4, attentive YOLOv4 and mobilenet YOLOv4 with PASCAL VOC and COCO
1.68k stars 329 forks source link

训练生成了best.pt 但是mAP为0 #172

Open estellebenice opened 3 years ago

estellebenice commented 3 years ago

[2021-04-23 20:38:32,074]-[train.py line:231]: === Epoch:[ 9/10],step:[ 20/43],img_size:[416],total_loss:15.5247|loss_ciou:3.6702|loss_conf:7.3729|loss_cls:4.4816|lr:0.0001 [2021-04-23 20:38:35,176]-[train.py line:231]: === Epoch:[ 9/10],step:[ 30/43],img_size:[416],total_loss:14.1888|loss_ciou:3.4168|loss_conf:6.7411|loss_cls:4.0309|lr:0.0001 [2021-04-23 20:38:38,355]-[train.py line:231]: === Epoch:[ 9/10],step:[ 40/43],img_size:[416],total_loss:14.0040|loss_ciou:3.4428|loss_conf:6.5731|loss_cls:3.9881|lr:0.0001 [2021-04-23 20:38:39,234]-[train.py line:275]:===== Validate ===== [2021-04-23 20:38:39,234]-[train.py line:277]:val img size is 416 100%|████████████████████████████████████████████████████████████████████████████████████████████████| 22/22 [00:06<00:00, 3.38it/s] [2021-04-23 20:38:45,750]-[train.py line:283]:face_mask --> mAP : 0 [2021-04-23 20:38:45,750]-[train.py line:283]:face --> mAP : 0 [2021-04-23 20:38:45,750]-[train.py line:286]:mAP : 0.0 [2021-04-23 20:38:45,750]-[train.py line:288]:inference time: 75.68 ms [2021-04-23 20:38:52,323]-[train.py line:292]:save weights done [2021-04-23 20:38:52,323]-[train.py line:293]: ===test mAP:0.000 [2021-04-23 20:38:52,323]-[train.py line:309]: ===cost time:26.8884s [2021-04-23 20:38:52,323]-[train.py line:312]:=====Training Finished. best_test_mAP:0.000%====

执行python3 eval_voc.py --weight_path weight/best.pt --gpu_id 0 --visiual /home/wangying/codeYOLOv4-pytorch-master/data/VOC/JPEGImages --mode det时 遇到如下问题

**** Initing PredictNet weights **** initing Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False) initing BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) initing Conv2d(256, 21, kernel_size=(1, 1), stride=(1, 1)) initing Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False) initing BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) initing Conv2d(512, 21, kernel_size=(1, 1), stride=(1, 1)) initing Conv2d(512, 1024, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False) initing BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) initing Conv2d(1024, 21, kernel_size=(1, 1), stride=(1, 1)) loading weight file from : weight/best.pt Traceback (most recent call last): File "eval_voc.py", line 144, in mode=opt.mode File "eval_voc.py", line 34, in init self.load_model_weights(weight_path) File "eval_voc.py", line 43, in load_model_weights self.__model.load_state_dict(chkpt["model"]) KeyError: 'model'

请问可能是什么原因呢?有解决办法吗?

jcluo1994 commented 3 years ago

你是否修改了网络,这是在拿权重预测的时候网络结构不对。

estellebenice commented 3 years ago

您是否修改了网络,这是在拿权重预测的时候网络结构不对。

并没有修改网络 请问有可能是别的原因引起的吗 比如数据集的问题 十分感谢

jingtianyilong commented 3 years ago

chkpt might not be a dict. Or it don't have the key 'model'

estellebenice commented 3 years ago

chkpt might not be a dict. Or it don't have the key 'model'

那mAP为0 可能由什么引起呢

Zpadger commented 3 years ago

@estellebenice 我遇到了同样的问题,请问你解决了吗?

Zpadger commented 3 years ago

问题已解决

estellebenice commented 3 years ago

问题已解决

我没有解决 请问你怎么解决的?

Zpadger commented 3 years ago

@estellebenice 模型加载问题,改了之后可以加载模型了,但是用了侦测图片没有输出结果...还需要改