rosebe commited on
Commit
9b4be67
·
1 Parent(s): da8e3ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -13
app.py CHANGED
@@ -1,23 +1,36 @@
1
- import gradio as gr
2
- import torch
3
-
4
- def snap(video):
5
- return [video]
6
 
7
- model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt')
8
- # Define the face detector function
9
  # def detect_faces(image):
10
  # # Loading in yolov5s - you can switch to larger models such as yolov5m or yolov5l, or smaller such as yolov5n
11
  # results = model(image)
12
 
13
  # return results.render()[0]
14
 
15
- # Create a Gradio interface
16
- iface = gr.Interface(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  snap,
18
- [gr.Video(source="webcam")],
19
- ["video"],
20
  )
21
 
22
- # Launch the interface
23
- iface.launch(debug=True)
 
1
+ # import gradio as gr
2
+ # import torch
 
 
 
3
 
4
+ # model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt')
5
+ # # Define the face detector function
6
  # def detect_faces(image):
7
  # # Loading in yolov5s - you can switch to larger models such as yolov5m or yolov5l, or smaller such as yolov5n
8
  # results = model(image)
9
 
10
  # return results.render()[0]
11
 
12
+ # # Create a Gradio interface
13
+ # iface = gr.Interface(fn=detect_faces, inputs="image", outputs="image")
14
+
15
+ # # Launch the interface
16
+ # iface.launch(debug=True)
17
+
18
+ import gradio as gr
19
+
20
+ def snap(video):
21
+ results = model(image)
22
+ return [results.render()[0], video]
23
+
24
+ # def detect_faces(image):
25
+ # # # Loading in yolov5s - you can switch to larger models such as yolov5m or yolov5l, or smaller such as yolov5n
26
+ # results = model(image)
27
+ # return results.render()[0]
28
+
29
+ demo = gr.Interface(
30
  snap,
31
+ inputs = gr.Video(source="webcam"),
32
+ outputs = "image",
33
  )
34
 
35
+ if __name__ == "__main__":
36
+ demo.launch()