<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 AWS Rekognition Module
This repository contains the code supporting the [AWS Rekognition DetectLabels](https://docs.aws.amazon.com/rekognition/latest/dg/labels-detect-labels-image.html) base model for use with [Autodistill](https://github.com/autodistill/autodistill).
With this repository, you can label images using the AWS Rekognition DetectLabels API and train a fine-tuned model using the generated labels.
This is ideal if you want to train a model that you own on a custom dataset.
You can then use your trained model on your computer using Autodistill, or at the edge or in the cloud by deploying with [Roboflow Inference](https://inference.roboflow.com).
See our Autodistill modules for [GCP Vision](https://github.com/autodistill/autodistill-gcp-vision) and [Azure Custom Vision](https://github.com/autodistill/autodistill-azure-vision) if you are interested in using those services instead.
Read the full [Autodistill documentation](https://autodistill.github.io/autodistill/).
Read the [Autodistill AWS Rekognition documentation](https://autodistill.github.io/autodistill/base_models/aws_rekognition/).
## Installation
> [!NOTE]
> Using this project will incur billing charges for API calls to the AWS Rekognition DetectLabels API. Refer to the [AWS Rekognition pricing](https://aws.amazon.com/rekognition/pricing/) for more information. This package makes one API call per image you want to label.
To use the AWS Rekognition DetectLabels API with autodistill, you need to install the following dependency:
```bash
pip install autodistill-rekognition
```
You will then need to authenticate with the `aws` CLI.
Learn [how to install the `aws` CLI](https://aws.amazon.com/cli/).
Learn [how to set up and authenticate with the `aws` CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html).
## Quickstart
_Note: You will need to install `python-opencv` to run the example below._
```python
from autodistill_rekognition import Rekognition
from autodistill.detection import CaptionOntology
import supervision as sv
import cv2
# define an ontology to map class names to our Rekognition 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 = Rekognition(
ontology=CaptionOntology(
{
"Person": "Person",
"a forklift": "forklift"
}
)
)
results = base_model.predict("image.jpeg")
# annotate predictions on an image
classes = base_model.ontology.classes()
box_annotator = sv.BoxAnnotator()
labels = [
f"{classes[class_id]} {confidence:0.2f}"
for _, _, confidence, class_id, _
in detections
]
image = cv2.imread("image.jpeg")
annotated_frame = box_annotator.annotate(
scene=image.copy(),
detections=detections,
labels=labels
)
sv.plot_image(image=annotated_frame, size=(16, 16))
```
## 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/autodistill/autodistill-rekognition",
"name": "autodistill-rekognition",
"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/19/52/c1d8823a866994ceadaeb13380e0356c23f89ece76d86052a698cb0b286e/autodistill-rekognition-0.1.0.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 AWS Rekognition Module\n\nThis repository contains the code supporting the [AWS Rekognition DetectLabels](https://docs.aws.amazon.com/rekognition/latest/dg/labels-detect-labels-image.html) base model for use with [Autodistill](https://github.com/autodistill/autodistill).\n\nWith this repository, you can label images using the AWS Rekognition DetectLabels API and train a fine-tuned model using the generated labels.\n\nThis is ideal if you want to train a model that you own on a custom dataset.\n\nYou can then use your trained model on your computer using Autodistill, or at the edge or in the cloud by deploying with [Roboflow Inference](https://inference.roboflow.com).\n\nSee our Autodistill modules for [GCP Vision](https://github.com/autodistill/autodistill-gcp-vision) and [Azure Custom Vision](https://github.com/autodistill/autodistill-azure-vision) if you are interested in using those services instead.\n\nRead the full [Autodistill documentation](https://autodistill.github.io/autodistill/).\n\nRead the [Autodistill AWS Rekognition documentation](https://autodistill.github.io/autodistill/base_models/aws_rekognition/).\n\n## Installation\n\n> [!NOTE] \n> Using this project will incur billing charges for API calls to the AWS Rekognition DetectLabels API. Refer to the [AWS Rekognition pricing](https://aws.amazon.com/rekognition/pricing/) for more information. This package makes one API call per image you want to label.\n\nTo use the AWS Rekognition DetectLabels API with autodistill, you need to install the following dependency:\n\n```bash\npip install autodistill-rekognition\n```\n\nYou will then need to authenticate with the `aws` CLI.\n\nLearn [how to install the `aws` CLI](https://aws.amazon.com/cli/).\n\nLearn [how to set up and authenticate with the `aws` CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html).\n\n## Quickstart\n\n_Note: You will need to install `python-opencv` to run the example below._\n\n```python\nfrom autodistill_rekognition import Rekognition\nfrom autodistill.detection import CaptionOntology\nimport supervision as sv\nimport cv2\n\n# define an ontology to map class names to our Rekognition 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 = Rekognition(\n ontology=CaptionOntology(\n {\n \"Person\": \"Person\",\n \"a forklift\": \"forklift\"\n }\n )\n)\n\nresults = base_model.predict(\"image.jpeg\")\n\n# annotate predictions on an image\nclasses = base_model.ontology.classes()\n\nbox_annotator = sv.BoxAnnotator()\n\nlabels = [\n\tf\"{classes[class_id]} {confidence:0.2f}\"\n\tfor _, _, confidence, class_id, _\n\tin detections\n]\n\nimage = cv2.imread(\"image.jpeg\")\n\nannotated_frame = box_annotator.annotate(\n\tscene=image.copy(),\n\tdetections=detections,\n\tlabels=labels\n)\n\nsv.plot_image(image=annotated_frame, size=(16, 16))\n```\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": "AWS Rekognition base model for use with Autodistill",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/autodistill/autodistill-rekognition"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7bb4859a590c28c982f8d0652c06ee5e244731dce96c027c20cf8302dc1923d5",
"md5": "32c7e0267b6b66dcc23fd4012ae750dd",
"sha256": "7ac6047fbc99a75303e1f81ae7500a750a3fc0f7c7ea3e91ed8309ccb53fe22b"
},
"downloads": -1,
"filename": "autodistill_rekognition-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "32c7e0267b6b66dcc23fd4012ae750dd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 4852,
"upload_time": "2023-10-27T09:46:06",
"upload_time_iso_8601": "2023-10-27T09:46:06.549512Z",
"url": "https://files.pythonhosted.org/packages/7b/b4/859a590c28c982f8d0652c06ee5e244731dce96c027c20cf8302dc1923d5/autodistill_rekognition-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1952c1d8823a866994ceadaeb13380e0356c23f89ece76d86052a698cb0b286e",
"md5": "e4ccfb51eab26766561afccdc0228cf6",
"sha256": "b1b0650332fb67965097aa214c9d4f6bcd5cbe1bda43f10e290e93fc3d0f6ba2"
},
"downloads": -1,
"filename": "autodistill-rekognition-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "e4ccfb51eab26766561afccdc0228cf6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 4557,
"upload_time": "2023-10-27T09:46:08",
"upload_time_iso_8601": "2023-10-27T09:46:08.029163Z",
"url": "https://files.pythonhosted.org/packages/19/52/c1d8823a866994ceadaeb13380e0356c23f89ece76d86052a698cb0b286e/autodistill-rekognition-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-27 09:46:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "autodistill",
"github_project": "autodistill-rekognition",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "autodistill-rekognition"
}