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>
utils/flask_rest_api/restapi.py
CHANGED
@@ -21,12 +21,16 @@ def predict():
|
|
21 |
return
|
22 |
|
23 |
if request.files.get("image"):
|
24 |
-
|
25 |
-
|
|
|
26 |
|
27 |
-
|
|
|
|
|
|
|
28 |
|
29 |
-
results = model(
|
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 |
|