Maruf commited on
Commit
ef46d86
·
1 Parent(s): ab14be8
Files changed (2) hide show
  1. app.py +19 -4
  2. requirements.txt +4 -0
app.py CHANGED
@@ -1,7 +1,22 @@
1
  import gradio as gr
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import torch
3
+ from PIL import Image
4
 
5
+ # Load a pretrained model (YOLOv5 for example)
6
+ model = torch.hub.load("ultralytics/yolov5", "yolov5s", pretrained=True)
7
 
8
+ def detect_objects(image):
9
+ results = model(image)
10
+ detections = results.pandas().xyxy[0].to_dict(orient="records")
11
+ return detections # JSON-friendly list of dicts
12
+
13
+ # Gradio interface
14
+ iface = gr.Interface(
15
+ fn=detect_objects,
16
+ inputs=gr.Image(type="pil"),
17
+ outputs=gr.JSON(),
18
+ examples=[]
19
+ )
20
+
21
+ if __name__ == "__main__":
22
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ torch
2
+ pillow
3
+ gradio
4
+ pandas