File size: 1,779 Bytes
17725c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from backend import SengaFiller
def init(sengafiller:SengaFiller):
    from gradio import Blocks, Markdown, Image, Row, Button, Box

    with Blocks() as app:

        # Prepare Components
        Markdown(
            """# SengaFiller
        Connects the lines you draw so that you can fill your drawing correctly.
        """
        )
        with Box().style(rounded=True, margin=True):
            input_image = Image(label="input",image_mode="L",type="pil")
            with Box().style(border=False):
                with Row().style(equal_height=True):
                    submit_button = Button("RUN", variant="primary").style(
                        full_width=True, rounded=(True, False, False, True)
                    )
                    clear_button = Button("CLEAR").style(
                        full_width=True, rounded=(False, True, True, False)
                    )
            output_image = Image(label="output")
        Markdown(
            """
        ### Credit
        The model `model1.h5` is licensed under a CC-BY-NC-SA 4.0 international license, created by [hepesu](https://github.com/hepesu) and available on [Release Page of LineCloser Repo](https://github.com/hepesu/LineCloser/releases)
        """
        )

        # Event Handlers
        def on_submit_button_click(input_image_data):
            return sengafiller.run(input_image_data)
        def on_clear_button_click():
            return None,None

        # Connect Components
        submit_button.click(
            fn=on_submit_button_click, inputs=[input_image], outputs=[output_image]
        )
        clear_button.click(
            fn=on_clear_button_click,inputs=[],outputs=[input_image,output_image]
        )
    app.launch()


if __name__ == "__main__":
    init()