Skip to main content

Autodistill CoDet Module

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

CoDet is an open vocabulary zero-shot object detection model. The model was described in the "CoDet: Co-Occurrence Guided Region-Word Alignment for Open-Vocabulary Object Detection" published by Chuofan Ma, Yi Jiang, Xin Wen, Zehuan Yuan, Xiaojuan Qi. The paper was submitted to NeurIPS2023.

Read the full Autodistill documentation.

Read the CoDet Autodistill documentation.

Installation

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

pip3 install autodistill-codet

Quickstart

When you first run the model, it will download CoDet and its dependencies, as well as the required model configuration and weights. The output during the download process will be verbose. If you stop the download process before it has finished, run rm -rf ~/.cache/autodistill/CoDet before running the model again. This ensures that you don't work from a part-installed CoDet setup.

When the predict() function runs, the output will also be verbose. You can ignore the output printed to the console that appears when you call predict().

You can only predict classes in the LVIS vocabulary. You can see a list of supported classes in the class_names.json file in the autodistill-codet GitHub repository.

Use the code snippet below to get started:

from autodistill_codet import CoDet
from autodistill.detection import CaptionOntology
from autodistill.utils import plot
import cv2

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

# run inference on an image and display the results
# class_names is a list of all classes supported by the model
# class_names can be used to turn the class_id values from the model into human-readable class names
# class names is defined in self.class_names
predictions = base_model.predict("./context_images/1.jpeg")
image = cv2.imread("./context_images/1.jpeg")

plot(
  image=image,
  detections=predictions,
  classes=base_model.class_names
)

# run inference on a folder of images and save the results
base_model.label("./context_images", extension=".jpeg")

License

This project is licensed under an Apache 2.0 license, except where files explicitly note a license.

🏆 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-codet 0.1.2

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-codet 0.1.2
File Size Uploaded
autodistill-codet-0.1.2.tar.gz 18.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for autodistill-codet 0.1.2
File Interpreter ABI Platform
autodistill_codet-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 30.2 kB

Release files / autodistill-codet-0.1.2.tar.gz

Download URL autodistill-codet-0.1.2.tar.gz
Size 18.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ba557e0d697fd97ca707ad510bdfda957f0b59279429a0342d17ab02a3f9aad7
BLAKE2b-256 checksum
How to use checksums
15fad8cf81bce8d398e42c134ecea4934500c45f377d865edac391e20616ea33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / autodistill_codet-0.1.2-py3-none-any.whl

Download URL autodistill_codet-0.1.2-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e8b353980c95d465eefeb1b8b684a4f99753d3b57c43b8f6dde89acc6543d7de
BLAKE2b-256 checksum
How to use checksums
b21e7d798a744f5b527ea17f5c6d6113202fc4f78a726a621ce2a1f91a4419d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

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