Giter Site home page Giter Site logo

jmau2002 / yolov5-flask Goto Github PK

View Code? Open in Web Editor NEW

This project forked from robmarkcole/yolov5-flask

0.0 0.0 0.0 15.17 MB

Official implementation at https://github.com/ultralytics/yolov5/tree/master/utils/flask_rest_api

License: MIT License

Python 52.04% CSS 6.65% HTML 37.95% Dockerfile 3.35%

yolov5-flask's Introduction

Yolov5 object detection model deployment using flask

This repo contains example apps for exposing the yolo5 object detection model from pytorch hub via a flask api/app.

Web app

Simple app consisting of a form where you can upload an image, and see the inference result of the model in the browser. Run:

$ python3 webapp.py --port 5000

then visit http://localhost:5000/ in your browser:

Processed images are saved in the static directory with a datetime for the filename.

Rest API

Simple rest API exposing the model for consumption by another service. Run:

$ python3 restapi.py --port 5000 --model yolov5s

Then use curl to perform a request:

$ curl -X POST -F image=@tests/zidane.jpg 'http://localhost:5000/v1/object-detection/yolov5'

The model inference results are returned:

[{'class': 0,
  'confidence': 0.8197850585,
  'name': 'person',
  'xmax': 1159.1403808594,
  'xmin': 750.912902832,
  'ymax': 711.2583007812,
  'ymin': 44.0350036621},
 {'class': 0,
  'confidence': 0.5667674541,
  'name': 'person',
  'xmax': 1065.5523681641,
  'xmin': 116.0448303223,
  'ymax': 713.8904418945,
  'ymin': 198.4603881836},
 {'class': 27,
  'confidence': 0.5661227107,
  'name': 'tie',
  'xmax': 516.7975463867,
  'xmin': 416.6880187988,
  'ymax': 717.0524902344,
  'ymin': 429.2020568848}]

Run & Develop locally

Run locally for dev, requirements mostly originate from yolov5:

  • python3 -m venv venv
  • source venv/bin/activate
  • (venv) $ pip install -r requirements.txt
  • (venv) $ python3 restapi.py --port 5000

An example python script to perform inference using requests is given in tests/test_request.py

Docker

The example dockerfile shows how to expose the rest API:

# Build
docker build -t yolov5-flask .
# Run
docker run -p 5000:5000 yolov5-flask:latest

reference

yolov5-flask's People

Contributors

ahmetkipkip avatar robmarkcole avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.