Open chuong98 opened 1 year ago
Have you solve this problem? I have encountered similar error when converted yolov5l.pt to mmyolo format. The error is: KeyError: 'model.9.cv3'. I checked the key 'model.9.cv3' was not in the convert_dict.
I don't remember exactly, but here are the step that I would do:
yolov7
statedict to find unmatched keys:
umatch_yolov7=[k for k in yolov7.state_dict().keys() if k not in list(map_dict.keys())]
mmyolo
statedict to find unmatched keys:
umatch_mmyolov=[k for k in mmyolo.state_dict().keys() if k not in list(map_dict.values())]
umatch_yolov7
with umatch_mmyolov
, then append the result to map_dict
I don't remember exactly, but here are the step that I would do:
- Modify the scrip 'yolov7_to_mmyolo.py' to create a Mapping Dict: map_dict={Yolov7_key:mmyolo_key}.
- Loop over the key of
yolov7
statedict to find unmatched keys:umatch_yolov7=[k for k in yolov7.state_dict().keys() if k not in list(map_dict.keys())]
- Loop over the key of
mmyolo
statedict to find unmatched keys:umatch_mmyolov=[k for k in mmyolo.state_dict().keys() if k not in list(map_dict.values())]
- Manually match the
umatch_yolov7
withumatch_mmyolov
, then append the result tomap_dict
Thank you for your reply. I have found the problem was that the given weights was trained by the early version of yolov5 released, which contained module like 'Focus'. I succesfully converted the weights download from official repository.
Prerequisite
🐞 Describe the bug
I tested the command:
tools/model_converters/yolov7_to_mmyolo.py
on Yolov7-w6. It ran successfully up to layer 117, then throw the following error:Environment
sys.platform: linux Python: 3.10.12 (main, Jul 5 2023, 18:54:27) [GCC 11.2.0] CUDA available: True numpy_random_seed: 2147483648 GPU 0,1,2,3: Quadro RTX 8000 CUDA_HOME: /usr/local/cuda-11.8/ GCC: gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0 PyTorch: 2.0.1+cu117 PyTorch compiling details: PyTorch built with:
TorchVision: 0.15.1a0+60a3e72 OpenCV: 4.6.0 MMEngine: 0.8.4 MMCV: 2.0.0 MMDetection: 3.1.0 MMYOLO: 0.6.0+84932d7
Additional information
I printed the state dict keys from the official Yolov7, and found there are layers from 118-->122 that are not included in the mmyolo converter code. In addition, layer 122 is the box_head instead of layer 118. I think the
convert_dict_w
is not correct for yolov7-w6.