francescoKrnl commited on
Commit
f6f9541
1 Parent(s): c6dc013

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -23,10 +23,13 @@ DEFAULT_ITEM_NAME = "💡 Lamp"
23
  COLORS = ["blue", "red", "black", "yellow", "green", "pink", "grey"]
24
  DEFAULT_COLOR = "yellow"
25
  def empty_input_image():
26
- return [{ 'background': Image.new("L", (512, 512), 255),
27
  'layers': [Image.new("L", (512, 512), 255),Image.new("L", (512, 512), 255)],
28
- 'composite': Image.new("L", (512, 512), 255)}, random.choice(COLORS)]
29
 
 
 
 
30
  def pil_image_to_data_uri(img, format='PNG'):
31
  buffered = BytesIO()
32
  img.save(buffered, format=format)
@@ -204,6 +207,6 @@ with gr.Blocks(css="style.css", head = head) as demo:
204
  item.change(fn=run, inputs=inputs, outputs=outputs)
205
  color.change(fn=run, inputs=inputs, outputs=outputs)
206
  image.change(fn=run, inputs=inputs, outputs=outputs, trigger_mode="always_last")
207
- image.clear(fn=empty_input_image, outputs=[image , color])
208
  if __name__ == "__main__":
209
  demo.queue().launch(debug=True, allowed_paths=["."])
 
23
  COLORS = ["blue", "red", "black", "yellow", "green", "pink", "grey"]
24
  DEFAULT_COLOR = "yellow"
25
  def empty_input_image():
26
+ return { 'background': Image.new("L", (512, 512), 255),
27
  'layers': [Image.new("L", (512, 512), 255),Image.new("L", (512, 512), 255)],
28
+ 'composite': Image.new("L", (512, 512), 255)}
29
 
30
+ def clear_sketchbox():
31
+ return [empty_input_image(), random.choice(COLORS)]
32
+
33
  def pil_image_to_data_uri(img, format='PNG'):
34
  buffered = BytesIO()
35
  img.save(buffered, format=format)
 
207
  item.change(fn=run, inputs=inputs, outputs=outputs)
208
  color.change(fn=run, inputs=inputs, outputs=outputs)
209
  image.change(fn=run, inputs=inputs, outputs=outputs, trigger_mode="always_last")
210
+ image.clear(fn=clear_sketchbox, outputs=[image , color])
211
  if __name__ == "__main__":
212
  demo.queue().launch(debug=True, allowed_paths=["."])