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()