Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -38,13 +38,16 @@ with gr.Blocks() as demo:
|
|
38 |
|
39 |
with gr.Row():
|
40 |
with gr.Column():
|
41 |
-
|
|
|
42 |
clear_btn = gr.Button("Clear")
|
43 |
generate_btn = gr.Button("Generate Image")
|
44 |
|
45 |
with gr.Column():
|
46 |
-
#
|
47 |
-
|
|
|
|
|
48 |
output_image = gr.Image(label="Generated Image", type="numpy")
|
49 |
|
50 |
# Define the actions for buttons
|
@@ -53,13 +56,6 @@ with gr.Blocks() as demo:
|
|
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)
|
65 |
|
|
|
38 |
|
39 |
with gr.Row():
|
40 |
with gr.Column():
|
41 |
+
# Create a sketchpad for drawing
|
42 |
+
canvas = gr.Sketchpad(label="Draw Here", tool="brush", brush_color="black")
|
43 |
clear_btn = gr.Button("Clear")
|
44 |
generate_btn = gr.Button("Generate Image")
|
45 |
|
46 |
with gr.Column():
|
47 |
+
# Create color buttons for different terrains
|
48 |
+
for color_name, color in color_mapping.items():
|
49 |
+
gr.Button(color_name, variant="primary").click(fn=lambda c=color: canvas.update(brush_color=c), inputs=None, outputs=None)
|
50 |
+
|
51 |
output_image = gr.Image(label="Generated Image", type="numpy")
|
52 |
|
53 |
# Define the actions for buttons
|
|
|
56 |
|
57 |
clear_btn.click(fn=clear_canvas, inputs=None, outputs=canvas)
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
# Click to generate an image
|
60 |
generate_btn.click(fn=predict, inputs=canvas, outputs=output_image)
|
61 |
|