docs.aws.amazon.com
Open in
urlscan Pro
18.66.147.89
Public Scan
URL:
https://docs.aws.amazon.com/rekognition/latest/dg/procedure-moderate-images.html
Submission: On July 24 via api from ZA — Scanned from DE
Submission: On July 24 via api from ZA — Scanned from DE
Form analysis
0 forms found in the DOMText Content
SELECT YOUR COOKIE PREFERENCES We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can click “Customize cookies” to decline performance cookies. If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To continue without accepting these cookies, click “Continue without accepting.” To make more detailed choices or learn more, click “Customize cookies.” Accept all cookiesContinue without acceptingCustomize cookies CUSTOMIZE COOKIE PREFERENCES We use cookies and similar tools (collectively, "cookies") for the following purposes. ESSENTIAL Essential cookies are necessary to provide our site and services and cannot be deactivated. They are usually set in response to your actions on the site, such as setting your privacy preferences, signing in, or filling in forms. PERFORMANCE Performance cookies provide anonymous statistics about how customers navigate our site so we can improve site experience and performance. Approved third parties may perform analytics on our behalf, but they cannot use the data for their own purposes. Allow performance category Allowed FUNCTIONAL Functional cookies help us provide useful site features, remember your preferences, and display relevant content. Approved third parties may set these cookies to provide certain site features. If you do not allow these cookies, then some or all of these services may not function properly. Allow functional category Allowed ADVERTISING Advertising cookies may be set through our site by us or our advertising partners and help us deliver relevant marketing content. If you do not allow these cookies, you will experience less relevant advertising. Allow advertising category Allowed Blocking some types of cookies may impact your experience of our sites. You may review and change your choices at any time by clicking Cookie preferences in the footer of this site. We and selected third-parties use cookies or similar technologies as specified in the AWS Cookie Notice. CancelSave preferences UNABLE TO SAVE COOKIE PREFERENCES We will only store essential cookies at this time, because we were unable to save your cookie preferences. If you want to change your cookie preferences, try again later using the link in the AWS console footer, or contact support if the problem persists. Dismiss Contact Us English Create an AWS Account 1. AWS 2. ... 3. Documentation 4. Amazon Rekognition 5. Developer Guide Feedback Preferences AMAZON REKOGNITION DEVELOPER GUIDE * What is Amazon Rekognition? * How it works * Types of analysis * Image and video operations * Non-storage and storage API operations * Model versioning * Getting started * Step 1: Set up an AWS account and create a User * Step 2: Set up the AWS CLI and AWS SDKs * Grant programmatic access * Working with AWS SDKs * Step 3: Getting started using the AWS CLI and AWS SDK API * Step 4: Getting started using the console * Exercise 1: Detect objects and scenes (console) * Exercise 2: Analyze faces (console) * Exercise 3: Compare faces (console) * Exercise 4: See aggregated metrics (console) * Working with images and videos * Working with images * Image specifications * Analyzing images in an Amazon S3 bucket * Using a local file system * Using JavaScript * Displaying bounding boxes * Getting image orientation and bounding box coordinates * Working with stored video analysis * Calling Amazon Rekognition Video operations * Configuring Amazon Rekognition Video * Analyzing a stored video (SDK) * Analyzing a video (AWS CLI) * Reference: Video analysis results notification * Troubleshooting Amazon Rekognition Video * Working with streaming video events * Tagging the Amazon Rekognition Video stream processor * Error handling * Using Amazon Rekognition with FedRAMP * Best practices for sensors, input images, and videos * Amazon Rekognition Image operation latency * Recommendations for facial comparison input images * Recommendations for camera setup (image and video) * Recommendations for camera setup (stored and streaming video) * Recommendations for camera setup (streaming video) * Recommendations for Usage of Face Liveness * Detecting objects and concepts * Detecting labels in an image * Detecting labels in a video * Detecting labels in streaming video events * Setting up your Amazon Rekognition Video and Amazon Kinesis resources * Label detection operations for streaming video events * Detecting custom labels * Detecting and analyzing faces * Overview of face detection and face comparison * Guidelines on face attributes * Detecting faces in an image * Comparing faces in images * Detecting faces in a stored video * Searching faces in a collection * Use cases that involve public safety * Creating a collection * Tagging collections * Listing collections * Describing a collection * Deleting a collection * Adding faces to a collection * Listing faces and associated users in a collection * Deleting faces from a collection * Creating a user * Deleting a user * Associating faces to a user * Disassociating faces from a user * Listing users in a collection * Searching for a face (face ID) * Searching for a face (image) * Searching for users (face ID/ user ID) * Searching for users (image) * Searching stored videos for faces * Searching faces in a collection in streaming video * Setting up your Amazon Rekognition Video and Amazon Kinesis resources * Giving Amazon Rekognition Video access to resources * Searching faces in a streaming video * Reading analysis results * Displaying Rekognition results with Kinesis Video Streams locally * Reference: Kinesis face recognition record * InputInformation * KinesisVideo * StreamProcessorInformation * FaceSearchResponse * DetectedFace * MatchedFace * Streaming using a GStreamer plugin * Troubleshooting streaming video * People pathing * Detecting personal protective equipment * Understanding the PPE detection API * Detecting PPE in an image * Example: bounding boxes and face covers * Recognizing celebrities * Celebrity recognition compared to face search * Recognizing celebrities in an image * Recognizing celebrities in a stored video * Getting celebrity information * Moderating content * Detecting inappropriate images * Detecting inappropriate stored videos * Reviewing inappropriate content with Amazon A2I * Detecting text * Detecting text in an image * Detecting text in a stored video * Detecting video segments * Using the Amazon Rekognition Segment API * Example: Detecting segments in a stored video * Detecting face liveness * User-Side Face Liveness Requirements * Architecture and Sequence Diagrams * Prerequisites * Programming the Amazon Rekognition Face Liveness APIs * Calling the Face Liveness APIs * Configuring and Customizing Your Application * Face Liveness Shared Responsibility Model * Face Liveness update guidelines * Face Liveness FAQ * Tutorials * Storing Amazon Rekognition Data with Amazon RDS and DynamoDB * Using Amazon Rekognition and Lambda to tag assets in an Amazon S3 bucket * Creating AWS video analyzer applications * Creating an Amazon Rekognition Lambda function * Using Amazon Rekognition for Identity Verification * Detecting Labels in an Image Using Lambda and Python * Code examples * Actions * Compare faces in an image against a reference image * Create a collection * Delete a collection * Delete faces from a collection * Describe a collection * Detect faces in an image * Detect labels in an image * Detect moderation labels in an image * Detect text in an image * Get information about celebrities * Index faces to a collection * List collections * List faces in a collection * Recognize celebrities in an image * Search for faces in a collection * Search for faces in a collection compared to a reference image * Scenarios * Build a collection and find faces in it * Detect and display elements in images * Detect information in videos * Cross-service examples * Create a serverless application to manage photos * Detect PPE in images * Detect faces in an image * Detect objects in images * Detect people and objects in a video * Save EXIF and other image information * API Reference * Security * Identity and access management * How Amazon Rekognition works with IAM * AWS managed policies * Using identity-based policy examples * Resource-based policy examples * Troubleshooting * Data protection * Data encryption * Internetwork traffic privacy * Using Amazon Rekognition with Amazon VPC endpoints * Compliance validation * Resilience * Configuration and vulnerability analysis * Cross-service confused deputy prevention * Infrastructure security * Monitoring * Monitoring Rekognition with Amazon CloudWatch * Logging Amazon Rekognition API calls with AWS CloudTrail * Guidelines and quotas * Document history * AWS glossary Detecting inappropriate images - Amazon Rekognition AWSDocumentationAmazon RekognitionDeveloper Guide Detecting inappropriate content in an imageDetectModerationLabels operation requestDetectModerationLabels operation response DETECTING INAPPROPRIATE IMAGES PDFRSS You can use the DetectModerationLabels operation to determine if an image contains inappropriate or offensive content. For a list of moderation labels in Amazon Rekognition, see Using the image and video moderation APIs. DETECTING INAPPROPRIATE CONTENT IN AN IMAGE The image must be in either a .jpg or a .png format. You can provide the input image as an image byte array (base64-encoded image bytes), or specify an Amazon S3 object. In these procedures, you upload an image (.jpg or .png) to your S3 bucket. To run these procedures, you need to have the AWS CLI or the appropriate AWS SDK installed. For more information, see Getting started with Amazon Rekognition. The AWS account you use must have access permissions to the Amazon Rekognition API. For more information, see Actions Defined by Amazon Rekognition. TO DETECT MODERATION LABELS IN AN IMAGE (SDK) 1. If you haven't already: 1. Create or update an user with AmazonRekognitionFullAccess and AmazonS3ReadOnlyAccess permissions. For more information, see Step 1: Set up an AWS account and create a User. 2. Install and configure the AWS CLI and the AWS SDKs. For more information, see Step 2: Set up the AWS CLI and AWS SDKs. 2. Upload an image to your S3 bucket. For instructions, see Uploading Objects into Amazon S3 in the Amazon Simple Storage Service User Guide. 3. Use the following examples to call the DetectModerationLabels operation. Java This example outputs detected inappropriate content label names, confidence levels, and the parent label for detected moderation labels. Replace the values of bucket and photo with the S3 bucket name and the image file name that you used in step 2. //Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. //PDX-License-Identifier: MIT-0 (For details, see https://github.com/awsdocs/amazon-rekognition-developer-guide/blob/master/LICENSE-SAMPLECODE.) package aws.example.rekognition.image; import com.amazonaws.services.rekognition.AmazonRekognition; import com.amazonaws.services.rekognition.AmazonRekognitionClientBuilder; import com.amazonaws.services.rekognition.model.AmazonRekognitionException; import com.amazonaws.services.rekognition.model.DetectModerationLabelsRequest; import com.amazonaws.services.rekognition.model.DetectModerationLabelsResult; import com.amazonaws.services.rekognition.model.Image; import com.amazonaws.services.rekognition.model.ModerationLabel; import com.amazonaws.services.rekognition.model.S3Object; import java.util.List; public class DetectModerationLabels { public static void main(String[] args) throws Exception { String photo = "input.jpg"; String bucket = "bucket"; AmazonRekognition rekognitionClient = AmazonRekognitionClientBuilder.defaultClient(); DetectModerationLabelsRequest request = new DetectModerationLabelsRequest() .withImage(new Image().withS3Object(new S3Object().withName(photo).withBucket(bucket))) .withMinConfidence(60F); try { DetectModerationLabelsResult result = rekognitionClient.detectModerationLabels(request); List<ModerationLabel> labels = result.getModerationLabels(); System.out.println("Detected labels for " + photo); for (ModerationLabel label : labels) { System.out.println("Label: " + label.getName() + "\n Confidence: " + label.getConfidence().toString() + "%" + "\n Parent:" + label.getParentName()); } } catch (AmazonRekognitionException e) { e.printStackTrace(); } } } Java V2 This code is taken from the AWS Documentation SDK examples GitHub repository. See the full example here. //snippet-start:[rekognition.java2.recognize_video_text.import] //snippet-start:[rekognition.java2.detect_mod_labels.import] import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; import software.amazon.awssdk.core.SdkBytes; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.rekognition.RekognitionClient; import software.amazon.awssdk.services.rekognition.model.RekognitionException; import software.amazon.awssdk.services.rekognition.model.Image; import software.amazon.awssdk.services.rekognition.model.DetectModerationLabelsRequest; import software.amazon.awssdk.services.rekognition.model.DetectModerationLabelsResponse; import software.amazon.awssdk.services.rekognition.model.ModerationLabel; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.util.List; //snippet-end:[rekognition.java2.detect_mod_labels.import] /** * Before running this Java V2 code example, set up your development environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class ModerateLabels { public static void main(String[] args) { final String usage = "\n" + "Usage: " + " <sourceImage>\n\n" + "Where:\n" + " sourceImage - The path to the image (for example, C:\\AWS\\pic1.png). \n\n"; if (args.length < 1) { System.out.println(usage); System.exit(1); } String sourceImage = args[0]; Region region = Region.US_WEST_2; RekognitionClient rekClient = RekognitionClient.builder() .region(region) .credentialsProvider(ProfileCredentialsProvider.create("profile-name")) .build(); detectModLabels(rekClient, sourceImage); rekClient.close(); } // snippet-start:[rekognition.java2.detect_mod_labels.main] public static void detectModLabels(RekognitionClient rekClient, String sourceImage) { try { InputStream sourceStream = new FileInputStream(sourceImage); SdkBytes sourceBytes = SdkBytes.fromInputStream(sourceStream); Image souImage = Image.builder() .bytes(sourceBytes) .build(); DetectModerationLabelsRequest moderationLabelsRequest = DetectModerationLabelsRequest.builder() .image(souImage) .minConfidence(60F) .build(); DetectModerationLabelsResponse moderationLabelsResponse = rekClient.detectModerationLabels(moderationLabelsRequest); List<ModerationLabel> labels = moderationLabelsResponse.moderationLabels(); System.out.println("Detected labels for image"); for (ModerationLabel label : labels) { System.out.println("Label: " + label.name() + "\n Confidence: " + label.confidence().toString() + "%" + "\n Parent:" + label.parentName()); } } catch (RekognitionException | FileNotFoundException e) { e.printStackTrace(); System.exit(1); } } // snippet-end:[rekognition.java2.detect_mod_labels.main] AWS CLI This AWS CLI command displays the JSON output for the detect-moderation-labels CLI operation. Replace bucket and input.jpg with the S3 bucket name and the image file name that you used in step 2. Replace the value of profile_name with the name of your developer profile. aws rekognition detect-moderation-labels --image "{"S3Object":{"Bucket":"bucket-name","Name":"image-name"}}" \ --profile profile-name If you are accessing the CLI on a Windows device, use double quotes instead of single quotes and escape the inner double quotes by backslash (i.e. \) to address any parser errors you may encounter. For an example, see the following: aws rekognition detect-moderation-labels --image "{\"S3Object\":{\"Bucket\":\"bucket-name\",\"Name\":\"image-name\"}}" \ --profile profile-name Python This example outputs detected inappropriate or offensive content label names, confidence levels, and the parent label for detected inappropriate content labels. In the function main, replace the values of bucket and photo with the S3 bucket name and the image file name that you used in step 2. Replace the value of profile_name in the line that creates the Rekognition session with the name of your developer profile. #Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. #PDX-License-Identifier: MIT-0 (For details, see https://github.com/awsdocs/amazon-rekognition-developer-guide/blob/master/LICENSE-SAMPLECODE.) import boto3 def moderate_image(photo, bucket): session = boto3.Session(profile_name='profile-name') client = session.client('rekognition') response = client.detect_moderation_labels(Image={'S3Object':{'Bucket':bucket,'Name':photo}}) print('Detected labels for ' + photo) for label in response['ModerationLabels']: print (label['Name'] + ' : ' + str(label['Confidence'])) print (label['ParentName']) return len(response['ModerationLabels']) def main(): photo='image-name' bucket='bucket-name' label_count=moderate_image(photo, bucket) print("Labels detected: " + str(label_count)) if __name__ == "__main__": main() .NET This example outputs detected inappropriate or offensive content label names, confidence levels, and the parent label for detected moderation labels. Replace the values of bucket and photo with the S3 bucket name and the image file name that you used in step 2. //Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. //PDX-License-Identifier: MIT-0 (For details, see https://github.com/awsdocs/amazon-rekognition-developer-guide/blob/master/LICENSE-SAMPLECODE.) using System; using Amazon.Rekognition; using Amazon.Rekognition.Model; public class DetectModerationLabels { public static void Example() { String photo = "input.jpg"; String bucket = "bucket"; AmazonRekognitionClient rekognitionClient = new AmazonRekognitionClient(); DetectModerationLabelsRequest detectModerationLabelsRequest = new DetectModerationLabelsRequest() { Image = new Image() { S3Object = new S3Object() { Name = photo, Bucket = bucket }, }, MinConfidence = 60F }; try { DetectModerationLabelsResponse detectModerationLabelsResponse = rekognitionClient.DetectModerationLabels(detectModerationLabelsRequest); Console.WriteLine("Detected labels for " + photo); foreach (ModerationLabel label in detectModerationLabelsResponse.ModerationLabels) Console.WriteLine("Label: {0}\n Confidence: {1}\n Parent: {2}", label.Name, label.Confidence, label.ParentName); } catch (Exception e) { Console.WriteLine(e.Message); } } } anchoranchoranchoranchoranchor * Java * Java V2 * AWS CLI * Python * .NET This example outputs detected inappropriate content label names, confidence levels, and the parent label for detected moderation labels. Replace the values of bucket and photo with the S3 bucket name and the image file name that you used in step 2. //Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. //PDX-License-Identifier: MIT-0 (For details, see https://github.com/awsdocs/amazon-rekognition-developer-guide/blob/master/LICENSE-SAMPLECODE.) package aws.example.rekognition.image; import com.amazonaws.services.rekognition.AmazonRekognition; import com.amazonaws.services.rekognition.AmazonRekognitionClientBuilder; import com.amazonaws.services.rekognition.model.AmazonRekognitionException; import com.amazonaws.services.rekognition.model.DetectModerationLabelsRequest; import com.amazonaws.services.rekognition.model.DetectModerationLabelsResult; import com.amazonaws.services.rekognition.model.Image; import com.amazonaws.services.rekognition.model.ModerationLabel; import com.amazonaws.services.rekognition.model.S3Object; import java.util.List; public class DetectModerationLabels { public static void main(String[] args) throws Exception { String photo = "input.jpg"; String bucket = "bucket"; AmazonRekognition rekognitionClient = AmazonRekognitionClientBuilder.defaultClient(); DetectModerationLabelsRequest request = new DetectModerationLabelsRequest() .withImage(new Image().withS3Object(new S3Object().withName(photo).withBucket(bucket))) .withMinConfidence(60F); try { DetectModerationLabelsResult result = rekognitionClient.detectModerationLabels(request); List<ModerationLabel> labels = result.getModerationLabels(); System.out.println("Detected labels for " + photo); for (ModerationLabel label : labels) { System.out.println("Label: " + label.getName() + "\n Confidence: " + label.getConfidence().toString() + "%" + "\n Parent:" + label.getParentName()); } } catch (AmazonRekognitionException e) { e.printStackTrace(); } } } DETECTMODERATIONLABELS OPERATION REQUEST The input to DetectModerationLabels is an image. In this example JSON input, the source image is loaded from an Amazon S3 bucket. MinConfidence is the minimum confidence that Amazon Rekognition Image must have in the accuracy of the detected label for it to be returned in the response. { "Image": { "S3Object": { "Bucket": "bucket", "Name": "input.jpg" } }, "MinConfidence": 60 } DETECTMODERATIONLABELS OPERATION RESPONSE DetectModerationLabels can retrieve input images from an S3 bucket, or you can provide them as image bytes. The following example is the response from a call to DetectModerationLabels. In the following example JSON response, note the following: * Inappropriate Image Detection information – The example shows a list of labels for inappropriate or offensive content found in the image. The list includes the top-level label and each second-level label that are detected in the image. Label – Each label has a name, an estimation of the confidence that Amazon Rekognition has that the label is accurate, and the name of its parent label. The parent name for a top-level label is "". Label confidence – Each label has a confidence value between 0 and 100 that indicates the percentage confidence that Amazon Rekognition has that the label is correct. You specify the required confidence level for a label to be returned in the response in the API operation request. { "ModerationLabels": [ { "Confidence": 99.24723052978516, "ParentName": "", "Name": "Explicit Nudity" }, { "Confidence": 99.24723052978516, "ParentName": "Explicit Nudity", "Name": "Graphic Male Nudity" }, { "Confidence": 88.25341796875, "ParentName": "Explicit Nudity", "Name": "Sexual Activity" } ] } Javascript is disabled or is unavailable in your browser. To use the Amazon Web Services Documentation, Javascript must be enabled. Please refer to your browser's Help pages for instructions. Document Conventions Moderating content Detecting inappropriate stored videos Did this page help you? - Yes Thanks for letting us know we're doing a good job! If you've got a moment, please tell us what we did right so we can do more of it. Did this page help you? - No Thanks for letting us know this page needs work. We're sorry we let you down. If you've got a moment, please tell us how we can make the documentation better. Did this page help you? Yes No Provide feedback Next topic: Detecting inappropriate stored videos Previous topic:Moderating content Need help? * Try AWS re:Post * Connect with an AWS IQ expert PrivacySite termsCookie preferences © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. ON THIS PAGE -------------------------------------------------------------------------------- * Detecting inappropriate content in an image * DetectModerationLabels operation request * DetectModerationLabels operation response DID THIS PAGE HELP YOU? - NO Thanks for letting us know this page needs work. We're sorry we let you down. If you've got a moment, please tell us how we can make the documentation better. Feedback