multimodalart HF staff commited on
Commit
a8d52ff
1 Parent(s): f4a8adf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -58,7 +58,7 @@ def process_sketch(image, binary_matrixes):
58
  for n in range(how_many_colors-1):
59
  visibilities[n] = gr.update(visible=True)
60
  colors[n] = colors_fixed[n]
61
- return [gr.update(visible=True), binary_matrixes, *visibilities, *colors]
62
 
63
  def process_generation(binary_matrixes, master_prompt, *prompts):
64
  clipped_prompts = prompts[:len(binary_matrixes)]
@@ -86,11 +86,12 @@ def update_css(aspect):
86
  with gr.Blocks(css=css) as demo:
87
  binary_matrixes = gr.State([])
88
  with gr.Box(elem_id="main-image"):
89
- with gr.Row():
90
- image = gr.Image(interactive=True, tool="color-sketch", source="canvas", type="pil")
91
- with gr.Row():
92
- aspect = gr.Radio(["Square", "Horizontal", "Vertical"], value="Square", label="Aspect Ratio")
93
- button_run = gr.Button("I've finished my sketch",elem_id="main_button")
 
94
 
95
  prompts = []
96
  colors = []
@@ -103,11 +104,11 @@ with gr.Blocks(css=css) as demo:
103
  colors.append(gr.HTML('<div class="color-bg-item" style="background-color: black"></div>'))
104
  prompts.append(gr.Textbox(label="Prompt for this color"))
105
  final_run_btn = gr.Button("Generate!")
106
- gallery = gr.Gallery()
107
 
108
  css_height = gr.HTML("<style>#main-image{width: 512px} .fixed-height{height: 512px !important}</style>")
109
 
110
  aspect.change(update_css, inputs=aspect, outputs=css_height)
111
- button_run.click(process_sketch, inputs=[image, binary_matrixes], outputs=[post_sketch, binary_matrixes, *color_row, *colors])
112
- final_run_btn.click(process_generation, inputs=[binary_matrixes, general_prompt, *prompts], outputs=gallery)
113
  demo.launch()
 
58
  for n in range(how_many_colors-1):
59
  visibilities[n] = gr.update(visible=True)
60
  colors[n] = colors_fixed[n]
61
+ return [gr.update(open=False), gr.update(visible=True), binary_matrixes, *visibilities, *colors]
62
 
63
  def process_generation(binary_matrixes, master_prompt, *prompts):
64
  clipped_prompts = prompts[:len(binary_matrixes)]
 
86
  with gr.Blocks(css=css) as demo:
87
  binary_matrixes = gr.State([])
88
  with gr.Box(elem_id="main-image"):
89
+ with gr.Accordion(open=True, label="Your color sketch") as sketch_accordion:
90
+ with gr.Row():
91
+ image = gr.Image(interactive=True, tool="color-sketch", source="canvas", type="pil")
92
+ with gr.Row():
93
+ aspect = gr.Radio(["Square", "Horizontal", "Vertical"], value="Square", label="Aspect Ratio")
94
+ button_run = gr.Button("I've finished my sketch",elem_id="main_button")
95
 
96
  prompts = []
97
  colors = []
 
104
  colors.append(gr.HTML('<div class="color-bg-item" style="background-color: black"></div>'))
105
  prompts.append(gr.Textbox(label="Prompt for this color"))
106
  final_run_btn = gr.Button("Generate!")
107
+ out_image = gr.Image()
108
 
109
  css_height = gr.HTML("<style>#main-image{width: 512px} .fixed-height{height: 512px !important}</style>")
110
 
111
  aspect.change(update_css, inputs=aspect, outputs=css_height)
112
+ button_run.click(process_sketch, inputs=[image, binary_matrixes], outputs=[sketch_accordion, post_sketch, binary_matrixes, *color_row, *colors])
113
+ final_run_btn.click(process_generation, inputs=[binary_matrixes, general_prompt, *prompts], outputs=out_image)
114
  demo.launch()