Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      The Value-Driven AI Roadmap

      September 9, 2025

      This week in AI updates: Mistral’s new Le Chat features, ChatGPT updates, and more (September 5, 2025)

      September 6, 2025

      Designing For TV: Principles, Patterns And Practical Guidance (Part 2)

      September 5, 2025

      Neo4j introduces new graph architecture that allows operational and analytics workloads to be run together

      September 5, 2025

      ‘Job Hugging’ Trend Emerges as Workers Confront AI Uncertainty

      September 8, 2025

      Distribution Release: MocaccinoOS 25.09

      September 8, 2025

      Composition in CSS

      September 8, 2025

      DataCrunch raises €55M to boost EU AI sovereignty with green cloud infrastructure

      September 8, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Finally, safe array methods in JavaScript

      September 9, 2025
      Recent

      Finally, safe array methods in JavaScript

      September 9, 2025

      Perficient Interviewed for Forrester Report on AI’s Transformative Role in DXPs

      September 9, 2025

      Perficient’s “What If? So What?” Podcast Wins Gold Stevie® Award for Technology Podcast

      September 9, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Distribution Release: MocaccinoOS 25.09

      September 8, 2025
      Recent

      Distribution Release: MocaccinoOS 25.09

      September 8, 2025

      Speed Isn’t Everything When Buying SSDs – Here’s What Really Matters!

      September 8, 2025

      14 Themes for Beautifying Your Ghostty Terminal

      September 8, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Moderate Image Uploads with AI/GenAI & AWS Rekognition

    Moderate Image Uploads with AI/GenAI & AWS Rekognition

    July 24, 2025

    As we all know, in the world of reels, Photos, and videos, Everyone is creating content and uploading to public-facing applications, such as social media. There is no control over the type of images users upload to the website. Here, we will discuss how to restrict inappropriate photos.

    The AWS Rekognition Service can help you restrict this. AWS Rekognition Content moderation can detect inappropriate or unwanted content and provide levels for the images. By using that, not only can you make your business site compliant, but it also saves you a lot of cost, as you must pay only for what you use, without minimum fees, licenses, or upfront commitments.

    This will require Lambda and API Gateway.

    Implementing AWS Rekognition

    To implement the solution, you must create a Lambda function and an API Gateway.

    So the flow of solution will be like in the following manner:
    2

    Lambda

    To create Lambda, you can follow the steps below:
    1. Go to AWS Lambda Service and click on Create function, add information, and click on Create function.

    123

    1. Make sure to add the permission below in Lambda Execution role:
    {
        "Version": "2012-10-17",
        "Statement": [
           {
                "Sid": "VisualEditor0",
                "Effect": "Allow",
                "Action": "rekognition:*",
                "Resource": "*"
            }
        ]
    }
    1. You can use the Python code below:

    Below, the sample Python code sends the image to the AWS Rekognition service, retrieves the moderation level from it, and based on that, decides whether it is safe or unsafe.

    responses = rekognition.detect_moderation_labels(
                Image={'Bytes': image_bytes},
                MinConfidence=80
            )
            print(responses)
            response = str(responses)    
            filter_keywords = ["Weapons","Graphic Violence","Death and Emaciation","Crashes","Products","Drugs & Tobacco Paraphernalia & Use","Alcohol Use","Alcoholic Beverages","Explicit Nudity","Explicit Sexual Activity","Sex Toys","Non-Explicit Nudity","Obstructed Intimate Parts","Kissing on the Lips","Female Swimwear or Underwear","Male Swimwear or Underwear","Middle Finger","Swimwear or Underwear","Nazi Party","White Supremacy","Extremist","Gambling" ]
            def check_for_unsafe_keywords(response: str):
                response_lower = response.lower()
                unsafe_keywords_found = [
                    keyword for keyword in filter_keywords if keyword.lower() in response_lower
                ]
                return unsafe_keywords_found
            unsafe = check_for_unsafe_keywords(response)
            if unsafe:
                print("Unsafe keywords found:", unsafe)
                return {
                    'statusCode': 403,
                    'headers': {'Content-Type': 'application/json'
                    },
                    'body': json.dumps({
                        "Unsafe": "Asset is Unsafe",
                        "labels": unsafe
                    })
                }
            else:
                print("No unsafe content detected.")
                return {
                    'statusCode': 200,
                    'headers': {'Content-Type': 'application/json'},
                    'body': json.dumps({
                       "safe": "Asset is safe",
                        "labels": unsafe
                    })
                }

    4.  Then click on the Deploy button to deploy the code.

    AWS Api Gateway

    You need to create an API gateway that can help you send an image to Lambda to process with AWS Rekognition and then send the response to the User.

    Sample API Integration:


    Picture11

     

    Once this is all set, when you send the image to the API gateway in the body, you will receive a response in a safe or unsafe manner.

    Picture9

    Conclusion

    With this solution, your application prevents the uploading of any inappropriate or unwanted images. It is very cost-friendly too. It also helps make your site compliant.

     

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleWCAG Compliance for Drupal Sites with UserWay
    Next Article Top Picks for the Best CPP Compiler: Enhance Your Coding Experience

    Related Posts

    Development

    Leading the QA Charge: Multi-Agent Systems Redefining Automation

    September 9, 2025
    Development

    Stop Duct-Taping AI Agents Together: Meet SmythOS

    September 9, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    Windows 11 KB5055627 24H2 fixes BSODs, direct download .msu

    Operating Systems

    How Amazon Finance Automation built an operational data store with AWS purpose built databases to power critical finance applications

    Databases

    Elpher is a gopher and gemini client for Emacs

    Linux

    NVIDIA’s latest driver fixes some big issues with DOOM: The Dark Ages

    News & Updates

    Highlights

    How to create a Liquid Glass effect with SVG filters

    July 15, 2025

    In this tutorial I’ll show you how to create a liquid glass effect (much like…

    Norma Kamali is transforming the future of fashion with AI

    April 22, 2025

    zgenom – lightweight and fast plugin manager for Zsh

    June 4, 2025

    GMines is a clone of the well-known minesweeper game

    June 8, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.