# Flask REST API
[REST](https://en.wikipedia.org/wiki/Representational_state_transfer) [API](https://en.wikipedia.org/wiki/API)s 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](https://pytorch.org/hub/ultralytics_yolov5/).
## Requirements
[Flask](https://palletsprojects.com/p/flask/) is required. Install with:
```shell
$ pip install Flask
```
## Run
After Flask installation run:
```shell
$ python3 restapi.py --port 5000
```
Then use [curl](https://curl.se/) to perform a request:
```shell
$ curl -X POST -F [email protected] 'http://localhost:5000/v1/object-detection/yolov5s'`
```
The model inference results are returned as a JSON response:
```json
[
{
"class": 0,
"confidence": 0.8900438547,
"height": 0.9318675399,
"name": "person",
"width": 0.3264600933,
"xcenter": 0.7438579798,
"ycenter": 0.5207948685
},
{
"class": 0,
"confidence": 0.8440024257,
"height": 0.7155083418,
"name": "person",
"width": 0.6546785235,
"xcenter": 0.427829951,
"ycenter": 0.6334488392
},
{
"class": 27,
"confidence": 0.3771208823,
"height": 0.3902671337,
"name": "tie",
"width": 0.0696444362,
"xcenter": 0.3675483763,
"ycenter": 0.7991207838
},
{
"class": 27,
"confidence": 0.3527112305,
"height": 0.1540903747,
"name": "tie",
"width": 0.0336618312,
"xcenter": 0.7814827561,
"ycenter": 0.5065554976
}
]
```
An example python script to perform inference using [requests](https://docs.python-requests.org/en/master/) is given in `example_request.py`
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Yolov5水果分类识别+pyqt交互式界面:详情见博客:https://blog.csdn.net/ALiLiLiYa/article/details/135153162?spm=1001.2014.3001.5502
资源推荐
资源详情
资源评论
收起资源包目录
Yolov5水果分类识别+pyqt交互式界面 (102个子文件)
Dockerfile 821B
.DS_Store 6KB
.DS_Store 6KB
.gitignore 12B
YoloToONNX.ipynb 4KB
README.md 2KB
README.md 1KB
datasets.py 44KB
train.py 33KB
general.py 28KB
plots.py 19KB
test.py 17KB
common.py 16KB
wandb_utils.py 16KB
yolo.py 13KB
torch_utils.py 12KB
loss.py 9KB
detect.py 9KB
metrics.py 9KB
autoanchor.py 7KB
export.py 7KB
hubconf.py 6KB
experimental.py 5KB
google_utils.py 5KB
detector.py 4KB
activations.py 4KB
main.py 3KB
resume.py 1KB
restapi.py 1KB
log_dataset.py 800B
example_request.py 299B
__init__.py 0B
__init__.py 0B
__init__.py 0B
__init__.py 0B
__init__.py 0B
datasets.cpython-37.pyc 33KB
datasets.cpython-38.pyc 33KB
general.cpython-38.pyc 23KB
general.cpython-37.pyc 23KB
common.cpython-37.pyc 19KB
common.cpython-38.pyc 18KB
plots.cpython-37.pyc 17KB
plots.cpython-38.pyc 16KB
torch_utils.cpython-38.pyc 11KB
torch_utils.cpython-37.pyc 11KB
yolo.cpython-38.pyc 11KB
yolo.cpython-37.pyc 11KB
metrics.cpython-37.pyc 8KB
metrics.cpython-38.pyc 7KB
autoanchor.cpython-37.pyc 6KB
autoanchor.cpython-38.pyc 6KB
experimental.cpython-37.pyc 6KB
experimental.cpython-38.pyc 6KB
google_utils.cpython-38.pyc 3KB
google_utils.cpython-37.pyc 3KB
__init__.cpython-38.pyc 172B
__init__.cpython-38.pyc 171B
__init__.cpython-37.pyc 164B
__init__.cpython-37.pyc 163B
main.pyproject 43B
get_voc.sh 4KB
get_argoverse_hd.sh 2KB
userdata.sh 1KB
get_coco.sh 962B
mime.sh 780B
get_coco128.sh 618B
download_weights.sh 277B
requirements.txt 613B
additional_requirements.txt 105B
form.ui 3KB
main.pyproject.user 10KB
objects365.yaml 7KB
anchors.yaml 3KB
VisDrone.yaml 3KB
SKU-110K.yaml 2KB
yolov5-p7.yaml 2KB
GlobalWheat2020.yaml 2KB
yolov5x6.yaml 2KB
yolov5s6.yaml 2KB
yolov5m6.yaml 2KB
yolov5l6.yaml 2KB
yolov5-p6.yaml 2KB
yolov5-p2.yaml 2KB
coco.yaml 2KB
hyp.scratch.yaml 2KB
coco128.yaml 2KB
yolov3-spp.yaml 1KB
yolov3.yaml 1KB
yolov5-panet.yaml 1KB
yolov5s-transformer.yaml 1KB
yolov5m.yaml 1KB
yolov5s.yaml 1KB
yolov5x.yaml 1KB
yolov5l.yaml 1KB
yolov5-fpn.yaml 1KB
yolov3-tiny.yaml 1KB
argoverse_hd.yaml 848B
hyp.finetune.yaml 846B
voc.yaml 737B
共 102 条
- 1
- 2
资源评论
阿利同学
- 粉丝: 3w+
- 资源: 290
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功