# 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进行水域游泳者检测系统.zip
共1876个文件
jpg:880个
txt:811个
yaml:60个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 40 浏览量
2023-03-21
14:18:43
上传
评论 1
收藏 231.96MB ZIP 举报
温馨提示
YOLOv5进行水域游泳者检测系统.zip
资源推荐
资源详情
资源评论
收起资源包目录
YOLOv5进行水域游泳者检测系统.zip (1876个子文件)
events.out.tfevents.1622345317.b56b89382d6f.544.0 750KB
events.out.tfevents.1622348409.b56b89382d6f.776.0 745KB
events.out.tfevents.1622347943.b56b89382d6f.682.0 694KB
events.out.tfevents.1622343384.b56b89382d6f.158.0 689KB
events.out.tfevents.1622450972.fc846bd6f9e4.353.0 688KB
events.out.tfevents.1622450126.fc846bd6f9e4.246.0 681KB
events.out.tfevents.1622343372.b56b89382d6f.148.0 40B
train2017.cache 43KB
Dockerfile 2KB
Dockerfile 846B
.dockerignore 4KB
.DS_Store 8KB
.DS_Store 8KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
tutorial.ipynb 386KB
image_test_002.jpeg 129KB
image_test_002-checkpoint.jpeg 129KB
image_test_003.jpeg 119KB
image_test_003-checkpoint.jpeg 119KB
img_110.jpg 1.32MB
img_110.jpg 1.32MB
img_109.jpg 1.16MB
img_109.jpg 1.16MB
img_111.jpg 1.06MB
img_111.jpg 1.06MB
img_113.jpg 1.06MB
img_113.jpg 1.06MB
img_117.jpg 1MB
img_117.jpg 1MB
img_106.jpg 960KB
img_106.jpg 960KB
img_067.jpg 931KB
img_067.jpg 931KB
img_080.jpg 667KB
img_080.jpg 667KB
img_116.jpg 606KB
img_116.jpg 606KB
000000000575.jpg 530KB
img_115.jpg 518KB
img_115.jpg 518KB
labels.jpg 506KB
labels.jpg 506KB
bus-checkpoint.jpg 483KB
bus.jpg 483KB
bus.jpg 476KB
img_114.jpg 470KB
img_114.jpg 470KB
labels.jpg 454KB
image_258.jpg 423KB
labels_correlogram.jpg 423KB
labels_correlogram.jpg 423KB
labels_correlogram.jpg 412KB
000000000034.jpg 397KB
000000000061.jpg 391KB
train_batch2.jpg 389KB
000000000073.jpg 375KB
000000000151.jpg 374KB
img_088.jpg 372KB
img_088.jpg 372KB
labels.jpg 367KB
labels.jpg 367KB
train_batch0.jpg 354KB
train_batch2.jpg 349KB
train_batch2.jpg 349KB
train_batch1.jpg 349KB
train_batch1.jpg 349KB
train_batch1.jpg 344KB
000000000368.jpg 341KB
labels_correlogram.jpg 341KB
train_batch0.jpg 339KB
train_batch0.jpg 339KB
test_batch2_pred.jpg 331KB
test_batch2_pred-checkpoint.jpg 331KB
test_batch2_labels.jpg 331KB
test_batch2_labels-checkpoint.jpg 331KB
000000000309.jpg 330KB
000000000397.jpg 313KB
000000000605.jpg 311KB
test_batch2_pred.jpg 309KB
test_batch2_pred-checkpoint.jpg 309KB
labels.jpg 308KB
test_batch2_labels.jpg 303KB
test_batch2_labels.jpg 303KB
test_batch2_pred.jpg 296KB
test_batch2_pred-checkpoint.jpg 296KB
000000000312.jpg 293KB
labels_correlogram.jpg 292KB
labels_correlogram.jpg 292KB
000000000307.jpg 292KB
test_batch1_pred.jpg 292KB
img_112.jpg 288KB
img_112.jpg 288KB
000000000502.jpg 287KB
000000000629.jpg 286KB
img_087.jpg 281KB
共 1876 条
- 1
- 2
- 3
- 4
- 5
- 6
- 19
资源评论
- tiebiao0992024-01-11感谢资源主的分享,很值得参考学习,资源价值较高,支持!
oligaga
- 粉丝: 53
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功