<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 Roboflow Universe Module
This repository contains the code supporting the Roboflow Universe base model for use with [Autodistill](https://github.com/autodistill/autodistill).
[Roboflow Universe](https://universe.roboflow.com) is a community where people share computer vision models and datasets. Over 50,000 models and 250,000 datasets have been shared on Universe, with new models available every day. You can use Autodistill to run object detection, classification, and segmentation models hosted on Roboflow Universe.
> [!NOTE]
> Using this project will use Roboflow API calls. You will need a free Roboflow account to use this project. [Sign up for a free Roboflow account](https://app.roboflow.com) to get started. [Learn more about pricing](https://roboflow.com/pricing).
Read the full [Autodistill documentation](https://autodistill.github.io/autodistill/).
Read the [Roboflow Universe Autodistill documentation](https://autodistill.github.io/autodistill/base_models/roboflow_universe/).
## Installation
To use models hosted on Roboflow Universe with autodistill, you need to install the following dependency:
```bash
pip3 install autodistill-roboflow-universe
```
## Quickstart
> [!NOTE]
> Autodistill uses ontology to map model predictions to the expected class labels. For other Autodistill models, the term 'caption' is used when the model accepts prompting or a description for a prediction. When using Roboflow Universe as an Autodistill base model, the 'caption' will be the class name/label that the Universe model will return.
```python
from autodistill_roboflow_universe import RoboflowUniverseModel
from autodistill.detection import CaptionOntology
from autodistill.utils import plot
import cv2
# define an ontology to map class names to our Roboflow model 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 in the generated annotations
model_configs = [
("PROJECT_ID", VERSION_NUMBER)
]
base_model = RoboflowUniverseModel(
ontology=CaptionOntology(
{
"person": "person",
"forklift": "vehicle"
}
),
api_key="ROBOFLOW_API_KEY",
model_configs=model_configs,
)
# run inference on a single image
result = base_model.predict("image.jpeg")
print(result)
plot(
image=cv2.imread("image.jpeg"),
detections=result,
classes=base_model.ontology.classes(),
)
# label a folder of images
base_model.label("./context_images", extension=".jpeg")
```
Above, replace:
- `API_KEY`: with your Roboflow API key
- `PROJECT_NAME`: with your Roboflow project ID.
- `VERSION`: with your Roboflow model version.
- `model_type`: with the type of model you want to run. Options are `object-detection`, `classification`, or `segmentation`. This value must be the same as the model type trained on Roboflow Universe.
You can run multiple models on a single image. This is ideal if you need to identify multiple objects using different models hosted on Roboflow Universe. To run multiple models, add the models you want to run in the `model_configs` list. For example:
```python
model_configs = [
("PROJECT_ID", VERSION_NUMBER),
("PROJECT_ID", VERSION_NUMBER)
]
```
All models will be run on every image.
[Learn how to retrieve your Roboflow API key](https://docs.roboflow.com/api-reference/authentication#retrieve-an-api-key).
[Learn how to retrieve a model ID](https://docs.roboflow.com/api-reference/workspace-and-project-ids).
## License
This project is licensed under an [MIT license](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/capjamesg/autodistill-universe",
"name": "autodistill-roboflow-universe",
"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/e8/e4/7ced410c6a156ab0758ffff723a694f79ddafc5343f83d5c9925f9502483/autodistill-roboflow-universe-0.1.1.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 Roboflow Universe Module\n\nThis repository contains the code supporting the Roboflow Universe base model for use with [Autodistill](https://github.com/autodistill/autodistill).\n\n[Roboflow Universe](https://universe.roboflow.com) is a community where people share computer vision models and datasets. Over 50,000 models and 250,000 datasets have been shared on Universe, with new models available every day. You can use Autodistill to run object detection, classification, and segmentation models hosted on Roboflow Universe.\n\n> [!NOTE]\n> Using this project will use Roboflow API calls. You will need a free Roboflow account to use this project. [Sign up for a free Roboflow account](https://app.roboflow.com) to get started. [Learn more about pricing](https://roboflow.com/pricing).\n\nRead the full [Autodistill documentation](https://autodistill.github.io/autodistill/).\n\nRead the [Roboflow Universe Autodistill documentation](https://autodistill.github.io/autodistill/base_models/roboflow_universe/).\n\n## Installation\n\nTo use models hosted on Roboflow Universe with autodistill, you need to install the following dependency:\n\n```bash\npip3 install autodistill-roboflow-universe\n```\n\n## Quickstart\n\n> [!NOTE]\n> Autodistill uses ontology to map model predictions to the expected class labels. For other Autodistill models, the term 'caption' is used when the model accepts prompting or a description for a prediction. When using Roboflow Universe as an Autodistill base model, the 'caption' will be the class name/label that the Universe model will return. \n\n```python\nfrom autodistill_roboflow_universe import RoboflowUniverseModel\nfrom autodistill.detection import CaptionOntology\nfrom autodistill.utils import plot\nimport cv2\n\n# define an ontology to map class names to our Roboflow model 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 in the generated annotations\n\nmodel_configs = [\n (\"PROJECT_ID\", VERSION_NUMBER)\n]\n\nbase_model = RoboflowUniverseModel(\n ontology=CaptionOntology(\n {\n \"person\": \"person\",\n \"forklift\": \"vehicle\"\n }\n),\n api_key=\"ROBOFLOW_API_KEY\",\n model_configs=model_configs,\n)\n\n# run inference on a single image\nresult = base_model.predict(\"image.jpeg\")\n\nprint(result)\n\nplot(\n image=cv2.imread(\"image.jpeg\"),\n detections=result,\n classes=base_model.ontology.classes(),\n)\n\n# label a folder of images\nbase_model.label(\"./context_images\", extension=\".jpeg\")\n```\n\nAbove, replace:\n\n- `API_KEY`: with your Roboflow API key\n- `PROJECT_NAME`: with your Roboflow project ID.\n- `VERSION`: with your Roboflow model version.\n- `model_type`: with the type of model you want to run. Options are `object-detection`, `classification`, or `segmentation`. This value must be the same as the model type trained on Roboflow Universe.\n\nYou can run multiple models on a single image. This is ideal if you need to identify multiple objects using different models hosted on Roboflow Universe. To run multiple models, add the models you want to run in the `model_configs` list. For example:\n\n```python\nmodel_configs = [\n (\"PROJECT_ID\", VERSION_NUMBER),\n (\"PROJECT_ID\", VERSION_NUMBER)\n]\n```\n\nAll models will be run on every image.\n\n[Learn how to retrieve your Roboflow API key](https://docs.roboflow.com/api-reference/authentication#retrieve-an-api-key).\n[Learn how to retrieve a model ID](https://docs.roboflow.com/api-reference/workspace-and-project-ids).\n\n## License\n\nThis project is licensed under an [MIT license](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": "Use models on Roboflow Universe to auto-label data for use in model training.",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/capjamesg/autodistill-universe"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "febf20b7896317cfea152175dd8138f18c6f9c0ff27dd6731a318219c054211e",
"md5": "a84bb8e58222f6f56b468896ab0f0f66",
"sha256": "70175cb377896227db3fbfdddc84f4871b5a051954a5f07beed832aa86c3cbed"
},
"downloads": -1,
"filename": "autodistill_roboflow_universe-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a84bb8e58222f6f56b468896ab0f0f66",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 5148,
"upload_time": "2024-02-08T09:32:07",
"upload_time_iso_8601": "2024-02-08T09:32:07.762470Z",
"url": "https://files.pythonhosted.org/packages/fe/bf/20b7896317cfea152175dd8138f18c6f9c0ff27dd6731a318219c054211e/autodistill_roboflow_universe-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e8e47ced410c6a156ab0758ffff723a694f79ddafc5343f83d5c9925f9502483",
"md5": "43d77b266199f0bb7003cde308bd19dc",
"sha256": "a8333cdbbd1312b2ec7502c7c20209d777a5ab0dca9f6973679481d274d0b430"
},
"downloads": -1,
"filename": "autodistill-roboflow-universe-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "43d77b266199f0bb7003cde308bd19dc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 4654,
"upload_time": "2024-02-08T09:32:09",
"upload_time_iso_8601": "2024-02-08T09:32:09.389726Z",
"url": "https://files.pythonhosted.org/packages/e8/e4/7ced410c6a156ab0758ffff723a694f79ddafc5343f83d5c9925f9502483/autodistill-roboflow-universe-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-08 09:32:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "capjamesg",
"github_project": "autodistill-universe",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "autodistill-roboflow-universe"
}