autodistill / autodistill-florence-2

Use Florence 2 to auto-label data for use in training fine-tuned object detection models.
https://docs.autodistill.com
59 stars 7 forks source link

syntax errors in the autodistill-florence-2 code #1

Open Samuel5106 opened 4 months ago

Samuel5106 commented 4 months ago
from autodistill_florence_2 import Florence2
from autodistill.detection import CaptionOntology
from PIL import Image

# define an ontology to map class names to our Florence 2 prompt
# the ontology dictionary has the format {caption: class}
# where caption is the prompt sent to the base model, and class is the label that will
# be saved for that caption in the generated annotations
# Then, load the model
base_model = Florence2(
    ontology=CaptionOntology(
        {
            "person": "person",
            "a forklift": "forklift"
        }
    )
)

image = Image.open("image.jpeg")
result = base_model.predict('image.jpeg')

bounding_box_annotator = sv.BoundingBoxAnnotator()
annotated_frame = bounding_box_annotator.annotate(
    scene=image.copy(),
    detections=result 
)
sv.plot_image(image=annotated_frame, size=(16, 16))

# label a dataset
base_model.label("./context_images", extension=".jpeg")
capjamesg commented 3 months ago

Hello there! It looks like we missed the import supervision as sv line. This has now been fixed. Are there any other errors?