Shangkhonil commited on
Commit
963e404
·
verified ·
1 Parent(s): 4ceec67

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -4
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 the microsoft/table-transformer-detection 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
- # Format the result to show detected objects and their scores
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(