Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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
|
30 |
results = model(image)
|
31 |
return results.render()[0]
|
32 |
|
33 |
# Create Gradio interfaces for different modes
|
34 |
webcam_interface = gr.Interface(
|
35 |
-
fn=
|
36 |
-
inputs=gr.inputs.Image(source="
|
37 |
outputs="image",
|
38 |
-
title="
|
39 |
)
|
40 |
|
41 |
file_interface = gr.Interface(
|
42 |
-
fn=
|
43 |
-
inputs=gr.inputs.
|
44 |
-
outputs="
|
45 |
-
title="
|
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.
|
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)
|