import gradio as gr def ui(controller): with gr.Blocks() as ui: with gr.Row(): with gr.Column(): sketch=gr.Image(sources = 'upload', label='Model image', type = 'pil') first_prompt = gr.Textbox(label="Prompt", lines=3) first_negative_prompt = gr.Textbox(label="Negative prompt", lines=3, value="sketch, lowres, error, extra digit, fewer digits, cropped, worst quality,low quality, normal quality, jpeg artifacts, blurry") #controlnet_scale = gr.Slider(minimum=0.5, maximum=1.25, value=0.5, step=0.01, label="Contr") improve_sketch = gr.Button(value="Improve Sketch", variant="primary") with gr.Column(): improved_sketch_view = gr.Image(type="pil", label="Improved Sketch") improve_sketch.click(fn=controller.get_first_result, inputs=[sketch, first_prompt, first_negative_prompt], outputs=improved_sketch_view) with gr.Row(): result=gr.Image(type="pil", label="Improved Sketch") second_prompt = gr.Textbox(label="Prompt", lines=3) second_negative_prompt = gr.Textbox(label="Negative prompt", lines=3, value="disfigured, extra digit, fewer digits, cropped, worst quality, low quality") result_button = gr.Button(value="Paint It", variant="primary") result_button.click(fn=controller.get_secnd_result, inputs=[sketch, second_prompt, second_negative_prompt], outputs=result) ui.queue().launch(debug=True)