Shangkhonil commited on
Commit
5d5981a
·
verified ·
1 Parent(s): 963e404

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
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, # Function for object detection
15
- inputs=gr.Image(type="filepath"), # Input field to upload an image
16
- outputs=gr.JSON(), # Output field for detected objects (JSON format)
17
- title="Object Detection", # Title of the app
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