GithubHelp home page GithubHelp logo

autodistill / autodistill-codet Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 38 KB

CoDet base model for use with Autodistill.

Home Page: https://docs.autodistill.com

License: Apache License 2.0

Makefile 5.51% Python 94.49%
autodistill computer-vision object-detection zero-shot-object-detection codet

autodistill-codet's Introduction

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!

autodistill-codet's People

Contributors

capjamesg avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

autodistill-codet's Issues

ModuleNotFoundError: No module named 'detectron2'

Hello,

I am trying to install the CO-Det implementation with Autodistill. I had installed autodistill with the given command-line in the the documentation:

pip install autodistill autodistill-grounded-sam autodistill-yolov8

I am running the following demo script:

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

base_model = CoDet(ontology=CaptionOntology({"person": "person"}))

image_path = "../my-img.jpg"
predictions = base_model.predict(image_path)
image = cv2.imread(image_path)

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

I am getting the following error:

Traceback (most recent call last):
  File "/home/xx/Desktop/auto-labeling-models-evaluation/codet/preview.py", line 1, in <module>
    from autodistill_codet import CoDet
  File "/home/xx/miniconda3/envs/autodistill/lib/python3.11/site-packages/autodistill_codet/__init__.py", line 1, in <module>
    from autodistill_codet.codet_model import CoDet
  File "/home/xx/miniconda3/envs/autodistill/lib/python3.11/site-packages/autodistill_codet/codet_model.py", line 86, in <module>
    import detectron2.utils.comm as comm
ModuleNotFoundError: No module named 'detectron2'

I already tried to install detectron2 separately but the CO-Det install overwrite it anyaway.

Thank you for your help,
Rivoks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.