Skip to content

Simple interface to upload image and predict with Yolov5 model

License

Notifications You must be signed in to change notification settings

annabelle1217/yolov5-flask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask REST API

REST APIs are commonly used to expose Machine Learning (ML) models to other services. This folder contains an example REST API created using Flask to expose the YOLOv5s model from PyTorch Hub.

Requirements

Install requirements.txt in a Python>=3.7.0 environment, including PyTorch>=1.7.

$ pip install -r requirements.txt

Run

After Flask installation run:

$ export FLASK_ENV=development && flask run

or

$ python app.py

To use custom model:

$ python app.py --model best.pt

Use GUI

Use GUI to upload and view resut: Go to http://localhost:5000

Use Terminal

Use curl to perform a request (Recommended: Git Bash):

$ curl -X POST -F image=@images/cat.jpg 'http://localhost:5000/v1/object-detection/yolov5s'

The model inference results are returned as a JSON response:

[{"xmin":384.2033081055,"ymin":35.8358840942,"xmax":823.404296875,"ymax":409.2363891602,"confidence":0.8502380848,"class":0,"name":"cat"}]

Example

example.gif

Reference

Note: The best.pt provided is self-trained yolov5 model on cats and dogs dataset.

About

Simple interface to upload image and predict with Yolov5 model

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published