argusswift / YOLOv4-pytorch

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

在 Colaboratory平台train之后没有best.pt生成 #155

Open Fan-SR opened 3 years ago

Fan-SR commented 3 years ago

!python -u train.py --weight_path weight/yolov4.weights --gpu_id 0 使用的这个进行训练,训练成功,但是在weight文件夹下没有生成best.pt文件,同时训练成功时会显示mAP=0.000% [2021-03-14 11:52:43,113]-[train.py line:231]: === Epoch:[ 9/10],step:[1710/1749],img_size:[352],total_loss:5.4350|loss_ciou:1.0242|loss_conf:1.5988|loss_cls:2.8119|lr:0.0000 [2021-03-14 11:52:45,917]-[train.py line:231]: === Epoch:[ 9/10],step:[1720/1749],img_size:[608],total_loss:5.4310|loss_ciou:1.0235|loss_conf:1.5954|loss_cls:2.8120|lr:0.0000 [2021-03-14 11:52:50,280]-[train.py line:231]: === Epoch:[ 9/10],step:[1730/1749],img_size:[448],total_loss:5.4254|loss_ciou:1.0229|loss_conf:1.5935|loss_cls:2.8090|lr:0.0000 [2021-03-14 11:52:53,322]-[train.py line:231]: === Epoch:[ 9/10],step:[1740/1749],img_size:[320],total_loss:5.4339|loss_ciou:1.0231|loss_conf:1.5913|loss_cls:2.8195|lr:0.0000 [2021-03-14 11:52:55,560]-[train.py line:309]: ===cost time:590.5572s [2021-03-14 11:52:55,560]-[train.py line:312]:=====Training Finished. best_test_mAP:0.000%==== 4)G0CWKSHXXDL~JO%R4C~EY 因此运行这串代码时会报错 !python3 eval_voc.py --weight_path weight/best.pt --gpu_id 0 --visiual data/voc/JEPGImages/007000.jpg --mode DET

Traceback (most recent call last): File "eval_voc.py", line 144, in <module> mode=opt.mode File "eval_voc.py", line 34, in __init__ self.__load_model_weights(weight_path) File "eval_voc.py", line 42, in __load_model_weights chkpt = torch.load(weight, map_location=self.__device) File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 579, in load with _open_file_like(f, 'rb') as opened_file: File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 230, in _open_file_like return _open_file(name_or_buffer, mode) File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 211, in __init__ super(_open_file, self).__init__(open(name, mode)) FileNotFoundError: [Errno 2] No such file or directory: 'weight/best.pt'

Fan-SR commented 3 years ago

