# 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`
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
YOLO项目,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! 软件开发设计:PHP、QT、应用软件开发、系统软件开发、移动应用开发、网站开发C++、Java、python、web、C#等语言的项目开发与学习资料 硬件与设备:单片机、EDA、proteus、RTOS、包括计算机硬件、服务器、网络设备、存储设备、移动设备等 操作系统:LInux、IOS、树莓派、安卓开发、微机操作系统、网络操作系统、分布式操作系统等。此外,还有嵌入式操作系统、智能操作系统等。 云计算与大数据:数据集、包括云计算平台、大数据分析、人工智能、机器学习等,云计算是一种基于互联网的计算方式,通过这种方式,共享的软硬件资源和信息可以按需提供给计算机和其他设备。
资源推荐
资源详情
资源评论
收起资源包目录
An efficient Apex Legends Aimbot based on YoloV5 real-time target detection.zip (86个子文件)
cmd
.vscode
settings.json 69B
weights
apexSt1.pt 13.74MB
main.py 8KB
testvideo.mp4 22.23MB
utils
__init__.py 0B
google_utils.py 6KB
loss.py 9KB
flask_rest_api
example_request.py 299B
restapi.py 1KB
README.md 2KB
metrics.py 9KB
aws
__init__.py 0B
userdata.sh 1KB
mime.sh 780B
resume.py 1KB
autoanchor.py 7KB
general.py 29KB
wandb_logging
__init__.py 0B
log_dataset.py 800B
__pycache__
wandb_utils.cpython-36.pyc 12KB
__init__.cpython-36.pyc 134B
wandb_utils.cpython-38.pyc 12KB
__init__.cpython-38.pyc 142B
wandb_utils.py 16KB
activations.py 4KB
google_app_engine
Dockerfile 821B
app.yaml 173B
additional_requirements.txt 105B
plots.py 18KB
datasets.py 44KB
__pycache__
metrics.cpython-38.pyc 7KB
torch_utils.cpython-38.pyc 11KB
datasets.cpython-38.pyc 34KB
plots.cpython-36.pyc 16KB
general.cpython-36.pyc 23KB
datasets.cpython-36.pyc 34KB
torch_utils.cpython-36.pyc 11KB
google_utils.cpython-38.pyc 4KB
loss.cpython-38.pyc 6KB
google_utils.cpython-36.pyc 4KB
general.cpython-38.pyc 23KB
__init__.cpython-36.pyc 120B
loss.cpython-36.pyc 6KB
autoanchor.cpython-38.pyc 6KB
autoanchor.cpython-36.pyc 6KB
metrics.cpython-36.pyc 7KB
__init__.cpython-38.pyc 128B
plots.cpython-38.pyc 16KB
torch_utils.py 12KB
game.jpg 3.93MB
tmpimg
haha.jpg 7.91MB
requirements.txt 677B
models
hub
yolov5x6.yaml 2KB
anchors.yaml 3KB
yolov5-p2.yaml 2KB
yolov5-panet.yaml 1KB
yolov5s6.yaml 2KB
yolov3.yaml 1KB
yolov5-p6.yaml 2KB
yolov5-p7.yaml 2KB
yolov5l6.yaml 2KB
yolov5m6.yaml 2KB
yolov3-spp.yaml 1KB
yolov3-tiny.yaml 1KB
yolov5-fpn.yaml 1KB
yolov5s-transformer.yaml 1KB
__init__.py 0B
export.py 7KB
yolov5m.yaml 1KB
yolov5s.yaml 1KB
yolov5l.yaml 1KB
common.py 16KB
experimental.py 5KB
__pycache__
experimental.cpython-38.pyc 6KB
experimental.cpython-36.pyc 6KB
yolo.cpython-36.pyc 11KB
common.cpython-36.pyc 19KB
__init__.cpython-36.pyc 121B
common.cpython-38.pyc 18KB
yolo.cpython-38.pyc 11KB
__init__.cpython-38.pyc 129B
yolov5x.yaml 1KB
yolo.py 13KB
detect.py 9KB
__pycache__
detect.cpython-38.pyc 6KB
README.md 1KB
共 86 条
- 1
资源评论
妄北y
- 粉丝: 1w+
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- mod-ldap-2.4.6-31.el7.centos.1.x86-64.rpm
- mod-ldap-2.4.6-40.el7.centos.x86-64.rpm
- ResNet50模型训练猫狗数据集
- mod-ldap-2.4.6-80.el7.centos.x86-64.rpm
- mod-ldap-2.4.6-88.el7.centos.x86-64.rpm
- mod-ldap-2.4.6-89.el7.centos.1.x86-64.rpm
- mod-ldap-2.4.6-89.el7.centos.x86-64.rpm
- mod-ldap-2.4.6-99.el7.centos.1.x86-64.rpm
- 开源代码分享(31)-计及电转气协同的含碳捕集与垃圾焚烧虚拟电厂优化调度
- meta-llama-3-8b-instruct 的 model-00002-of-00004.safetensors 的1/3
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功