GPT4-v 图像标记:“分类”对象不可迭代

GPT4-v images labeling: 'Classifications' object is not iterable

提问人:maks-ua 提问时间:11/14/2023 最后编辑:maks-ua 更新时间:11/14/2023 访问量:19

问:

在这篇文章图像分类之后,我尝试使用 GPT4-Visual API 标记具有特定类别的图像,以便我可以使用这些分类来训练 YOLOv8 模型。 最后我得到 TypeError: 'Classifications' object is not iterable 这是我的代码:

from autodistill_gpt_4v import GPT4V
from autodistill.detection import CaptionOntology
import os


api_key = os.getenv("OPENAI_API_KEY")

base_model = GPT4V(
    api_key=api_key,
    ontology=CaptionOntology(
        {
            "scratch": "scratch"
        }
    )
)
base_model.label("./images/", extension=".jpg")

下面是错误跟踪:

base_model.label("./images/", extension=".jpg")
  File "C:\Python311\Lib\site-packages\autodistill\detection\detection_base_model.py", line 64, in label
    dataset.as_yolo(
  File "C:\Python311\Lib\site-packages\supervision\dataset\core.py", line 363, in as_yolo
    save_yolo_annotations(
  File "C:\Python311\Lib\site-packages\supervision\dataset\formats\yolo.py", line 239, in save_yolo_annotations
    lines = detections_to_yolo_annotations(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\supervision\dataset\formats\yolo.py", line 198, in detections_to_yolo_annotations
    for xyxy, mask, _, class_id, _ in detections:
TypeError: 'Classifications' object is not iterable

我试图打印传递给

detections_to_yolo_annotations(detections: Detections, 
    image_shape: Tuple[int, int, int],
    min_image_area_percentage: float = 0.0,
    max_image_area_percentage: float = 1.0,
    approximation_percentage: float = 0.75,) 

并得到Classifications(class_id=array([0]), confidence=array([1]))

计算机视觉 OpenAI-API YOLO GPT-4

评论


答: 暂无答案