Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dpyneo opened this issue Mar 8, 2024 · 3 comments

Comments

@dpyneo
Copy link

dpyneo commented Mar 8, 2024

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
Copy link

limchr commented Mar 8, 2024

I gave a quick fix for this, check out #94

@taofuyu
Copy link
Contributor

taofuyu commented Mar 13, 2024

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

@wondervictor
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants