Spaces:
Runtime error
Runtime error
Update ui/gradio_ui.py
Browse files- ui/gradio_ui.py +9 -26
ui/gradio_ui.py
CHANGED
|
@@ -3,27 +3,15 @@ from PIL import Image, ImageOps
|
|
| 3 |
import numpy as np
|
| 4 |
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
def get_img_from_sketchpad(img):
|
| 9 |
-
#global SER_SKETCH
|
| 10 |
-
return Image.fromarray(img["composite"]) #ImageOps.invert(Image.fromarray((img["composite"])))#,'L')
|
| 11 |
-
|
| 12 |
-
#def set_ser_sketch(img):
|
| 13 |
-
#global SER_SKETCH
|
| 14 |
-
#SER_SKETCH=img
|
| 15 |
-
|
| 16 |
-
def ui(controller):#get_first_result,get_second_result): #controller):
|
| 17 |
with gr.Blocks() as ui:
|
| 18 |
with gr.Row():
|
| 19 |
with gr.Column():
|
| 20 |
sketch=gr.Sketchpad(sources = 'upload', label='Sketch', type='pil', image_mode="RGB", brush=gr.Brush()) #gr.Image(sources = 'upload', label='Sketch', type = 'pil')
|
| 21 |
-
|
| 22 |
-
|
| 23 |
with gr.Column():
|
| 24 |
-
improved_sketch_view = gr.Image(type="pil", label="Improved Sketch")
|
| 25 |
-
|
| 26 |
-
#with gr.Row():
|
| 27 |
with gr.Column():
|
| 28 |
result=gr.Image(type="pil", label="Colored Image")
|
| 29 |
|
|
@@ -32,8 +20,7 @@ def ui(controller):#get_first_result,get_second_result): #controller):
|
|
| 32 |
with gr.Column():
|
| 33 |
first_prompt = gr.Textbox(label="Prompt to Improve Sketch", lines=3)
|
| 34 |
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")
|
| 35 |
-
firts_prompt_helper = gr.Button(value="Prompt Helper", variant="primary")
|
| 36 |
-
#controlnet_scale = gr.Slider(minimum=0.5, maximum=1.25, value=0.5, step=0.01, label="Contr")
|
| 37 |
improve_sketch = gr.Button(value="Improve Sketch", variant="primary")
|
| 38 |
|
| 39 |
with gr.Column():
|
|
@@ -52,11 +39,9 @@ def ui(controller):#get_first_result,get_second_result): #controller):
|
|
| 52 |
inputs=[sketch, first_prompt, second_prompt],
|
| 53 |
label='Examples. Be concrete as much as possible.')
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
improve_sketch.click(fn=controller.get_first_result,
|
| 59 |
-
inputs=[sketch, first_prompt, first_negative_prompt],
|
| 60 |
outputs=improved_sketch_view)
|
| 61 |
|
| 62 |
result_button.click(fn=controller.get_second_result,
|
|
@@ -64,13 +49,11 @@ def ui(controller):#get_first_result,get_second_result): #controller):
|
|
| 64 |
outputs=result)
|
| 65 |
|
| 66 |
firts_prompt_helper.click(fn=controller.get_help_w_prompt,
|
| 67 |
-
inputs=[sketch],
|
| 68 |
outputs=first_prompt)
|
| 69 |
|
| 70 |
second_prompt_helper.click(fn=controller.get_help_w_prompt,
|
| 71 |
inputs=[improved_sketch_view],
|
| 72 |
-
outputs=second_prompt)
|
| 73 |
-
|
| 74 |
-
|
| 75 |
|
| 76 |
ui.queue().launch(debug=True)
|
|
|
|
| 3 |
import numpy as np
|
| 4 |
|
| 5 |
|
| 6 |
+
def ui(controller):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
with gr.Blocks() as ui:
|
| 8 |
with gr.Row():
|
| 9 |
with gr.Column():
|
| 10 |
sketch=gr.Sketchpad(sources = 'upload', label='Sketch', type='pil', image_mode="RGB", brush=gr.Brush()) #gr.Image(sources = 'upload', label='Sketch', type = 'pil')
|
| 11 |
+
|
|
|
|
| 12 |
with gr.Column():
|
| 13 |
+
improved_sketch_view = gr.Image(type="pil", label="Improved Sketch")
|
| 14 |
+
|
|
|
|
| 15 |
with gr.Column():
|
| 16 |
result=gr.Image(type="pil", label="Colored Image")
|
| 17 |
|
|
|
|
| 20 |
with gr.Column():
|
| 21 |
first_prompt = gr.Textbox(label="Prompt to Improve Sketch", lines=3)
|
| 22 |
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")
|
| 23 |
+
firts_prompt_helper = gr.Button(value="Prompt Helper", variant="primary")
|
|
|
|
| 24 |
improve_sketch = gr.Button(value="Improve Sketch", variant="primary")
|
| 25 |
|
| 26 |
with gr.Column():
|
|
|
|
| 39 |
inputs=[sketch, first_prompt, second_prompt],
|
| 40 |
label='Examples. Be concrete as much as possible.')
|
| 41 |
|
| 42 |
+
|
|
|
|
|
|
|
| 43 |
improve_sketch.click(fn=controller.get_first_result,
|
| 44 |
+
inputs=[sketch, first_prompt, first_negative_prompt],
|
| 45 |
outputs=improved_sketch_view)
|
| 46 |
|
| 47 |
result_button.click(fn=controller.get_second_result,
|
|
|
|
| 49 |
outputs=result)
|
| 50 |
|
| 51 |
firts_prompt_helper.click(fn=controller.get_help_w_prompt,
|
| 52 |
+
inputs=[sketch],
|
| 53 |
outputs=first_prompt)
|
| 54 |
|
| 55 |
second_prompt_helper.click(fn=controller.get_help_w_prompt,
|
| 56 |
inputs=[improved_sketch_view],
|
| 57 |
+
outputs=second_prompt)
|
|
|
|
|
|
|
| 58 |
|
| 59 |
ui.queue().launch(debug=True)
|