szili2011 commited on
Commit
fa2d0fb
·
verified ·
1 Parent(s): 70720ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -38,7 +38,7 @@ with gr.Blocks() as demo:
38
 
39
  with gr.Row():
40
  with gr.Column():
41
- canvas = gr.Sketchpad(label="Draw Here", tool="brush")
42
  clear_btn = gr.Button("Clear")
43
  generate_btn = gr.Button("Generate Image")
44
 
@@ -52,9 +52,13 @@ with gr.Blocks() as demo:
52
  return np.zeros((400, 400, 3), dtype=np.uint8)
53
 
54
  clear_btn.click(fn=clear_canvas, inputs=None, outputs=canvas)
55
-
 
 
 
 
56
  for color_name, color in color_mapping.items():
57
- color_btns[color_name].click(fn=lambda color=color: canvas.update(value=color), inputs=None, outputs=None)
58
 
59
  # Click to generate an image
60
  generate_btn.click(fn=predict, inputs=canvas, outputs=output_image)
 
38
 
39
  with gr.Row():
40
  with gr.Column():
41
+ canvas = gr.Sketchpad(label="Draw Here", shape=(400, 400)) # Updated: Removed 'tool' argument
42
  clear_btn = gr.Button("Clear")
43
  generate_btn = gr.Button("Generate Image")
44
 
 
52
  return np.zeros((400, 400, 3), dtype=np.uint8)
53
 
54
  clear_btn.click(fn=clear_canvas, inputs=None, outputs=canvas)
55
+
56
+ # Assign color to brush for each color button
57
+ def change_color(color):
58
+ return color
59
+
60
  for color_name, color in color_mapping.items():
61
+ color_btns[color_name].click(fn=change_color, inputs=None, outputs=canvas)
62
 
63
  # Click to generate an image
64
  generate_btn.click(fn=predict, inputs=canvas, outputs=output_image)