Spaces:
Sleeping
Sleeping
unfinity
commited on
Commit
·
ff2b03c
1
Parent(s):
defbc57
case when no person
Browse files- Dockerfile +3 -1
- main.py +3 -5
Dockerfile
CHANGED
@@ -11,4 +11,6 @@ RUN wget https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8l-
|
|
11 |
|
12 |
COPY . .
|
13 |
|
14 |
-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
|
|
11 |
|
12 |
COPY . .
|
13 |
|
14 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
15 |
+
|
16 |
+
# curl -X POST "https://unfinity-yolov8-pose.hf.space/predict-image" -F "[email protected]"
|
main.py
CHANGED
@@ -34,6 +34,9 @@ async def predict_image(file: UploadFile = File(...)):
|
|
34 |
result = model_pose(input_image)[0]
|
35 |
keypoints = utils.get_keypoints(result)
|
36 |
|
|
|
|
|
|
|
37 |
# draw keypoints
|
38 |
output_image = draw_keypoints(input_image, keypoints).convert("RGB")
|
39 |
|
@@ -56,8 +59,3 @@ async def predict_image(file: UploadFile = File(...)):
|
|
56 |
}
|
57 |
|
58 |
return JSONResponse(content=json_data)
|
59 |
-
|
60 |
-
|
61 |
-
# if __name__ == "__main__":
|
62 |
-
# import uvicorn
|
63 |
-
# uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
34 |
result = model_pose(input_image)[0]
|
35 |
keypoints = utils.get_keypoints(result)
|
36 |
|
37 |
+
if not keypoints:
|
38 |
+
return JSONResponse(content={"error": "No person detected"})
|
39 |
+
|
40 |
# draw keypoints
|
41 |
output_image = draw_keypoints(input_image, keypoints).convert("RGB")
|
42 |
|
|
|
59 |
}
|
60 |
|
61 |
return JSONResponse(content=json_data)
|
|
|
|
|
|
|
|
|
|