glenn-jocher pre-commit-ci[bot] commited on
Commit
404b4fe
1 Parent(s): 3a89377

Update restapi.py (#7309)

Browse files

* Update restapi.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update restapi.py

* Update restapi.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update restapi.py

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

Files changed (1) hide show
  1. utils/flask_rest_api/restapi.py +8 -4
utils/flask_rest_api/restapi.py CHANGED
@@ -21,12 +21,16 @@ def predict():
21
  return
22
 
23
  if request.files.get("image"):
24
- image_file = request.files["image"]
25
- image_bytes = image_file.read()
 
26
 
27
- img = Image.open(io.BytesIO(image_bytes))
 
 
 
28
 
29
- results = model(img, size=640) # reduce size=320 for faster inference
30
  return results.pandas().xyxy[0].to_json(orient="records")
31
 
32
 
 
21
  return
22
 
23
  if request.files.get("image"):
24
+ # Method 1
25
+ # with request.files["image"] as f:
26
+ # im = Image.open(io.BytesIO(f.read()))
27
 
28
+ # Method 2
29
+ im_file = request.files["image"]
30
+ im_bytes = im_file.read()
31
+ im = Image.open(io.BytesIO(im_bytes))
32
 
33
+ results = model(im, size=640) # reduce size=320 for faster inference
34
  return results.pandas().xyxy[0].to_json(orient="records")
35
 
36