# 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 image=@zidane.jpg '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目标检测模型的知识蒸馏(基于响应的蒸馏) 教师模型: python train.py --weights weights/yolov5m.pt \ --cfg models/yolov5m.yaml --data data/voc.yaml --epochs 50 \ --batch-size 8 --device 0 --hyp data/hyp.scratch.yaml 蒸馏训练: python train.py --weights weights/yolov5s.pt \ --cfg models/yolov5s.yaml --data data/voc.yaml --epochs 50 \ --batch-size 8 --device 0 --hyp data/hyp.scratch.yaml \ --t_weights yolov5m.pt --distill
资源推荐
资源详情
资源评论
收起资源包目录
人工智能-项目实践-计算机视觉-yolov5目标检测模型的知识蒸馏(基于响应的蒸馏).zip (52个子文件)
yolov5-knowledge-distillation-main
export.py 8KB
hubconf.py 6KB
utils
__init__.py 0B
google_utils.py 6KB
loss.py 19KB
loggers
__init__.py 6KB
augmentations.py 11KB
flask_rest_api
example_request.py 299B
restapi.py 1KB
README.md 2KB
metrics.py 13KB
aws
__init__.py 0B
userdata.sh 1KB
mime.sh 780B
resume.py 1KB
autoanchor.py 7KB
general.py 28KB
activations.py 4KB
google_app_engine
Dockerfile 821B
app.yaml 173B
additional_requirements.txt 105B
plots.py 18KB
datasets.py 39KB
torch_utils.py 12KB
convert.py 3KB
val.py 16KB
requirements.txt 703B
models
hub
yolov5x6.yaml 2KB
anchors.yaml 3KB
yolov5-p2.yaml 2KB
yolov5-panet.yaml 2KB
yolov5s6.yaml 2KB
yolov3.yaml 2KB
yolov5-p6.yaml 2KB
yolov5-p7.yaml 2KB
yolov5l6.yaml 2KB
yolov5m6.yaml 2KB
yolov3-spp.yaml 2KB
yolov3-tiny.yaml 1KB
yolov5-fpn.yaml 1KB
yolov5s-transformer.yaml 2KB
__init__.py 0B
yolov5m.yaml 1KB
yolov5s.yaml 1KB
yolov5l.yaml 1KB
common.py 16KB
experimental.py 5KB
yolov5x.yaml 1KB
yolo.py 13KB
detect.py 12KB
train.py 30KB
distill.py 31KB
共 52 条
- 1
资源评论
博士僧小星
- 粉丝: 2381
- 资源: 5995
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功