AILab-CVC / YOLO-World

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

RuntimeError: shape '[1, -1, 1203]' is invalid for input of size 12800 #203

Closed zhujiajian98 closed 7 months ago

zhujiajian98 commented 7 months ago

When I pull the newest demo of YOLO-World and use the image_demo.py to infer the image, it would arise the next error like this:

Traceback (most recent call last):
  File "image_demo.py", line 196, in <module>
    inference_detector(runner,
  File "image_demo.py", line 85, in inference_detector
    output = runner.model.test_step(data_batch)[0]
  File "/opt/conda/lib/python3.8/site-packages/mmengine/model/base_model/base_model.py", line 145, in test_step
    return self._run_forward(data, mode='predict')  # type: ignore
  File "/opt/conda/lib/python3.8/site-packages/mmengine/model/base_model/base_model.py", line 361, in _run_forward
    results = self(**data, mode=mode)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
    return forward_call(*input, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/mmdet/models/detectors/base.py", line 94, in forward
    return self.predict(inputs, data_samples)
  File "/home/zjj/project/YOLO-World/yolo_world/models/detectors/yolo_world.py", line 48, in predict
    results_list = self.bbox_head.predict(img_feats,
  File "/home/zjj/project/YOLO-World/yolo_world/models/dense_heads/yolo_world_head.py", line 324, in predict
    predictions = self.predict_by_feat(*outs,
  File "/home/zjj/project/YOLO-World/yolo_world/models/dense_heads/yolo_world_head.py", line 555, in predict_by_feat
    flatten_cls_scores = [
  File "/home/zjj/project/YOLO-World/yolo_world/models/dense_heads/yolo_world_head.py", line 556, in <listcomp>
    cls_score.permute(0, 2, 3, 1).reshape(num_imgs, -1,
RuntimeError: shape '[1, -1, 1203]' is invalid for input of size 12800
zhujiajian98 commented 7 months ago

I check two issues of YOLO-World github repo, but we can't fix the error.

mingxingpu commented 7 months ago

@zhujiajian98 I ran into the same problem, and fixed the error. maybe you can refer to https://github.com/AILab-CVC/YOLO-World/issues/202#issue-2217360202

zhujiajian98 commented 7 months ago

@mingxingpu Thank you very much, but when I ran the image_demo.py, I still get the same error. Screenshot from 2024-04-02 10-33-44

zhujiajian98 commented 7 months ago

The command I used is like this:

python image_demo.py configs/pretrain/yolo_world_v2_s_vlpan_bn_2e-3_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py /root/.cache/huggingface/hub/models--wondervictor--YOLO-World/snapshots/22efce1a2f6e751dfbf1626e9d039cb3b0f3e809/yolo_world_v2_s_obj365v1_goldg_pretrain-55b943ea.pth data/images/bus.jpg person,bus --topk 100
mingxingpu commented 7 months ago

The command I used is like this:

python image_demo.py configs/pretrain/yolo_world_v2_s_vlpan_bn_2e-3_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py /root/.cache/huggingface/hub/models--wondervictor--YOLO-World/snapshots/22efce1a2f6e751dfbf1626e9d039cb3b0f3e809/yolo_world_v2_s_obj365v1_goldg_pretrain-55b943ea.pth data/images/bus.jpg person,bus --topk 100

you can try comment line 46 and uncomment line 47.

@mingxingpu Thank you very much, but when I ran the image_demo.py, I still get the same error. Screenshot from 2024-04-02 10-33-44

you can try comment line 46 and uncomment line 47.

zhujiajian98 commented 7 months ago

OK, thanks a lot. @mingxingpu