glenn-jocher
commited on
Commit
•
c1c7eb0
1
Parent(s):
52c0570
Update JSON response (#3139)
Browse files- utils/flask_rest_api/README.md +41 -24
utils/flask_rest_api/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
# Flask REST API
|
2 |
-
[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
|
3 |
|
4 |
## Requirements
|
5 |
|
@@ -22,30 +22,47 @@ Then use [curl](https://curl.se/) to perform a request:
|
|
22 |
$ curl -X POST -F [email protected] 'http://localhost:5000/v1/object-detection/yolov5s'`
|
23 |
```
|
24 |
|
25 |
-
The model inference results are returned:
|
26 |
|
27 |
-
```
|
28 |
-
[
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
```
|
50 |
|
51 |
An example python script to perform inference using [requests](https://docs.python-requests.org/en/master/) is given in `example_request.py`
|
|
|
1 |
# Flask REST API
|
2 |
+
[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/).
|
3 |
|
4 |
## Requirements
|
5 |
|
|
|
22 |
$ curl -X POST -F [email protected] 'http://localhost:5000/v1/object-detection/yolov5s'`
|
23 |
```
|
24 |
|
25 |
+
The model inference results are returned as a JSON response:
|
26 |
|
27 |
+
```json
|
28 |
+
[
|
29 |
+
{
|
30 |
+
"class": 0,
|
31 |
+
"confidence": 0.8900438547,
|
32 |
+
"height": 0.9318675399,
|
33 |
+
"name": "person",
|
34 |
+
"width": 0.3264600933,
|
35 |
+
"xcenter": 0.7438579798,
|
36 |
+
"ycenter": 0.5207948685
|
37 |
+
},
|
38 |
+
{
|
39 |
+
"class": 0,
|
40 |
+
"confidence": 0.8440024257,
|
41 |
+
"height": 0.7155083418,
|
42 |
+
"name": "person",
|
43 |
+
"width": 0.6546785235,
|
44 |
+
"xcenter": 0.427829951,
|
45 |
+
"ycenter": 0.6334488392
|
46 |
+
},
|
47 |
+
{
|
48 |
+
"class": 27,
|
49 |
+
"confidence": 0.3771208823,
|
50 |
+
"height": 0.3902671337,
|
51 |
+
"name": "tie",
|
52 |
+
"width": 0.0696444362,
|
53 |
+
"xcenter": 0.3675483763,
|
54 |
+
"ycenter": 0.7991207838
|
55 |
+
},
|
56 |
+
{
|
57 |
+
"class": 27,
|
58 |
+
"confidence": 0.3527112305,
|
59 |
+
"height": 0.1540903747,
|
60 |
+
"name": "tie",
|
61 |
+
"width": 0.0336618312,
|
62 |
+
"xcenter": 0.7814827561,
|
63 |
+
"ycenter": 0.5065554976
|
64 |
+
}
|
65 |
+
]
|
66 |
```
|
67 |
|
68 |
An example python script to perform inference using [requests](https://docs.python-requests.org/en/master/) is given in `example_request.py`
|