<div align="center">
<p>
<a align="center" href="" target="_blank">
<img
width="850"
src="https://media.roboflow.com/open-source/autodistill/autodistill-banner.png"
>
</a>
</p>
</div>
# Autodistill CoDet Module
This repository contains the code supporting the CoDet base model for use with [Autodistill](https://github.com/autodistill/autodistill).
[CoDet](https://github.com/CVMI-Lab/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](https://autodistill.github.io/autodistill/).
Read the [CoDet Autodistill documentation](https://autodistill.github.io/autodistill/base_models/codet/).
## Installation
To use CoDet with autodistill, you need to install the following dependency:
```bash
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](https://github.com/autodistill/autodistill-codet).
Use the code snippet below to get started:
```python
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](LICENSE), except where files explicitly note a license.
## 🏆 Contributing
We love your input! Please see the core Autodistill [contributing guide](https://github.com/autodistill/autodistill/blob/main/CONTRIBUTING.md) to get started. Thank you 🙏 to all our contributors!
Raw data
{
"_id": null,
"home_page": "https://github.com/autodistill/autodistill-codet",
"name": "autodistill-codet",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "Roboflow",
"author_email": "support@roboflow.com",
"download_url": "https://files.pythonhosted.org/packages/15/fa/d8cf81bce8d398e42c134ecea4934500c45f377d865edac391e20616ea33/autodistill-codet-0.1.2.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n <p>\n <a align=\"center\" href=\"\" target=\"_blank\">\n <img\n width=\"850\"\n src=\"https://media.roboflow.com/open-source/autodistill/autodistill-banner.png\"\n >\n </a>\n </p>\n</div>\n\n# Autodistill CoDet Module\n\nThis repository contains the code supporting the CoDet base model for use with [Autodistill](https://github.com/autodistill/autodistill).\n\n[CoDet](https://github.com/CVMI-Lab/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.\n\nRead the full [Autodistill documentation](https://autodistill.github.io/autodistill/).\n\nRead the [CoDet Autodistill documentation](https://autodistill.github.io/autodistill/base_models/codet/).\n\n## Installation\n\nTo use CoDet with autodistill, you need to install the following dependency:\n\n```bash\npip3 install autodistill-codet\n```\n\n## Quickstart\n\nWhen 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.\n\nWhen 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()`.\n\nYou 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](https://github.com/autodistill/autodistill-codet).\n\nUse the code snippet below to get started:\n\n```python\nfrom autodistill_codet import CoDet\nfrom autodistill.detection import CaptionOntology\nfrom autodistill.utils import plot\nimport cv2\n\n# define an ontology to map class names to our CoDet prompt\n# the ontology dictionary has the format {caption: class}\n# where caption is the prompt sent to the base model, and class is the label that will\n# be saved for that caption in the generated annotations\n# then, load the model\nbase_model = CoDet(\n ontology=CaptionOntology(\n {\n \"person\": \"person\"\n }\n )\n)\n\n# run inference on an image and display the results\n# class_names is a list of all classes supported by the model\n# class_names can be used to turn the class_id values from the model into human-readable class names\n# class names is defined in self.class_names\npredictions = base_model.predict(\"./context_images/1.jpeg\")\nimage = cv2.imread(\"./context_images/1.jpeg\")\n\nplot(\n image=image,\n detections=predictions,\n classes=base_model.class_names\n)\n\n# run inference on a folder of images and save the results\nbase_model.label(\"./context_images\", extension=\".jpeg\")\n```\n\n\n## License\n\nThis project is licensed under an [Apache 2.0 license](LICENSE), except where files explicitly note a license.\n\n## \ud83c\udfc6 Contributing\n\nWe love your input! Please see the core Autodistill [contributing guide](https://github.com/autodistill/autodistill/blob/main/CONTRIBUTING.md) to get started. Thank you \ud83d\ude4f to all our contributors!\n",
"bugtrack_url": null,
"license": "",
"summary": "CoDet model for use with Autodistill",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/autodistill/autodistill-codet"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b21e7d798a744f5b527ea17f5c6d6113202fc4f78a726a621ce2a1f91a4419d3",
"md5": "98811c808552f80475c6c70a7cd23287",
"sha256": "e8b353980c95d465eefeb1b8b684a4f99753d3b57c43b8f6dde89acc6543d7de"
},
"downloads": -1,
"filename": "autodistill_codet-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "98811c808552f80475c6c70a7cd23287",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 11471,
"upload_time": "2023-12-06T10:35:49",
"upload_time_iso_8601": "2023-12-06T10:35:49.271796Z",
"url": "https://files.pythonhosted.org/packages/b2/1e/7d798a744f5b527ea17f5c6d6113202fc4f78a726a621ce2a1f91a4419d3/autodistill_codet-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "15fad8cf81bce8d398e42c134ecea4934500c45f377d865edac391e20616ea33",
"md5": "9fa6197deb32c38e1d61275bc7c164bb",
"sha256": "ba557e0d697fd97ca707ad510bdfda957f0b59279429a0342d17ab02a3f9aad7"
},
"downloads": -1,
"filename": "autodistill-codet-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "9fa6197deb32c38e1d61275bc7c164bb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 18721,
"upload_time": "2023-12-06T10:35:51",
"upload_time_iso_8601": "2023-12-06T10:35:51.027773Z",
"url": "https://files.pythonhosted.org/packages/15/fa/d8cf81bce8d398e42c134ecea4934500c45f377d865edac391e20616ea33/autodistill-codet-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-06 10:35:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "autodistill",
"github_project": "autodistill-codet",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "autodistill-codet"
}