(The same content is also available here.)

This article describes an example of building an object detection API using AWS App Runner and YOLOv5.

Amazon ECR

The following repository publishes a YOLOv5 model using Flask:

https://github.com/robmarkcole/yolov5-flask

I registered an image of this repository in Amazon ECR (Elastic Container Registry) public registry.

https://gallery.ecr.aws/b8m8i5m3/yolov5-flask

Some source code has been modified from the original repository. The forked repository is available here:

https://github.com/ldasjp8/yolov5-flask

Below, I explain how to use this image with App Runner as an example.

AWS App Runner

Go to App Runner and click "Create service" in the upper right corner of the screen.

On the next "Source and deployment" screen, configure the settings as shown below. For "Container image URI", enter the following:

public.ecr.aws/b8m8i5m3/yolov5-flask:latest

On the next "Configure service" screen, enter a service name and change the port to 5000.

Proceed with the default settings for the remaining configuration, and you will be taken to the following screen.

After waiting about 5 to 10 minutes, it is successful when the "Status" shows "Running".

Using the domain from "Default domain" (https://XXXX.us-east-1.awsapprunner.com/), access the following URL:

https://XXXX.us-east-1.awsapprunner.com/detect?url=https://raw.githubusercontent.com/ultralytics/yolov5/master/data/images/zidane.jpg

JSON data containing the object detection results, as shown below, will be returned.

Summary

Using AWS App Runner, it was straightforward to build an object detection API with YOLOv5.