glenn-jocher
commited on
Commit
•
2c7c075
1
Parent(s):
57812df
Update restapi.py (#2967)
Browse files
utils/flask_rest_api/restapi.py
CHANGED
@@ -24,15 +24,14 @@ def predict():
|
|
24 |
|
25 |
img = Image.open(io.BytesIO(image_bytes))
|
26 |
|
27 |
-
results = model(img, size=640)
|
28 |
-
|
29 |
-
return data
|
30 |
|
31 |
|
32 |
if __name__ == "__main__":
|
33 |
-
parser = argparse.ArgumentParser(description="Flask
|
34 |
parser.add_argument("--port", default=5000, type=int, help="port number")
|
35 |
args = parser.parse_args()
|
36 |
|
37 |
-
model = torch.hub.load("ultralytics/yolov5", "yolov5s", force_reload=True)
|
38 |
app.run(host="0.0.0.0", port=args.port) # debug=True causes Restarting with stat
|
|
|
24 |
|
25 |
img = Image.open(io.BytesIO(image_bytes))
|
26 |
|
27 |
+
results = model(img, size=640) # reduce size=320 for faster inference
|
28 |
+
return results.pandas().xyxy[0].to_json(orient="records")
|
|
|
29 |
|
30 |
|
31 |
if __name__ == "__main__":
|
32 |
+
parser = argparse.ArgumentParser(description="Flask API exposing YOLOv5 model")
|
33 |
parser.add_argument("--port", default=5000, type=int, help="port number")
|
34 |
args = parser.parse_args()
|
35 |
|
36 |
+
model = torch.hub.load("ultralytics/yolov5", "yolov5s", force_reload=True) # force_reload to recache
|
37 |
app.run(host="0.0.0.0", port=args.port) # debug=True causes Restarting with stat
|