Skip to content

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

Closed
@dpyneo

Description

@dpyneo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions