Update app.py
Browse files
app.py
CHANGED
@@ -30,11 +30,9 @@ def perform(image, task: str="detect"):
|
|
30 |
confs = float(result.boxes.conf) # confidence score of each box
|
31 |
outputs.append({"xywh": xywh, "conf": confs, "name": name})
|
32 |
|
33 |
-
# Add base64 image to outputs
|
34 |
-
outputs.append({"image_base64": f"data:image/jpeg;base64,{img_base64}"})
|
35 |
|
36 |
# return the PIL image (for display) and the outputs with base64
|
37 |
-
return prediction_image, outputs
|
38 |
|
39 |
def load_model(model_name: str = "yolo11n.pt"):
|
40 |
"""Model loading"""
|
@@ -52,7 +50,7 @@ model = load_model()
|
|
52 |
demo = gr.Interface(
|
53 |
fn=perform,
|
54 |
inputs=[gr.Image(type="pil")], # PIL Image format
|
55 |
-
outputs=[gr.Image(type="pil"), gr.JSON()],
|
56 |
title="Object Detection using YOLO",
|
57 |
description="Upload an image and get image with bbox in it",
|
58 |
examples=None # You can add example images here if needed
|
|
|
30 |
confs = float(result.boxes.conf) # confidence score of each box
|
31 |
outputs.append({"xywh": xywh, "conf": confs, "name": name})
|
32 |
|
|
|
|
|
33 |
|
34 |
# return the PIL image (for display) and the outputs with base64
|
35 |
+
return prediction_image, outputs, {"image_base64": f"data:image/jpeg;base64,{img_base64}"}
|
36 |
|
37 |
def load_model(model_name: str = "yolo11n.pt"):
|
38 |
"""Model loading"""
|
|
|
50 |
demo = gr.Interface(
|
51 |
fn=perform,
|
52 |
inputs=[gr.Image(type="pil")], # PIL Image format
|
53 |
+
outputs=[gr.Image(type="pil"), gr.JSON(), gr.JSON()],
|
54 |
title="Object Detection using YOLO",
|
55 |
description="Upload an image and get image with bbox in it",
|
56 |
examples=None # You can add example images here if needed
|