File size: 1,453 Bytes
c4eb26f
 
 
 
6d83417
c4eb26f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9b4be67
7282a92
9b4be67
7282a92
c4eb26f
 
acba7af
7282a92
 
9b4be67
c4eb26f
d3923d5
acba7af
 
c4eb26f
acba7af
c4eb26f
 
d3923d5
acba7af
 
 
 
c4eb26f
 
 
d3923d5
c4eb26f
 
acba7af
b3818eb
c4eb26f
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# import gradio as gr
# import torch

# model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt')
# Define the face detector function 
# def detect_faces(image):
#    # Loading in yolov5s - you can switch to larger models such as yolov5m or yolov5l, or smaller such as yolov5n
#     results = model(image)

#     return results.render()[0]

# # Create a Gradio interface
# iface = gr.Interface(fn=detect_faces, inputs=gr.Image(source="webcam", tool =None), outputs="image")

# # Launch the interface
# iface.launch(debug=True)

# demo = gr.TabbedInterface([img_demo, vid_demo], ["Image", "Video"])

# if __name__ == "__main__":
#     demo.launch()

import gradio as gr
import torch

model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt')

# Define the face detector function
def detect_image(image):
    results = model(image)
    return results.render()[0]

# Create Gradio interfaces for different modes
img_interface = gr.Interface(
    fn=detect_image,
    inputs=gr.inputs.Image(source="upload"),
    outputs="image",
    title="Image"
)

vid_interface = gr.Interface(
    fn=detect_image,
    inputs=gr.inputs.Video(source="upload"),
    outputs="video",
    title="Videoe"
)

# Create a list of interfaces
interfaces = [img_interface, vid_interface]

# Create the tabbed interface
tabbed_interface = gr.TabbedInterface(interfaces, ["Image", "Video"])

# Launch the tabbed interface
tabbed_interface.launch(debug=True)