YOLO-World icon indicating copy to clipboard operation
YOLO-World copied to clipboard

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

Open dpyneo opened this issue 1 year ago • 1 comments

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的输出的,以便能方便对接接口的,非常感谢!

dpyneo avatar Mar 08 '24 07:03 dpyneo

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

limchr avatar Mar 08 '24 07:03 limchr

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

taofuyu avatar Mar 13 '24 02:03 taofuyu

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

wondervictor avatar Mar 16 '24 10:03 wondervictor