Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,8 +8,7 @@ def random_hex():
|
|
8 |
|
9 |
# Generate initial 5-color palette
|
10 |
def generate_palette(locked_colors):
|
11 |
-
|
12 |
-
return new_palette
|
13 |
|
14 |
# Create color swatches
|
15 |
def display_palette(colors):
|
@@ -25,16 +24,16 @@ initial_palette = generate_palette([None] * 5)
|
|
25 |
|
26 |
# Gradio UI
|
27 |
def update_palette(*locks):
|
28 |
-
locks = [color if color else None for color in locks]
|
29 |
new_palette = generate_palette(locks)
|
30 |
return display_palette(new_palette) + tuple(new_palette)
|
31 |
|
32 |
with gr.Blocks(theme=gr.themes.Soft()) as iface:
|
33 |
gr.Markdown("# π¨ AI-Powered Color Palette Generator")
|
34 |
-
gr.Markdown("Click to lock
|
35 |
|
36 |
with gr.Row():
|
37 |
-
lock_inputs = [gr.
|
38 |
|
39 |
palette_output = gr.Plot(label="Generated Palette")
|
40 |
generate_button = gr.Button("Regenerate Palette π¨")
|
@@ -46,4 +45,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
|
|
46 |
|
47 |
# Launch the app
|
48 |
if __name__ == "__main__":
|
49 |
-
iface.launch()
|
|
|
8 |
|
9 |
# Generate initial 5-color palette
|
10 |
def generate_palette(locked_colors):
|
11 |
+
return [random_hex() if locked is None else locked for locked in locked_colors]
|
|
|
12 |
|
13 |
# Create color swatches
|
14 |
def display_palette(colors):
|
|
|
24 |
|
25 |
# Gradio UI
|
26 |
def update_palette(*locks):
|
27 |
+
locks = [color if color and color != "None" else None for color in locks]
|
28 |
new_palette = generate_palette(locks)
|
29 |
return display_palette(new_palette) + tuple(new_palette)
|
30 |
|
31 |
with gr.Blocks(theme=gr.themes.Soft()) as iface:
|
32 |
gr.Markdown("# π¨ AI-Powered Color Palette Generator")
|
33 |
+
gr.Markdown("Click on a color to lock it. Generate fresh palettes for unlocked colors!")
|
34 |
|
35 |
with gr.Row():
|
36 |
+
lock_inputs = [gr.ColorPicker(label=f"Color {i+1}", value=initial_palette[i]) for i in range(5)]
|
37 |
|
38 |
palette_output = gr.Plot(label="Generated Palette")
|
39 |
generate_button = gr.Button("Regenerate Palette π¨")
|
|
|
45 |
|
46 |
# Launch the app
|
47 |
if __name__ == "__main__":
|
48 |
+
iface.launch()
|