Following this article Image Classification I try to label images with specific categories using GPT4-Visual API, so that I can use these classifications to train a YOLOv8 model. At the end I get TypeError: 'Classifications' object is not iterable Here is my code:
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")
Here is error trace:
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
I tried to print the detections object passed to the
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,)
and got
Classifications(class_id=array([0]), confidence=array([1]))