madakixo / build-sell-computer-vision-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

build-sell-computer-vision-api

Watch the video
Watch on YouTube: Build and sell your own computer vision API |
Image classification with Python and Yolov8

model

We will be using an image classifier I trained with Yolov8. The model was trained using this dataset and following this step by step tutorial on how to train an image classifier with Yolov8 on your custom data. The model is available here.

model performance

The model was successfully trained for 30 epochs achieving a ~96% accuracy.

Model performance
Model performance. Validation and training loss during the training process
and validation accuracy. Accuracy is around 96%.

server setup

Log into your AWS account and launch a t2.xlarge EC2 instance, using the latest stable Ubuntu image.

SSH into the instance and run these commands to update the software repository and install the dependencies.

sudo apt-get update
sudo apt install -y python3-pip nginx

sudo nano /etc/nginx/sites-enabled/fastapi_nginx

And put this config into the file (replace the IP address with your EC2 instance's public IP):

server {
    listen 80;   
    server_name <YOUR_EC2_IP>;
    location / {        
        proxy_pass http://127.0.0.1:8000;    
    }
}

sudo service nginx restart

Update EC2 security-group settings for your instance to allow HTTP traffic to port 80.

launch api

Install dependencies:

pip install ultralytics fastapi uvicorn

Launch API:

python3 -m uvicorn main:app

About


Languages

Language:Python 100.0%