Skip to content

fraukecharms/fastapi-sagemaker-compvision

Repository files navigation

Github Actions Badge

Create an Object Detection Demo

You can use this repo to quickly create a live public(!) demo website for object detection. The prediction requests are sent to your own Sagemaker endpoint. If you are looking for a solution that sends requests to AWS' built-in Rekognition service instead, check out this repo.

Before You Start

Make sure that you do all your work in a region where App Runner is available (e.g. eu-west-1 if you are based in Europe) and that you have the quota to deploy your inference endpoint in that region. In the video below I'm using an ml.m5.large instance.

Walk-Through Screen Recording

Here is an example of setting up a Cloud9 environment for your repo. Once that is up and running, feel free to follow along here:

Sagemaker Object Detection Demo (via FastAPI & AWS App Runner)

Docker Instructions

docker build --tag visiondemo-sagemaker .
docker run -p 127.0.0.1:8080:8080 -v $HOME/.aws/:/root/.aws:ro -e \
    AWS_PROFILE=default visiondemo-sagemaker

Push to ECR

Screenshot 2022-11-08 at 09 56 41

App Runner Permissions

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "tasks.apprunner.amazonaws.com"
            },
            "Action": "sts:AssumeRole"
        }
    ]
}

(Optional) Run without Docker

make install
python main.py

(Optional) Automated Testing with Github Actions

If you are interested in automated testing, check out the main.yml file in .github/workflows/. You can set this up by configuring OpenID Connect in AWS and creating an IAM role for your repo. You can read more about it here and here. However, this is optional and not required for the demo to work.

Learning Material

About

create a live ML demo on top of your own AWS Sagemaker endpoint

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published