Edit

Share via


Analyze image content with docker containers (preview)

The Analyze image container scans images for sexual content, violence, hate, and self-harm with multi-severity levels. This guide shows how to download, install, and run a content safety image container.

For more information about prerequisites, validating that a container is running, running multiple containers on the same host, and running disconnected containers, see Install and run content safety containers with Docker.

Specify a container image

The content safety analyze image container image for all supported versions can be found on the Microsoft Container Registry (MCR) syndicate. It resides in the azure-cognitive-services/contentsafety repository and is named image-analyze.

Screenshot of image container on registry website.

The fully qualified container name is, mcr.microsoft.com/en-us/product/azure-cognitive-services/contentsafety/image-analyze. Append a specific container version, or append :latest to get the most recent version. For example:

Version Path
Latest mcr.microsoft.com/azure-cognitive-services/contentsafety/image-analyze:latest

The latest tag pulls the latest image.
1.0.0-amd64-preview mcr.microsoft.com/azure-cognitive-services/contentsafety/image-analyze:1.0.0-amd64-preview

Get the container image

Make sure you meet the prerequisites, including required hardware. Also see the recommended allocation of resources section for each content safety container.

Use the docker pull command to download a container image from Microsoft Container Registry:

docker mcr.microsoft.com/azure-cognitive-services/contentsafety/image-analyze:latest

Run the container

Use the docker run command to run the container.

The following table represents the various docker run parameters and their corresponding descriptions:

Parameter Description
{ENDPOINT_URI} The endpoint is required for metering and billing. For more information, see billing arguments.
{API_KEY} The API key is required. For more information, see billing arguments.

When you run the content safety analyze image container, configure the port, memory, and CPU according to the requirements and recommendations.

Here's a sample docker run command with placeholder values. You must specify the ENDPOINT_URI and API_KEY values:

docker run --rm -it -p 5000:5000 --gpus all \
mcr.microsoft.com/azure-cognitive-services/contentsafety/image-analyze:latest \
Eula=accept \
Billing={ENDPOINT_URI} \
ApiKey={API_KEY}

This command:

  • Runs an image-analyze container from the container image.
  • Uses all available GPU resources (by specifying --gpus all). Content safety containers require CUDA for optimal performance. Learn more in host requirements and recommendations. Also make sure your host installs NVIDIA container toolkit.
  • Exposes TCP port 5000 and allocates a pseudo-TTY for the container.
  • Automatically removes the container after it exits. The container image is still available on the host computer.

Test the container

Once the container is up and running, you can validate its operation by sending a request to the REST endpoint deployed within the container. To do this, follow the steps in the quickstart. Note, you need to replace the endpoint URL with the Docker URL specific to your container deployment. Also, ensure that you're using host authentication, rather than key-based authentication.

Analyze image quickstart

Next steps