config.py做了如下调整 `MODEL_TYPE = { "TYPE": "YOLOv4" } # YOLO type:YOLOv4, Mobilenet-YOLOv4 or Mobilenetv3-YOLOv4

CONV_TYPE = {"TYPE": "DO_CONV"} # conv type:DO_CONV or GENERAL

ATTENTION = {"TYPE": "NONE"} # attention type:SEnet、CBAM or NONE

train

TRAIN = { "DATA_TYPE": "Customer", # DATA_TYPE: VOC ,COCO or Customer "TRAIN_IMG_SIZE": 416, "AUGMENT": True, "BATCH_SIZE": 4, "MULTI_SCALE_TRAIN": True, "IOU_THRESHOLD_LOSS": 0.5, "YOLO_EPOCHS": 1, "Mobilenet_YOLO_EPOCHS": 120, "NUMBER_WORKERS": 0, "MOMENTUM": 0.9, "WEIGHT_DECAY": 0.0005, "LR_INIT": 1e-4, "LR_END": 1e-6, "WARMUP_EPOCHS": 2, # or None "showatt": True }

val

VAL = { "TEST_IMG_SIZE": 416, "BATCH_SIZE": 1, "NUMBER_WORKERS": 0, "CONF_THRESH": 0.005, "NMS_THRESH": 0.45, "MULTI_SCALE_VAL": False, "FLIP_VAL": False, "Visual": True, "showatt": True }

Customer_DATA = { "NUM": 6, # your dataset number "CLASSES": ["ore carrier", "general cargo ship", "bulk cargo carrier", "container ship", "fishing boat", "passenger ship",], # your dataset class }` 数据集也做了对应的调整 S571M0$UU 2(X_8X$QI40ZI

Fan-SR commented 3 years ago

大致了解应该是应为mAP=0导致的没有best.pt的生成 @jingtianyilong 那么请问怎么解决mAP=0的问题,是因为我使用的数据集的标签中间有空格还是其他原因吗,我的train_annotation.txt是如下格式 $JZ RAA(TDA_U_RPBSR`D4V

xu81581466 commented 3 years ago

解决了吗,我也遇到这个问题

jingtianyilong commented 3 years ago

大致了解应该是应为mAP=0导致的没有best.pt的生成 @jingtianyilong 那么请问怎么解决mAP=0的问题,是因为我使用的数据集的标签中间有空格还是其他原因吗,我的train_annotation.txt是如下格式 $JZ RAA(TDA_U_RPBSR`D4V

I use my own code. Not this one. So I got no clue

jcluo1994 commented 3 years ago

i also meet this error ,but i clear my data and try again

jcluo1994 commented 3 years ago

解决了吗,我也遇到这个问题

请问解决了吗 我也遇到了这个问题

estellebenice commented 3 years ago

!python -u train.py --weight_path weight / yolov4.weights --gpu_id 0 使用的这个进行训练,训练成功,但是在weight文件夹下没有生成best.pt文件,同时训练成功时会显示​​mAP = 0.000 % 因此运行这串代码时会报错 !python3 eval_voc.py --weight_path重量/ best.pt --gpu_id 0 --visiual数据/ VOC / JEPGImages / 007000.jpg --mode DET [2021-03-14 11:52:43,113]-[train.py line:231]: === Epoch:[ 9/10],step:[1710/1749],img_size:[352],total_loss:5.4350|loss_ciou:1.0242|loss_conf:1.5988|loss_cls:2.8119|lr:0.0000 [2021-03-14 11:52:45,917]-[train.py line:231]: === Epoch:[ 9/10],step:[1720/1749],img_size:[608],total_loss:5.4310|loss_ciou:1.0235|loss_conf:1.5954|loss_cls:2.8120|lr:0.0000 [2021-03-14 11:52:50,280]-[train.py line:231]: === Epoch:[ 9/10],step:[1730/1749],img_size:[448],total_loss:5.4254|loss_ciou:1.0229|loss_conf:1.5935|loss_cls:2.8090|lr:0.0000 [2021-03-14 11:52:53,322]-[train.py line:231]: === Epoch:[ 9/10],step:[1740/1749],img_size:[320],total_loss:5.4339|loss_ciou:1.0231|loss_conf:1.5913|loss_cls:2.8195|lr:0.0000 [2021-03-14 11:52:55,560]-[train.py line:309]: ===cost time:590.5572s [2021-03-14 11:52:55,560]-[train.py line:312]:=====Training Finished. best_test_mAP:0.000%==== 4)G0CWKSHXXDLJO%R4CEY

Traceback (most recent call last): File "eval_voc.py", line 144, in <module> mode=opt.mode File "eval_voc.py", line 34, in __init__ self.__load_model_weights(weight_path) File "eval_voc.py", line 42, in __load_model_weights chkpt = torch.load(weight, map_location=self.__device) File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 579, in load with _open_file_like(f, 'rb') as opened_file: File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 230, in _open_file_like return _open_file(name_or_buffer, mode) File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 211, in __init__ super(_open_file, self).__init__(open(name, mode)) FileNotFoundError: [Errno 2] No such file or directory: 'weight/best.pt'

请问解决了吗

li-ju-bazhong commented 3 years ago

你是不是调整了训练轮数,默认的mobile120轮,CSP50轮;MObile的在60轮以后才会保存模型,CSP30轮以后才会保存模型。路径尽量不要用中文