Spaces:
Sleeping

File size: 2,259 Bytes
c70698a
 
fe3bd84
d659ae8
c70698a
fe3bd84
 
c59885b
c70698a
069792d
b1c0038
 
 
b102ebc
c70698a
 
00b71e6
 
f28fcd5
069792d
f28fcd5
 
 
00b71e6
 
 
 
 
 
c70698a
f28fcd5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c70698a
 
 
f28fcd5
 
 
 
 
 
 
 
 
c70698a
 
 
 
f28fcd5
 
 
 
 
 
 
 
 
 
c70698a
 
 
 
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
import gradio as gr
import numpy as np
import os
from utils import process_image, clear_image


model_names = [i.removesuffix('.pt') for i in os.listdir('./models')]
modes = ['Shadow Removal', '1º Segmentation Algorithm', '2º Segmentation Algorithm'] + model_names

initial_mode = modes[0]
if 'Classificator_YOLOv8n_Refined (16 epochs)' in model_names:
    initial_mode = 'Classificator_YOLOv8n_Refined (16 epochs)'


with gr.Blocks() as demo:
    with gr.Column():
        with gr.Row():
            with gr.Column():
                dropdown = gr.Dropdown(
                    choices=modes, value=initial_mode,
                    interactive=True,
                    show_label=False
                )
            with gr.Column():
                pass
            with gr.Column():
                pass
            with gr.Column():
                pass
        with gr.Row():
            input_box = gr.Image(
                label='Input Image',
                elem_id='input_box',
                sources=['upload'],
                type='numpy',
                show_fullscreen_button=True
            )
            output_box = gr.Image(
                label='Output Image',
                elem_id='output_box',
                sources=['upload'],
                type='pil',
                interactive=False,
                show_download_button=True,
                show_fullscreen_button=True,
                show_share_button=False
            )
        with gr.Row():
            with gr.Column():
                with gr.Row():
                    submit_btn = gr.Button(
                        "Submit",
                        elem_id='submit_btn',
                        variant='primary'
                    )
                    clear_btn = gr.Button(
                        "Clear",
                        elem_id='clear_btn'
                    )
            with gr.Column():
                pass

    # button events
    submit_btn.click(
        fn=process_image,
        inputs=[input_box, dropdown],
        outputs=output_box
    )
    clear_btn.click(
        inputs=None,
        outputs=[input_box, output_box],
        fn=lambda: [clear_image(), clear_image()]
    )


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