glenn-jocher commited on
Commit
c1c7eb0
1 Parent(s): 52c0570

Update JSON response (#3139)

Browse files
Files changed (1) hide show
  1. 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 `yolov5s` model from [PyTorch Hub](https://pytorch.org/hub/ultralytics_yolov5/).
3
 
4
  ## Requirements
5
 
@@ -22,30 +22,47 @@ Then use [curl](https://curl.se/) to perform a request:
22
  $ curl -X POST -F image=@zidane.jpg 'http://localhost:5000/v1/object-detection/yolov5s'`
23
  ```
24
 
25
- The model inference results are returned:
26
 
27
- ```shell
28
- [{'class': 0,
29
- 'confidence': 0.8197850585,
30
- 'name': 'person',
31
- 'xmax': 1159.1403808594,
32
- 'xmin': 750.912902832,
33
- 'ymax': 711.2583007812,
34
- 'ymin': 44.0350036621},
35
- {'class': 0,
36
- 'confidence': 0.5667674541,
37
- 'name': 'person',
38
- 'xmax': 1065.5523681641,
39
- 'xmin': 116.0448303223,
40
- 'ymax': 713.8904418945,
41
- 'ymin': 198.4603881836},
42
- {'class': 27,
43
- 'confidence': 0.5661227107,
44
- 'name': 'tie',
45
- 'xmax': 516.7975463867,
46
- 'xmin': 416.6880187988,
47
- 'ymax': 717.0524902344,
48
- 'ymin': 429.2020568848}]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 image=@zidane.jpg '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`