Skip to main content

DINOv2 module for use with Autodistill

Project description

Autodistill DINOv2 Module

This repository contains the code supporting the DINOv2 base model for use with Autodistill.

DINOv2, developed by Meta Research, is a self-supervised training method for computer vision models. This library uses DINOv2 image embeddings with SVM to build a classification model.

Read the full Autodistill documentation.

Read the DINOv2 Autodistill documentation.

Installation

To use DINOv2 with autodistill, you need to install the following dependency:

pip3 install autodistill-dinov2

Quickstart

from autodistill_dinov2 import DINOv2

target_model = DINOv2(None)

# train a model
# specify the directory where your annotations (in multiclass classification folder format)
# DINOv2 embeddings are saved in a file called "embeddings.json" the folder in which you are working
# with the structure {filename: embedding}
target_model.train("./context_images_labeled")

# get class list
# print(target_model.ontology.classes())

# run inference on the new model
pred = target_model.predict("./context_images_labeled/train/images/dog-7.jpg")

print(pred)

License

The code in this repository is licensed under a CC Attribution-NonCommercial 4.0 International license.

🏆 Contributing

We love your input! Please see the core Autodistill contributing guide to get started. Thank you 🙏 to all our contributors!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autodistill-dinov2-0.1.1.tar.gz (12.9 kB view hashes)

Uploaded Source

Built Distribution

autodistill_dinov2-0.1.1-py3-none-any.whl (10.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page