Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -54,4 +54,20 @@ demo = gr.Interface(
|
|
54 |
]
|
55 |
)
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
demo.launch()
|
|
|
54 |
]
|
55 |
)
|
56 |
|
57 |
+
def get_pipeline_prediction(pil_image):
|
58 |
+
try:
|
59 |
+
# Run the object detection pipeline
|
60 |
+
pipeline_output = od_pipe(pil_image)
|
61 |
+
|
62 |
+
# Draw the detection results on the image
|
63 |
+
processed_image = draw_detections(pil_image, pipeline_output)
|
64 |
+
|
65 |
+
# Provide both the image and the JSON detection results
|
66 |
+
return processed_image, pipeline_output
|
67 |
+
except Exception as e:
|
68 |
+
# Log the error
|
69 |
+
print(f"An error occurred: {str(e)}")
|
70 |
+
# Return a message and an empty JSON
|
71 |
+
return pil_image, {"error": str(e)}
|
72 |
+
|
73 |
demo.launch()
|