Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,17 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
# Initialize the object detection pipeline with Microsoft's table transformer model
|
| 5 |
pipe = pipeline("object-detection", model="microsoft/table-transformer-detection")
|
| 6 |
|
| 7 |
-
# Define the function to detect objects in an image
|
| 8 |
def detect_objects(image):
|
| 9 |
result = pipe(image)
|
| 10 |
return [{"label": item["label"], "score": item["score"], "box": item["box"]} for item in result]
|
| 11 |
|
| 12 |
-
# Set up the Gradio interface
|
| 13 |
app = gr.Interface(
|
| 14 |
-
fn=detect_objects,
|
| 15 |
-
inputs=gr.Image(type="filepath"),
|
| 16 |
-
outputs=gr.JSON(),
|
| 17 |
-
title="Object Detection",
|
| 18 |
description="Upload an image to detect objects using Microsoft's Table Transformer model."
|
| 19 |
)
|
| 20 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
|
|
|
| 4 |
pipe = pipeline("object-detection", model="microsoft/table-transformer-detection")
|
| 5 |
|
|
|
|
| 6 |
def detect_objects(image):
|
| 7 |
result = pipe(image)
|
| 8 |
return [{"label": item["label"], "score": item["score"], "box": item["box"]} for item in result]
|
| 9 |
|
|
|
|
| 10 |
app = gr.Interface(
|
| 11 |
+
fn=detect_objects,
|
| 12 |
+
inputs=gr.Image(type="filepath"),
|
| 13 |
+
outputs=gr.JSON(),
|
| 14 |
+
title="Object Detection",
|
| 15 |
description="Upload an image to detect objects using Microsoft's Table Transformer model."
|
| 16 |
)
|
| 17 |
|