# Before you run the Python code snippet below, run the following command:
# pip install roboflow autodistill autodistill_grounded_sam scikit-learn

from autodistill_grounded_sam import GroundedSAM
from autodistill.detection import CaptionOntology
from autodistill.helpers import sync_with_roboflow

BOX_THRESHOLD = 0.75
CAPTION_ONTOLOGY = {
    "0": "0",
    "1": "1",
    "5": "5",
    "green_car": "green_car",
    "gray_car": "gray_car",
    "Dent": "Dent",
    "scratch": "scratch",
    "red_car": "red_car",
    "undefined": "undefined",
    "yellow_car": "yellow_car",
    "Scratch": "Scratch",
    "blue_car": "blue_car",
    "white_car": "white_car",
    "black_car": "black_car"
}
TEXT_THRESHOLD = 0.70

model = GroundedSAM(
    ontology=CaptionOntology(CAPTION_ONTOLOGY),
    box_threshold=BOX_THRESHOLD,
    text_threshold=TEXT_THRESHOLD,
)

sync_with_roboflow(
    workspace_id="ofg8aFKE2OOmwddkN81tXUntmPr1",
    workspace_url="myassistant",
    project_id = "imperfections",
    batch_id = "aAre0tKc5Ja3ggoUkfda",
    model = model
)