MyGit

robmarkcole/yolov5-flask

Fork: 90 Star: 185 (更新于 2024-11-02 15:55:46)

license: MIT

Language: Python .

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

最后发布版本: 1.4 ( 2022-12-13 17:57:47)

GitHub网址

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

最近版本更新:(数据更新于 2024-09-12 03:19:14)

2022-12-13 17:57:47 1.4

2022-08-30 11:18:52 1.3

2021-07-20 15:18:50 1.2

2021-04-08 11:15:16 1.1

2021-04-08 10:43:44 1.0

2021-04-05 14:07:44 0.2

2021-04-05 13:54:10 0.1

robmarkcole/yolov5-flask同语言 Python最近更新仓库

2024-11-05 16:16:26 Guovin/TV

2024-11-05 15:03:24 Cinnamon/kotaemon

2024-11-05 11:00:51 home-assistant/core

2024-11-04 23:11:11 DS4SD/docling

2024-11-04 10:56:18 open-compass/opencompass

2024-11-04 08:51:21 yt-dlp/yt-dlp