francescoKrnl commited on
Commit
ade53d7
1 Parent(s): 1e99c7c
Files changed (1) hide show
  1. app.py +20 -32
app.py CHANGED
@@ -163,44 +163,32 @@ async () => {
163
  """
164
 
165
  with gr.Blocks(css="style.css") as demo:
166
-
167
-
168
-
169
  # these are hidden buttons that are used to trigger the canvas changes
170
  line = gr.Checkbox(label="line", value=False, elem_id="cb-line")
171
  eraser = gr.Checkbox(label="eraser", value=False, elem_id="cb-eraser")
172
- with gr.Row(elem_id="main_row"):
173
- with gr.Column(elem_id="column_input"):
174
- image = gr.Image(
175
- source="canvas", tool="color-sketch", type="pil", image_mode="L",
176
- invert_colors=True, shape=(512, 512), brush_radius=4, height=440, width=440,
177
- brush_color="#000000", interactive=True, show_download_button=False, elem_id="input_image", show_label=False)
178
- download_sketch = gr.Button("Download sketch", scale=1, elem_id="download_sketch")
179
- gr.HTML("""
180
- <div class="button-row">
181
- <div id="my-div-pencil" class="pad2"> <button id="my-toggle-pencil" onclick="return togglePencil(this)"></button> </div>
182
- <div id="my-div-eraser" class="pad2"> <button id="my-toggle-eraser" onclick="return toggleEraser(this)"></button> </div>
183
- <div class="pad2"> <button id="my-button-clear" onclick="return DELETE_SKETCH_FUNCTION(this)"></button> </div>
184
- </div>
185
- """)
186
- with gr.Row():
187
- item = gr.Radio(choices=ITEMS_NAMES, value=DEFAULT_ITEM_NAME)
188
-
189
-
190
- with gr.Column(elem_id="column_output"):
191
- result = gr.Image(label="Result", height=440, width=440, elem_id="output_image", show_label=False, show_download_button=True)
192
- download_output = gr.Button("Download output", elem_id="download_output")
193
- gr.HTML("""
194
- <button id="fullscreen" onclick="document.body.querySelector('#main_row').requestFullscreen();">fullscreen</button>
195
- """)
196
-
197
-
198
- eraser.change(fn=lambda x: gr.update(value=not x), inputs=[eraser], outputs=[line]).then(update_canvas, [line, eraser], [image])
199
- line.change(fn=lambda x: gr.update(value=not x), inputs=[line], outputs=[eraser]).then(update_canvas, [line, eraser], [image])
200
 
201
  demo.load(None,None,None,_js=scripts)
202
  inputs = [image, item]
203
- outputs = [result, download_sketch, download_output]
204
  item.change(fn=run, inputs=inputs, outputs=outputs)
205
  image.change(fn=run, inputs=inputs, outputs=outputs,)
206
 
 
163
  """
164
 
165
  with gr.Blocks(css="style.css") as demo:
 
 
 
166
  # these are hidden buttons that are used to trigger the canvas changes
167
  line = gr.Checkbox(label="line", value=False, elem_id="cb-line")
168
  eraser = gr.Checkbox(label="eraser", value=False, elem_id="cb-eraser")
169
+ with gr.Row(elem_id="header_block"):
170
+ gr.HTML("""<img src="assets/title.png" alt="title" /><img src="assets/logos.png" alt="title" />""")
171
+ with gr.Column(elem_id="main_block"):
172
+ with gr.Row(elem_id="board_row"):
173
+ with gr.Group(elem_id="input_image_container", elem_classes="image_container" ):
174
+ image = gr.Image(
175
+ source="canvas", tool="color-sketch", type="pil", image_mode="L",
176
+ invert_colors=True, shape=(512, 512), brush_radius=4, height=440, width=440,
177
+ brush_color="#000000", interactive=True, show_download_button=False, elem_id="input_image", show_label=False)
178
+ gr.HTML("""<img src="assets/drawCta.png" id="draw_cta" alt="draw here image" />
179
+ <button id="eraser" onclick="return DELETE_SKETCH_FUNCTION(this)">
180
+ <span id="eraser_icon"></span>
181
+ </button>""")
182
+ with gr.Group(elem_id="output_image_container", elem_classes="image_container"):
183
+ result = gr.Image(label="Result", height=440, width=440, elem_id="output_image", show_label=False, show_download_button=True)
184
+ with gr.Row(elem_id="radio_row"):
185
+ item = gr.Radio(choices=ITEMS_NAMES, value=DEFAULT_ITEM_NAME)
186
+ with gr.Row(elem_id="footer_block"):
187
+ gr.HTML("""<button id="fullscreen" onclick="document.body.querySelector('#main_row').requestFullscreen();" class="fullscreen" title="fullscreen"></button>""")
 
 
 
 
 
 
 
 
 
188
 
189
  demo.load(None,None,None,_js=scripts)
190
  inputs = [image, item]
191
+ outputs = [result]
192
  item.change(fn=run, inputs=inputs, outputs=outputs)
193
  image.change(fn=run, inputs=inputs, outputs=outputs,)
194