rosebe commited on
Commit
acba7af
·
1 Parent(s): 6d83417

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -16
app.py CHANGED
@@ -26,37 +26,30 @@ import torch
26
  model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt')
27
 
28
  # Define the face detector function
29
- def detect_faces(image):
30
  results = model(image)
31
  return results.render()[0]
32
 
33
  # Create Gradio interfaces for different modes
34
  webcam_interface = gr.Interface(
35
- fn=detect_faces,
36
- inputs=gr.inputs.Image(source="webcam", tool=None),
37
  outputs="image",
38
- title="Webcam Mode"
39
  )
40
 
41
  file_interface = gr.Interface(
42
- fn=detect_faces,
43
- inputs=gr.inputs.Image(source="file"),
44
- outputs="image",
45
- title="File Mode"
46
- )
47
-
48
- url_interface = gr.Interface(
49
- fn=detect_faces,
50
- inputs=gr.inputs.Image(source="url"),
51
- outputs="image",
52
- title="URL Mode"
53
  )
54
 
55
  # Create a list of interfaces
56
  interfaces = [webcam_interface, file_interface, url_interface]
57
 
58
  # Create the tabbed interface
59
- tabbed_interface = gr.Interface(interfaces, layout="horizontal")
60
 
61
  # Launch the tabbed interface
62
  tabbed_interface.launch(debug=True)
 
26
  model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt')
27
 
28
  # Define the face detector function
29
+ def detect_image(image):
30
  results = model(image)
31
  return results.render()[0]
32
 
33
  # Create Gradio interfaces for different modes
34
  webcam_interface = gr.Interface(
35
+ fn=detect_image,
36
+ inputs=gr.inputs.Image(source="upload"),
37
  outputs="image",
38
+ title="Image"
39
  )
40
 
41
  file_interface = gr.Interface(
42
+ fn=detect_image,
43
+ inputs=gr.inputs.Video(source="upload"),
44
+ outputs="video",
45
+ title="Videoe"
 
 
 
 
 
 
 
46
  )
47
 
48
  # Create a list of interfaces
49
  interfaces = [webcam_interface, file_interface, url_interface]
50
 
51
  # Create the tabbed interface
52
+ tabbed_interface = gr.TabbedInterface(interfaces, ["Image", "Video"])
53
 
54
  # Launch the tabbed interface
55
  tabbed_interface.launch(debug=True)