Yolo服务部署 YOLOv4 Deployment on AWS EC2 for Traffic/Stop Signs

Author: Zizhun Guo

作者:

写于:

YOLOv4 Deployment on AWS EC2 for Traffic/Stop Signs (TensorFlow + Flask + nginx + gunicorn)

Preparation

Steps

  1. Make sure YOLOv3 works fine: input an image and output the corresponding image plotting the predicted category score and bounding boxes.
  2. Create a Flask App, design a web page templete that matches the routes.
  3. Create an ubuntu EC2 Instance with default setting. Follow the rules by General prerequisites for connecting to your instance:
    • Open Security Group and open inbound SSH connection on local IP address.
    • Use PuTTy create SSH session for CLI mode remotely control the instance. Use winSCP create SFTP session for file uploading to the instance. Detail in Connect to your Linux instance from Windows using PuTTY
  4. Configure the instance by upgrade/update/install environment for being able to running the YOLO application:
    • Python3.8
    • TensorFlow 2.3.1
    • Pillow
    • opencv-python
    • matplotlib
    • Flask
    • Gunicorn
    • nginx
  5. Deploy it online (Details in (Deploy flask app with Nginx using Gunicorn)[https://medium.com/faun/deploy-flask-app-with-nginx-using-gunicorn-7fda4f50066a]):
    • Upload the project to the instance
    • Create the WSGI Entry Point wsgi.py
    • Serve the project by Gunicorn
    • Configuring Nginx

Details:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt apt-get install python3.8
python3.8 -m pip install --upgrade pip
python3.8 -m pip install tensorflow==2.3.1
python3.8 -m pip install Pillow
python3.8 -m pip install opencv-python
python3.8 -m pip install matplotlib
python3.8 -m pip install Flask
python3.8 -m pip install Gunicorn
python3.8 -m pip install tnginx

Application URL http://3.16.135.19/home

Application screenshot

drawing
YOLO project web page

Input example

drawing
Test Image

Results

drawing
Predicted Image

Results Screenshot

drawing
Results Screenshot
drawing
Deployment Architecture

Problems:

  1. Unicorn Server crash frequently when uploading greater size image.
  2. The result of predicted image may stay unchanged though using different input image

Potential Solutions:

  1. Deploy a supervisor program to manage server automatically by restarting the server.
  2. The browser keep the cache for the previous results since the name of the output image is the same. Mechanism for storing the output image on server could be changed to solve it.

Resources:

Back to Top