Skip to main content

Autodistill AWS Rekognition Module

This repository contains the code supporting the AWS Rekognition DetectLabels base model for use with 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.

See our Autodistill modules for GCP Vision and Azure Custom Vision if you are interested in using those services instead.

Read the full Autodistill documentation.

Read the Autodistill AWS Rekognition documentation.

Installation

[!NOTE]
Using this project will incur billing charges for API calls to the AWS Rekognition DetectLabels API. Refer to the AWS 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:

pip install autodistill-rekognition

You will then need to authenticate with the aws CLI.

Learn how to install the aws CLI.

Learn how to set up and authenticate with the aws CLI.

Quickstart

Note: You will need to install python-opencv to run the example below.

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.

🏆 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-rekognition 0.1.0

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-rekognition 0.1.0
File Size Uploaded
autodistill-rekognition-0.1.0.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for autodistill-rekognition 0.1.0
File Interpreter ABI Platform
autodistill_rekognition-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / autodistill-rekognition-0.1.0.tar.gz

Download URL autodistill-rekognition-0.1.0.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b1b0650332fb67965097aa214c9d4f6bcd5cbe1bda43f10e290e93fc3d0f6ba2
BLAKE2b-256 checksum
How to use checksums
1952c1d8823a866994ceadaeb13380e0356c23f89ece76d86052a698cb0b286e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / autodistill_rekognition-0.1.0-py3-none-any.whl

Download URL autodistill_rekognition-0.1.0-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ac6047fbc99a75303e1f81ae7500a750a3fc0f7c7ea3e91ed8309ccb53fe22b
BLAKE2b-256 checksum
How to use checksums
7bb4859a590c28c982f8d0652c06ee5e244731dce96c027c20cf8302dc1923d5
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.0 This release

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