Searching through Rekognition Results from Detect_Labels

0

Greetings from Vancouver Island, I have a very simple image of a Monk with a cell phone from a trip to Italy. I've successfully run Detect_Faces and Detect_Labels via Python and Boto3, no problem. I get back the proper JSON objects and can draw bounding boxes which is also good news especially given my lack of programming expertise. What I'm trying to do is only care about breathing things like my Monk, dogs, cats, etc. Not shoes or back packs. My question: Is there an efficient and scalable way to ether restrict what comes back to specific labels, ignoring the others or, go through the JSON results and pull out just what i want. I know I can take the labels version three list, reduce it to what I want and just search through the JSON but I fear the speed of that will be ugly.

Any suggestions gratefully appreciated. The monk can be found here, if you're interested:

https://tinyurl.com/26zf4u69

Rick Segal

profile picture
asked 15 days ago125 views
1 Answer
1
Accepted Answer

Greetings from Australia. 🦘You can download the list of all possible labels returned by Rekognition on this page in the documentation. When you extract the ZIP file, you will find a file called AmazonRekognitionLabelCategories_v3.0.csv. Take a look at this file to decide which categories you want to include. I suggest "Animals and Pets", "Person Description", and perhaps "Nature and Outdoors". You may need to play around with the categories until you get the result you are looking for.

Then, you can restrict the labels returned by Rekognition to only the categories you want to include.

response = client.detect_labels(
    Image={'S3Object':{'Bucket':bucket,'Name':photo}},
    "Settings": {
        "GeneralLabels": {
            "LabelCategoryInclusionFilters": ["Animals and Pets", "Person Description", "Nature and Outdoors"],
        },
    }
)

Rekognition also supports LabelCategoryExclusionFilters or LabelInclusionFilters or LabelExclusionFilters. See this page for more detail. I hope this helps!

AWS
S_Moose
answered 14 days ago
  • It's Australia for the win! :-) Thanks very much. This helps and allows me to get exceptionally granular as to what I need out of Rekognition. I appreciate the help!

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions