Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,23 @@
|
|
| 1 |
-
import
|
| 2 |
-
from PIL import Image
|
| 3 |
-
from object_detection import run_od_pipeline
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from PIL import Image
|
| 3 |
+
from object_detection import run_od_pipeline
|
| 4 |
+
|
| 5 |
+
def detect_objects(image: Image.Image) -> Image.Image:
|
| 6 |
+
return run_od_pipeline(image)
|
| 7 |
+
|
| 8 |
+
# Gradio Interface
|
| 9 |
+
title = "🧠 Object Detection using Hugging Face"
|
| 10 |
+
description = "Upload an image and run object detection powered by Hugging Face models."
|
| 11 |
+
|
| 12 |
+
demo = gr.Interface(
|
| 13 |
+
fn=detect_objects,
|
| 14 |
+
inputs=gr.Image(type="pil", label="Upload an image"),
|
| 15 |
+
outputs=gr.Image(type="pil", label="Detected Objects"),
|
| 16 |
+
title=title,
|
| 17 |
+
description=description,
|
| 18 |
+
theme="default",
|
| 19 |
+
allow_flagging="never"
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
if __name__ == "__main__":
|
| 23 |
+
demo.launch()
|