123LETSPLAY commited on
Commit
14caa5c
·
verified ·
1 Parent(s): 3a8ea87

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the object detection pipeline
5
+ pipe = pipeline("object-detection", model="facebook/detr-resnet-101")
6
+
7
+ def detect_objects(image):
8
+ results = pipe(image)
9
+ return results
10
+
11
+ # Set up the Gradio interface
12
+ iface = gr.Interface(
13
+ fn=detect_objects,
14
+ inputs=gr.Image(type="numpy", label="Upload Image"),
15
+ outputs=gr.JSON(label="Detection Results"),
16
+ title="Object Detection with DETR",
17
+ description="Upload an image to detect objects using the DETR model."
18
+ )
19
+
20
+ # Launch the app
21
+ if __name__ == "__main__":
22
+ iface.launch()