Update restapi.py (#7309)
* 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>
This commit is contained in:
parent
3a89377c04
commit
404b4fefbe
|
|
@ -21,12 +21,16 @@ def predict():
|
|||
return
|
||||
|
||||
if request.files.get("image"):
|
||||
image_file = request.files["image"]
|
||||
image_bytes = image_file.read()
|
||||
# Method 1
|
||||
# with request.files["image"] as f:
|
||||
# im = Image.open(io.BytesIO(f.read()))
|
||||
|
||||
img = Image.open(io.BytesIO(image_bytes))
|
||||
# Method 2
|
||||
im_file = request.files["image"]
|
||||
im_bytes = im_file.read()
|
||||
im = Image.open(io.BytesIO(im_bytes))
|
||||
|
||||
results = model(img, size=640) # reduce size=320 for faster inference
|
||||
results = model(im, size=640) # reduce size=320 for faster inference
|
||||
return results.pandas().xyxy[0].to_json(orient="records")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue