scooter7 commited on
Commit
fe1642d
·
verified ·
1 Parent(s): 03791e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -18
app.py CHANGED
@@ -175,7 +175,9 @@ color_checkboxes = {}
175
  color_sliders = {}
176
 
177
  # Set up the Gradio interface
178
- # Initialize color checkboxes and sliders before using them
 
 
179
  color_checkboxes = {color: gr.Checkbox(label=f"{color} Selected", value=False) for color in color_attributes}
180
  color_sliders = {color: gr.Slider(label=f"{color} Influence Ratio", minimum=0, maximum=1, step=0.01, value=0) for color in color_attributes}
181
 
@@ -205,7 +207,6 @@ with gr.Blocks() as demo:
205
  inference_steps = gr.Slider(minimum=4, maximum=20, label="Inference Steps", value=4)
206
  randomize_seed = gr.Checkbox(label="Randomize Seed", value=True)
207
 
208
- # Set examples for predefined prompts
209
  gr.Examples(
210
  examples=examples,
211
  inputs=prompt,
@@ -220,22 +221,22 @@ with gr.Blocks() as demo:
220
  outputs=negative_prompt,
221
  )
222
 
223
- # Define the inputs for the generate function using a dictionary for clear mapping
224
- generate_inputs = {
225
- "prompt": prompt,
226
- "negative_prompt": negative_prompt,
227
- "style": style_selection,
228
- "use_negative_prompt": use_negative_prompt,
229
- "seed": seed,
230
- "width": width,
231
- "height": height,
232
- "inference_steps": inference_steps,
233
- "randomize_seed": randomize_seed,
234
- **{f"{color.lower()}_selected": color_checkboxes[color] for color in color_attributes},
235
- **{f"{color.lower()}_ratio": color_sliders[color] for color in color_attributes}
236
- }
237
-
238
- # Connect the UI with the generate function
239
  run_button.click(
240
  fn=generate,
241
  inputs=generate_inputs,
 
175
  color_sliders = {}
176
 
177
  # Set up the Gradio interface
178
+ # Assuming the generate function and other necessary imports and initializations are already defined
179
+
180
+ # Initialize dynamic UI components for color influences
181
  color_checkboxes = {color: gr.Checkbox(label=f"{color} Selected", value=False) for color in color_attributes}
182
  color_sliders = {color: gr.Slider(label=f"{color} Influence Ratio", minimum=0, maximum=1, step=0.01, value=0) for color in color_attributes}
183
 
 
207
  inference_steps = gr.Slider(minimum=4, maximum=20, label="Inference Steps", value=4)
208
  randomize_seed = gr.Checkbox(label="Randomize Seed", value=True)
209
 
 
210
  gr.Examples(
211
  examples=examples,
212
  inputs=prompt,
 
221
  outputs=negative_prompt,
222
  )
223
 
224
+ # List of inputs for the generate function
225
+ generate_inputs = [
226
+ prompt,
227
+ negative_prompt,
228
+ style_selection,
229
+ use_negative_prompt,
230
+ seed,
231
+ width,
232
+ height,
233
+ inference_steps,
234
+ randomize_seed,
235
+ *[color_checkboxes[color] for color in color_attributes],
236
+ *[color_sliders[color] for color in color_attributes]
237
+ ]
238
+
239
+ # Connect the UI with the generate function using the run_button click
240
  run_button.click(
241
  fn=generate,
242
  inputs=generate_inputs,