Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,13 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
# Initialize the object detection pipeline with
|
| 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 |
-
|
| 11 |
-
detections = [{"label": item["label"], "score": item["score"], "box": item["box"]} for item in result]
|
| 12 |
-
return detections
|
| 13 |
|
| 14 |
# Set up the Gradio interface
|
| 15 |
app = gr.Interface(
|
|
|
|
| 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(
|