Commit
·
3248690
1
Parent(s):
0479306
28. Sept. 2024, 14:22
Browse files
app.py
CHANGED
|
@@ -250,6 +250,9 @@ def inpaint(image, invert):
|
|
| 250 |
|
| 251 |
|
| 252 |
# MARK: GRADIO UI
|
|
|
|
|
|
|
|
|
|
| 253 |
with gr.Blocks(theme=theme, css=custom_css, js=custom_js, head=custom_head, title=title) as demo:
|
| 254 |
with gr.Row(elem_classes="row-header"):
|
| 255 |
gr.Markdown(
|
|
@@ -268,7 +271,7 @@ with gr.Blocks(theme=theme, css=custom_css, js=custom_js, head=custom_head, titl
|
|
| 268 |
input_image = gr.Image(label="Input Image", type="numpy", height=512)
|
| 269 |
|
| 270 |
## TAB LINEART
|
| 271 |
-
with gr.Tab("Lineart"):
|
| 272 |
with gr.Row():
|
| 273 |
gr.Markdown("<p>Check Invert to use with Mochi Diffusion. Inverted image can also be created here for use with ControlNet Scribble.")
|
| 274 |
with gr.Row():
|
|
@@ -280,9 +283,14 @@ with gr.Blocks(theme=theme, css=custom_css, js=custom_js, head=custom_head, titl
|
|
| 280 |
resolution = gr.Slider(label="Auflösung", minimum=256, maximum=1024, value=512, step=64)
|
| 281 |
run_btn_lineart = gr.Button("Run")
|
| 282 |
invert.change(lambda x: {"info": invert_toggle_info[0] if x else invert_toggle_info[1], "__type__": "update"}, inputs=checkbox, outputs=checkbox)
|
| 283 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
## TAB Canny
|
| 285 |
-
with gr.Tab("Canny Edge"):
|
| 286 |
with gr.Row():
|
| 287 |
gr.Markdown("## Canny Edge")
|
| 288 |
with gr.Row():
|
|
@@ -305,7 +313,7 @@ with gr.Blocks(theme=theme, css=custom_css, js=custom_js, head=custom_head, titl
|
|
| 305 |
)
|
| 306 |
|
| 307 |
# MARK: Button Runs
|
| 308 |
-
run_btn_lineart.click(fn=lineart, inputs=[input_image, resolution, preprocessor_name, invert
|
| 309 |
run_btn_canny.click(fn=canny, inputs=[input_image, resolution, low_threshold, high_threshold, gallery], outputs=[gallery])
|
| 310 |
|
| 311 |
|
|
|
|
| 250 |
|
| 251 |
|
| 252 |
# MARK: GRADIO UI
|
| 253 |
+
|
| 254 |
+
input_options = []
|
| 255 |
+
|
| 256 |
with gr.Blocks(theme=theme, css=custom_css, js=custom_js, head=custom_head, title=title) as demo:
|
| 257 |
with gr.Row(elem_classes="row-header"):
|
| 258 |
gr.Markdown(
|
|
|
|
| 271 |
input_image = gr.Image(label="Input Image", type="numpy", height=512)
|
| 272 |
|
| 273 |
## TAB LINEART
|
| 274 |
+
with gr.Tab("Lineart") as tab_lineart:
|
| 275 |
with gr.Row():
|
| 276 |
gr.Markdown("<p>Check Invert to use with Mochi Diffusion. Inverted image can also be created here for use with ControlNet Scribble.")
|
| 277 |
with gr.Row():
|
|
|
|
| 283 |
resolution = gr.Slider(label="Auflösung", minimum=256, maximum=1024, value=512, step=64)
|
| 284 |
run_btn_lineart = gr.Button("Run")
|
| 285 |
invert.change(lambda x: {"info": invert_toggle_info[0] if x else invert_toggle_info[1], "__type__": "update"}, inputs=checkbox, outputs=checkbox)
|
| 286 |
+
def set_inputs(tab_name):
|
| 287 |
+
global input_options
|
| 288 |
+
if tab_name == "Lineart":
|
| 289 |
+
input_options = [preprocessor_name, invert]
|
| 290 |
+
return {"preprocessor_name": preprocessor_name, "invert": invert, "resolution": resolution}
|
| 291 |
+
tab_lineart.select(fn=set_inputs(), inputs=tab_lineart, outputs=None)
|
| 292 |
## TAB Canny
|
| 293 |
+
with gr.Tab("Canny Edge") as tab_canny:
|
| 294 |
with gr.Row():
|
| 295 |
gr.Markdown("## Canny Edge")
|
| 296 |
with gr.Row():
|
|
|
|
| 313 |
)
|
| 314 |
|
| 315 |
# MARK: Button Runs
|
| 316 |
+
run_btn_lineart.click(fn=lineart, inputs=[input_image, resolution, gallery, preprocessor_name, invert], outputs=[gallery])
|
| 317 |
run_btn_canny.click(fn=canny, inputs=[input_image, resolution, low_threshold, high_threshold, gallery], outputs=[gallery])
|
| 318 |
|
| 319 |
|