AILab-CVC / YOLO-World

[CVPR 2024] Real-Time Open-Vocabulary Object Detection
https://www.yoloworld.cc
GNU General Public License v3.0
4.65k stars 451 forks source link

Some undefined keys leading to error while finetuning #52

Open siddankthep opened 9 months ago

siddankthep commented 9 months ago

Hi, I am trying to finetune the model on my object detection dataset. I am using the config for Efficient YOLO-World with the no-mask annotation _base_.

In the finetune config file yolo_world_l_dual_vlpan_2e-4_80e_8gpus_finetune_coco.py, there are some fields such as _base_.copypaste_prob or _base_.min_area_ratio that is not present in the base file yolov8_l_syncbn_fast_8xb16-500e_coco.py.

I am currently unable to run the finetune scripts due to the errors caused by these keys. Can you provide some methods to tackle this problem? If any more context is needed, please let me know.

mio410 commented 8 months ago

The same problem happened to me. Have you solved this problem?

997897336 commented 8 months ago

同问

wondervictor commented 8 months ago

Hi @siddankthep, @mio410, and @997897336, I'm sorry for the late reply! This problem arises because the fine-tuning configs rely on the instance masks for augmentations, e.g., YOLOv5CopyPaste. And you need turn down the mask-refine for Random

  dict(
      type='YOLOv5RandomAffine',
      max_rotate_degree=0.0,
      max_shear_degree=0.0,
      max_aspect_ratio=100,
      scaling_ratio_range=(1 - affine_scale, 1 + affine_scale),
      # img_scale is (width, height)
      border=(-img_scale[0] // 2, -img_scale[1] // 2),
      border_val=(114, 114, 114),
      use_mask_refine=False)

Note that there are two YOLOv5RandomAffine in the config file.

We will upload the config files without mask-refine for more general fine-tuning.

997897336 commented 8 months ago

@wondervictor 我仍未解决该问题,修改的代码为 dict( type='YOLOv5RandomAffine', max_rotate_degree=0.0, max_shear_degree=0.0, max_aspect_ratio=100., scaling_ratio_range=(1 - base.affine_scale, 1 + base.affine_scale),

img_scale is (width, height)

    border=(-_base_.img_scale[0] // 2, -_base_.img_scale[1] // 2),
    border_val=(114, 114, 114),
    # min_area_ratio=_base_.min_area_ratio,
    # use_mask_refine=_base_.use_mask2refine)
    use_mask_refine=False)

]

报错 Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/mmengine/config/config.py", line 109, in getattr value = super().getattr(name) File "/usr/local/lib/python3.8/dist-packages/addict/addict.py", line 67, in getattr return self.getitem(item) File "/usr/local/lib/python3.8/dist-packages/mmengine/config/config.py", line 138, in getitem return self.build_lazy(super().getitem(key)) File "/usr/local/lib/python3.8/dist-packages/mmengine/config/config.py", line 105, in missing raise KeyError(name) KeyError: 'copypaste_prob'

Sally-lxy commented 8 months ago

@wondervictor 我仍未解决该问题,修改的代码为 dict( type='YOLOv5RandomAffine', max_rotate_degree=0.0, max_shear_degree=0.0, max_aspect_ratio=100., scaling_ratio_range=(1 - base.affine_scale, 1 + base.affine_scale), # img_scale is (width, height) border=(-base.img_scale[0] // 2, -base.img_scale[1] // 2), border_val=(114, 114, 114), # min_area_ratio=base.min_area_ratio, # use_mask_refine=base.use_mask2refine) use_mask_refine=False) ]

报错 Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/mmengine/config/config.py", line 109, in getattr value = super().getattr(name) File "/usr/local/lib/python3.8/dist-packages/addict/addict.py", line 67, in getattr return self.getitem(item) File "/usr/local/lib/python3.8/dist-packages/mmengine/config/config.py", line 138, in getitem return self.build_lazy(super().getitem(key)) File "/usr/local/lib/python3.8/dist-packages/mmengine/config/config.py", line 105, in missing raise KeyError(name) KeyError: 'copypaste_prob'

我同样修改以后,也遇到同样的情况,而且我没有在配置文件中找到两个YOLOv5RandomAffine。【 Note that there are two YOLOv5RandomAffine in the config file.】

Sally-lxy commented 8 months ago

@997897336 我的问题解决了,在作者提的建议基础上,再注释这一条【dict(type='YOLOv5CopyPaste', prob=base.copypaste_prob)】就可以微调了!

Sally-lxy commented 8 months ago

微信截图_20240221165006

kkkkkkb commented 8 months ago

@Sally-lxy 您好 想问下您有用微调后的模型来检测一些图片吗,因为我微调后却检测不到任何目标。还有就是您有看过图片的标签信息是否成功读取了吗(将train.py最后几行改成下面这样)? image

wondervictor commented 8 months ago

Hi @siddankthep, @mio410, @Sally-lxy, I've uploaded the new fine-tuning configs without mask-refine. You can refer to it now: yolo_world_l_dual_vlpan_2e-4_80e_8gpus_finetune_coco.py

taofuyu commented 8 months ago

不用base的值,自己填一个就好了