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

      Designing Better UX For Left-Handed People

      July 25, 2025

      This week in AI dev tools: Gemini 2.5 Flash-Lite, GitLab Duo Agent Platform beta, and more (July 25, 2025)

      July 25, 2025

      Tenable updates Vulnerability Priority Rating scoring method to flag fewer vulnerabilities as critical

      July 24, 2025

      Google adds updated workspace templates in Firebase Studio that leverage new Agent mode

      July 24, 2025

      Trump’s AI plan says a lot about open source – but here’s what it leaves out

      July 25, 2025

      Google’s new Search mode puts classic results back on top – how to access it

      July 25, 2025

      These AR swim goggles I tested have all the relevant metrics (and no subscription)

      July 25, 2025

      Google’s new AI tool Opal turns prompts into apps, no coding required

      July 25, 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

      Laravel Scoped Route Binding for Nested Resource Management

      July 25, 2025
      Recent

      Laravel Scoped Route Binding for Nested Resource Management

      July 25, 2025

      Add Reactions Functionality to Your App With Laravel Reactions

      July 25, 2025

      saasykit/laravel-open-graphy

      July 25, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Sam Altman won’t trust ChatGPT with his “medical fate” unless a doctor is involved — “Maybe I’m a dinosaur here”

      July 25, 2025
      Recent

      Sam Altman won’t trust ChatGPT with his “medical fate” unless a doctor is involved — “Maybe I’m a dinosaur here”

      July 25, 2025

      “It deleted our production database without permission”: Bill Gates called it — coding is too complex to replace software engineers with AI

      July 25, 2025

      Top 6 new features and changes coming to Windows 11 in August 2025 — from AI agents to redesigned BSOD screens

      July 25, 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

    Laravel Scoped Route Binding for Nested Resource Management

    July 25, 2025
    Development

    Add Reactions Functionality to Your App With Laravel Reactions

    July 25, 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

    Microsoft Admits Windows 11 Firewall Bug Still Isn’t Fixed

    Operating Systems

    Creating proportional, equal-height image rows with CSS

    Web Development

    CVE-2025-3468 – NEX-Forms Stored Cross-Site Scripting Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Architect a mature generative AI foundation on AWS

    Machine Learning

    Highlights

    CVE-2025-34120 – LimeSurvey Unauthenticated File Download Vulnerability

    July 16, 2025

    CVE ID : CVE-2025-34120

    Published : July 16, 2025, 9:15 p.m. | 5 hours, 47 minutes ago

    Description : An unauthenticated file download vulnerability exists in LimeSurvey versions from 2.0+ up to and including 2.06+ Build 151014. The application fails to validate serialized input to the admin backup endpoint (`index.php/admin/update/sa/backup`), allowing attackers to specify arbitrary file paths using a crafted `datasupdateinfo` payload. The files are packaged in a ZIP archive and made available for download without authentication. This vulnerability can be exploited to read arbitrary files on the host system, including sensitive OS and configuration files.

    Severity: 0.0 | NA

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    CVE-2025-3200 – “Com-Server TLS Protocol Downgrade Vulnerability”

    April 28, 2025

    CVE-2025-5630 – D-Link DIR-816 Remote Stack-Based Buffer Overflow Vulnerability

    June 4, 2025

    CVE-2025-4197 – Code-projects Patient Record Management System SQL Injection Vulnerability

    May 2, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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