Skip to content
New issue

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

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

Already on GitHub? # to your account

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

Open
Samuel5106 opened this issue Jun 22, 2024 · 1 comment
Open

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

Samuel5106 opened this issue Jun 22, 2024 · 1 comment

Comments

@Samuel5106
Copy link

Samuel5106 commented Jun 22, 2024

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

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

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

No branches or pull requests

2 participants