Skip to main content

AWS Rekognition base model for use with Autodistill

Project description

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!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autodistill-rekognition-0.1.0.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

autodistill_rekognition-0.1.0-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page