File size: 2,462 Bytes
8cc50cf
6cd9e92
934e326
 
8cc50cf
0152b73
758f1bb
934e326
758f1bb
 
 
 
0152b73
758f1bb
 
 
 
0152b73
8cc50cf
758f1bb
 
 
 
 
322d628
758f1bb
 
 
ccfae83
758f1bb
ccfae83
758f1bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0358eb0
758f1bb
 
0152b73
758f1bb
 
 
 
 
 
 
 
 
 
0152b73
758f1bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8cc50cf
 
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import gradio as gr
from ultralytics import YOLO
# Import YOLOv9
import yolov9

# Define function to perform prediction with YOLO model
def predict_image(image, model_path, image_size, conf_threshold, iou_threshold):

    # Load YOLO model
    model = YOLO(model_path)
    
    # Perform inference with YOLO model
    results = model.predict(image, size=image_size, conf=conf_threshold, iou=iou_threshold)
    
    # Render the output
    output_image = results.render()
    
    return output_image

# Define Gradio interface
def app():
    with gr.Blocks():
        with gr.Row():
            with gr.Column():
                img_path = gr.Image(type="filepath", label="Image")
                model_path = gr.Dropdown(
                    label="Model",
                    choices=[
                        "yolov9c-seg.pt",                                                                      
                    ],
                    value="yolov9c-seg.pt",
                )
                image_size = gr.Slider(
                    label="Image Size",
                    minimum=320,
                    maximum=1280,
                    step=32,
                    value=640,
                )
                conf_threshold = gr.Slider(
                    label="Confidence Threshold",
                    minimum=0.1,
                    maximum=1.0,
                    step=0.1,
                    value=0.4,
                )
                iou_threshold = gr.Slider(
                    label="IoU Threshold",
                    minimum=0.1,
                    maximum=1.0,
                    step=0.1,
                    value=0.5,
                )
                yolov9_infer = gr.Button("Submit")

            with gr.Column():
                output_image = gr.Image(type="numpy", label="Output")

        yolov9_infer.click(
            fn=predict_image,
            inputs=[
                img_path,
                model_path,
                image_size,
                conf_threshold,
                iou_threshold,
            ],
            outputs=[output_image],
        )   

gradio_app = gr.Blocks()
with gradio_app:
    gr.HTML(
        """
    <h1 style='text-align: center'>
    YOLOv9 Base Model
    </h1>
    """)
    gr.HTML(
        """
        <h3 style='text-align: center'>
        </h3>
        """)
    with gr.Row():
        with gr.Column():
            app()    
    
gradio_app.launch(debug=True)