Image Service Content Moderation

Meryln Peter 25 Reputation points

Hi Team,

I work for retail client where I will be uploading images like products on shelves you have to moderate the images based on the content classification. Any Azure AI service is there and please recommend any Python code. Any leads that will be appreciated.



Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,444 questions
0 comments No comments
{count} votes

Accepted answer
  1. Janarthanan S 700 Reputation points

    Hi @Meryln Peter

    Since you work for retail client especially products on shelves images in order to moderate the images use Computer Vision and Content Safety service.

    The Product Recognition APIs let you analyze photos of shelves in a retail store. You can detect the presence of products and get their bounding box coordinates. Use it in combination with model customization to train a model to identify your specific products.

    Please find detailed documentation for computer vision product on shelves

    In order to moderate the content on images use detailed documentation

    Please find sample python code to moderate the image content on the product on the shelves.

    def analyze_image():
        # [START analyze_image]
        import os
        from import ContentSafetyClient
        from azure.core.credentials import AzureKeyCredential
        from azure.core.exceptions import HttpResponseError
        from import AnalyzeImageOptions, ImageData
        key = os.environ["CONTENT_SAFETY_KEY"]
        endpoint = os.environ["CONTENT_SAFETY_ENDPOINT"]
        image_path = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "./sample_data/image.jpg"))
        # Create an Content Safety client
        client = ContentSafetyClient(endpoint, AzureKeyCredential(key))
        # Build request
        with open(image_path, "rb") as file:
            request = AnalyzeImageOptions(image=ImageData(
        # Analyze image
            response = client.analyze_image(request)
        except HttpResponseError as e:
            print("Analyze image failed.")
            if e.error:
                print(f"Error code: {e.error.code}")
                print(f"Error message: {e.error.message}")
        if response.hate_result:
            print(f"Hate severity: {response.hate_result.severity}")
        if response.self_harm_result:
            print(f"SelfHarm severity: {response.self_harm_result.severity}")
        if response.sexual_result:
            print(f"Sexual severity: {response.sexual_result.severity}")
        if response.violence_result:
            print(f"Violence severity: {response.violence_result.severity}")
        # [END analyze_image]
    if __name__ == "__main__":

    Please try out these steps with your data and check if it works. Hope this answer helps you with solution! Please comment below if you need any assistance on the same. Happy to help!


    Janarthanan S

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. VasaviLankipalle-MSFT 14,911 Reputation points

    Hello @Meryln Peter , Thanks for using Microsoft Q&A Platform.

    As we know the Azure AI Vision Image Analysis service can extract a wide variety of visual features from the images. I would suggest going through the product recognition APIs which let you analyze photos of shelves in a retail store

    Here is the python GitHub sample code related to the product recognition:

    Please review these and see if that fits your use case.

    I hope this helps.


    -Please kindly accept the answer and vote 'yes' if you feel helpful to support the community, thanks.

    0 comments No comments