angtrim commited on
Commit
6eb8bc3
β€’
1 Parent(s): 5fadb62

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -19
app.py CHANGED
@@ -17,9 +17,9 @@ from src.pix2pix_turbo import Pix2Pix_Turbo
17
 
18
  model = Pix2Pix_Turbo("sketch_to_image_stochastic")
19
 
20
- ITEMS_NAMES = [ "Lamp","Bag","Sofa","Chair","Car","Motorbike","Building"]
21
  MAX_SEED = np.iinfo(np.int32).max
22
- DEFAULT_ITEM_NAME = "Lamp"
23
 
24
 
25
  def pil_image_to_data_uri(img, format='PNG'):
@@ -56,7 +56,7 @@ def update_canvas(use_line, use_eraser):
56
  _color = "#ffffff"
57
  brush_size = 20
58
  if use_line:
59
- _color = "#000011"
60
  brush_size = 4
61
  return gr.update(brush_radius=brush_size, brush_color=_color, interactive=True)
62
 
@@ -96,18 +96,6 @@ async () => {
96
  return false
97
  }
98
 
99
- globalThis.UNDO_SKETCH_FUNCTION = () => {
100
- console.log("undo sketch function")
101
- var button_undo = document.querySelector('#input_image > div.image-container.svelte-p3y7hu > div.svelte-s6ybro > button:nth-child(1)');
102
- // Create a new 'click' event
103
- var event = new MouseEvent('click', {
104
- 'view': window,
105
- 'bubbles': true,
106
- 'cancelable': true
107
- });
108
- button_undo.dispatchEvent(event);
109
- }
110
-
111
  globalThis.DELETE_SKETCH_FUNCTION = () => {
112
  console.log("delete sketch function")
113
  var button_del = document.querySelector('#input_image > div.image-container.svelte-p3y7hu > div.svelte-s6ybro > button:nth-child(2)');
@@ -178,7 +166,6 @@ with gr.Blocks(css="style.css") as demo:
178
  eraser = gr.Checkbox(label="eraser", value=False, elem_id="cb-eraser")
179
  with gr.Row(elem_id="main_row"):
180
  with gr.Column(elem_id="column_input"):
181
- gr.Markdown("## INPUT", elem_id="input_header")
182
  image = gr.Image(
183
  source="canvas", tool="color-sketch", type="pil", image_mode="L",
184
  invert_colors=True, shape=(512, 512), brush_radius=4, height=440, width=440,
@@ -189,16 +176,14 @@ with gr.Blocks(css="style.css") as demo:
189
  <div class="button-row">
190
  <div id="my-div-pencil" class="pad2"> <button id="my-toggle-pencil" onclick="return togglePencil(this)"></button> </div>
191
  <div id="my-div-eraser" class="pad2"> <button id="my-toggle-eraser" onclick="return toggleEraser(this)"></button> </div>
192
- <div class="pad2"> <button id="my-button-undo" onclick="return UNDO_SKETCH_FUNCTION(this)"></button> </div>
193
  <div class="pad2"> <button id="my-button-clear" onclick="return DELETE_SKETCH_FUNCTION(this)"></button> </div>
194
  </div>
195
  """)
196
  with gr.Row():
197
- item = gr.Dropdown(label="Item", choices=ITEMS_NAMES, value=DEFAULT_ITEM_NAME, scale=1)
198
 
199
 
200
  with gr.Column(elem_id="column_output"):
201
- gr.Markdown("## OUTPUT", elem_id="output_header")
202
  result = gr.Image(label="Result", height=440, width=440, elem_id="output_image", show_label=False, show_download_button=True)
203
  download_output = gr.Button("Download output", elem_id="download_output")
204
 
 
17
 
18
  model = Pix2Pix_Turbo("sketch_to_image_stochastic")
19
 
20
+ ITEMS_NAMES = [ "πŸ’‘ Lamp","πŸ‘œ Bag","πŸ›‹οΈ Sofa","πŸͺ‘ Chair","🏎️ Car","🏍️ Motorbike","🏠 Building", "⌚ Watch"]
21
  MAX_SEED = np.iinfo(np.int32).max
22
+ DEFAULT_ITEM_NAME = "πŸ’‘ Lamp"
23
 
24
 
25
  def pil_image_to_data_uri(img, format='PNG'):
 
56
  _color = "#ffffff"
57
  brush_size = 20
58
  if use_line:
59
+ _color = "#000000"
60
  brush_size = 4
61
  return gr.update(brush_radius=brush_size, brush_color=_color, interactive=True)
62
 
 
96
  return false
97
  }
98
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  globalThis.DELETE_SKETCH_FUNCTION = () => {
100
  console.log("delete sketch function")
101
  var button_del = document.querySelector('#input_image > div.image-container.svelte-p3y7hu > div.svelte-s6ybro > button:nth-child(2)');
 
166
  eraser = gr.Checkbox(label="eraser", value=False, elem_id="cb-eraser")
167
  with gr.Row(elem_id="main_row"):
168
  with gr.Column(elem_id="column_input"):
 
169
  image = gr.Image(
170
  source="canvas", tool="color-sketch", type="pil", image_mode="L",
171
  invert_colors=True, shape=(512, 512), brush_radius=4, height=440, width=440,
 
176
  <div class="button-row">
177
  <div id="my-div-pencil" class="pad2"> <button id="my-toggle-pencil" onclick="return togglePencil(this)"></button> </div>
178
  <div id="my-div-eraser" class="pad2"> <button id="my-toggle-eraser" onclick="return toggleEraser(this)"></button> </div>
 
179
  <div class="pad2"> <button id="my-button-clear" onclick="return DELETE_SKETCH_FUNCTION(this)"></button> </div>
180
  </div>
181
  """)
182
  with gr.Row():
183
+ item = gr.Dropdown(label="What do you want to design? πŸ§‘β€πŸŽ¨ ", choices=ITEMS_NAMES, value=DEFAULT_ITEM_NAME, scale=1)
184
 
185
 
186
  with gr.Column(elem_id="column_output"):
 
187
  result = gr.Image(label="Result", height=440, width=440, elem_id="output_image", show_label=False, show_download_button=True)
188
  download_output = gr.Button("Download output", elem_id="download_output")
189