Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AWS Rekognition CustomLabels data loader #570

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

capjamesg
Copy link
Collaborator

Description

This PR adds a new data loader that enables loading CustomLabels predictions from AWS Rekognition. This will be useful for people who want to plot bounding boxes or filter predictions with Rekognition CustomLabels.

Note that CustomLabels does not have the concept of a class_id in the output, so my code includes logic to assign those when predictions are ingested into supervision.

Type of change

  • New feature (non-breaking change which adds functionality)

How has this change been tested, please provide a testcase or example of how you tested the change?

First, you need to download and install the aws CLI.

How to install the aws CLI.

Then you need to authenticate with the CLI.

Authenticate with the aws CLI.

Then you can run the following code snippet, included in the docstring:

import supervision as sv
import boto3
from PIL import Image

session = boto3.Session()
client = session.client("rekognition")
with Image.open(input) as image:
    buffered = io.BytesIO()
    image.save(buffered, format=image.format)
    image_bytes = buffered.getvalue()

esponse = client.detect_labels(Image={"Bytes": image_bytes})
detections = sv.Detections.from_rekognition_detectlabels(response)

Any specific deployment considerations

N/A

Docs

N/A

@capjamesg capjamesg requested a review from SkalskiP November 3, 2023 15:40
@capjamesg capjamesg self-assigned this Nov 3, 2023
@capjamesg capjamesg marked this pull request as draft November 3, 2023 16:12
@capjamesg capjamesg marked this pull request as ready for review November 27, 2023 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant