Skip to main content

Auto-label data with a PaliGemma model, or ine-tune a PaLiGemma model using custom data with Autodistill.

Project description

Autodistill PaLiGemma Module

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

PaLiGemma, developed by Google, is a computer vision model trained using pairs of images and text. You can label data with PaliGemma models for use in training smaller, fine-tuned models with Autodisitll.

Read the full Autodistill documentation.

Installation

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

pip3 install autodistill-paligemma

Quickstart

Auto-label with an existing model

from autodistill_paligemma import PaliGemma

# define an ontology to map class names to our PaliGemma 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 = PaliGemma(
    ontology=CaptionOntology(
        {
            "person": "person",
            "a forklift": "forklift"
        }
    )
)

# label a single image
result = PaliGemma.predict("test.jpeg")
print(result)

# label a folder of images
base_model.label("./context_images", extension=".jpeg")

Model fine-tuning (Coming soon)

from autodistill_paligemma import PaLiGemma

target_model = PaLiGemma()

# train a model
target_model.train("./context_images_labeled/data.yaml", epochs=200)

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

print(pred)

License

The model weights for PaLiGemma are licensed under a custom Google license. To learn more, refer to the Google Gemma Terms of Use.

🏆 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_paligemma-0.1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

autodistill_paligemma-0.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file autodistill_paligemma-0.1.0.tar.gz.

File metadata

  • Download URL: autodistill_paligemma-0.1.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for autodistill_paligemma-0.1.0.tar.gz
Algorithm Hash digest
SHA256 03ab36f339110c29bdb6a56dacc370562e9f49991c6fee00d5674433dd92f834
MD5 86a2431e49a640b2dee339c5e878ec3f
BLAKE2b-256 801a4a096b583c78cf7b5d6a79c27a30885e70d434a160a767918bfcab77718e

See more details on using hashes here.

File details

Details for the file autodistill_paligemma-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for autodistill_paligemma-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 16a69d97b8d4f9b6a823d7b379da2b68131d202ef9ff5b3ca6300dfd2ebdf607
MD5 16b9cf4cfe720fb07044b703be36a921
BLAKE2b-256 d913ff710bb2609e6000d6a4a063c40473421ecd22e7da740acec46398e83c87

See more details on using hashes here.

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