AILab-CVC / YOLO-World

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

python image_demo.py AttributeError: 'NoneType' object has no attribute 'class_id' #110

Closed dpyneo closed 6 months ago

dpyneo commented 6 months ago

Loads checkpoint by local backend from path: /data/ylword/yoloworld_pre/yolo_world_v2_x_obj365v1_goldg_cc3mlite_pretrain-8698fbfa.pth The model and loaded state dict do not match exactly

missing keys in source state_dict: backbone.text_model.model.text_model.embeddings.position_ids

The model and loaded state dict do not match exactly

missing keys in source state_dict: backbone.text_model.model.text_model.embeddings.position_ids

03/08 15:03:46 - mmengine - INFO - Load checkpoint from yolo_world_v2_x_obj365v1_goldg_cc3mlite_pretrain-8698fbfa.pth [ ] 0/1, elapsed: 0s, ETA:/data/miniconda3/envs/idface/lib/python3.10/site-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3526.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined] Traceback (most recent call last): File "/data/ylword/YOLO-World/image_demo.py", line 186, in inference_detector(runner, File "/data/ylword/YOLO-World/image_demo.py", line 95, in inference_detector zip(detections.class_id, detections.confidence) AttributeError: 'NoneType' object has no attribute 'class_id' 95行代码中“detections = None # Define detections object

labels = [
    f"{texts[class_id][0]} {confidence:0.2f}" for class_id, confidence in
    zip(detections.class_id, detections.confidence)
]”这个是None直接报错了,还是需要“pred_instances = pred_instances.cpu().numpy()
detections = sv.Detections(xyxy=pred_instances['bboxes'],
                           class_id=pred_instances['labels'],
                           confidence=pred_instances['scores'])

labels = [
    f"{texts[class_id][0]} {confidence:0.2f}" for class_id, confidence in
    zip(detections.class_id, detections.confidence)
]”这样的修改代码?还想烦请请问一下,这个有没有具体的能给出坐标和类别json的输出的,以便能方便对接接口的,非常感谢!
limchr commented 6 months ago

I gave a quick fix for this, check out https://github.com/AILab-CVC/YOLO-World/issues/94

taofuyu commented 6 months ago

This PR leads to the error. It should not be merged.

wondervictor commented 6 months ago

Thanks for your interest. If you have any questions about YOLO-World in the future, you're welcome to open a new issue.