Skip to main content

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

You can fine-tune PaliGemma models with LoRA for deployment with Roboflow Inference.

To train a model, use this code:

from autodistill_paligemma import PaLiGemmaTrainer

target_model = PaLiGemmaTrainer()

# train a model
target_model.train("./data/")

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!

Release files for autodistill-paligemma 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autodistill-paligemma 0.1.1
File Size Uploaded
autodistill_paligemma-0.1.1.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for autodistill-paligemma 0.1.1
File Interpreter ABI Platform
autodistill_paligemma-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.9 kB

Release files / autodistill_paligemma-0.1.1.tar.gz

Download URL autodistill_paligemma-0.1.1.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b0d7edace5ebc30587c57c24658e42815dcbac3cd84fd98338315476a35b93d0
BLAKE2b-256 checksum
How to use checksums
12fef5a7b0c40c96089716566c7d2f73075202ba67bf43458ba62576028de0bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / autodistill_paligemma-0.1.1-py3-none-any.whl

Download URL autodistill_paligemma-0.1.1-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c3695250687bfae317789a9c572b56d0742556869ff643b019ef9f01eb77bcdc
BLAKE2b-256 checksum
How to use checksums
b8b437333cab15564caf460a34faff49cde4db5875a5306765de084c1befb56a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page