MobileCLIP is an image embedding model developed by Apple and introduced in the "MobileCLIP: Fast Image-Text Models through Multi-Modal Reinforced Training" paper.
You can use MobileCLIP to calculate image embeddings. These embeddings can be used for:
First, install Autodistill and Autodistill MobileCLIP:
pip install autodistill-grounded-sam autodistill-mobileclip
Then, run:
from autodistill_mobileclip import MobileCLIP
from autodistill.detection import CaptionOntology
# define an ontology to map class names to our MobileCLIP 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 = MobileCLIP(
ontology=CaptionOntology(
{
"person": "person",
"a forklift": "forklift"
}
)
)
result = base_model.predict("image.jpeg")
print(result)