RohitGandikota commited on
Commit
bf45264
·
verified ·
1 Parent(s): dcf8b48

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -15
app.py CHANGED
@@ -290,13 +290,15 @@ SliderSpace allows you to explore diffusion model knowledge's concept directions
290
  - Ensure your prompt clearly relates to the selected concept
291
  - Try multiple directions if you're not seeing the effect you want
292
  """
293
-
294
- # Define a function to toggle instructions
295
- def toggle_instructions(state):
296
- if state:
297
- return simple_instructions, "Show Detailed Instructions", False
 
 
298
  else:
299
- return detailed_instructions, "Show Simple Instructions", True
300
 
301
  with gr.Blocks(css=css) as demo:
302
  with gr.Column(elem_id="col-container"):
@@ -308,15 +310,16 @@ with gr.Blocks(css=css) as demo:
308
  """)
309
 
310
  with gr.Row():
311
- instructions_md = gr.Markdown(simple_instructions)
312
- toggle_btn = gr.Button("Show Detailed Instructions")
313
-
314
- # Toggle button to switch between simple and detailed instructions
315
- toggle_btn.click(
316
- fn=toggle_instructions,
317
- inputs=[gr.State(False)], # Initial state is False
318
- outputs=[instructions_md, toggle_btn, gr.State()] # Return the new state
319
- )
 
320
 
321
  with gr.Row():
322
  prompt = gr.Text(
 
290
  - Ensure your prompt clearly relates to the selected concept
291
  - Try multiple directions if you're not seeing the effect you want
292
  """
293
+ # Define a function to toggle instructions that correctly handles both states
294
+ def toggle_instructions(is_detailed):
295
+ # Toggle the state
296
+ is_detailed = not is_detailed
297
+
298
+ if is_detailed:
299
+ return detailed_instructions, "Show Simple Instructions", is_detailed
300
  else:
301
+ return simple_instructions, "Show Detailed Instructions", is_detailed
302
 
303
  with gr.Blocks(css=css) as demo:
304
  with gr.Column(elem_id="col-container"):
 
310
  """)
311
 
312
  with gr.Row():
313
+ with gr.Column():
314
+ instructions_md = gr.Markdown(simple_instructions)
315
+ toggle_btn = gr.Button("Show Detailed Instructions")
316
+
317
+ # Toggle button to switch between simple and detailed instructions
318
+ toggle_btn.click(
319
+ fn=toggle_instructions,
320
+ inputs=[gr.State(False)], # Initial state is False (simple instructions)
321
+ outputs=[instructions_md, toggle_btn, gr.State()] # Return updated state
322
+ )
323
 
324
  with gr.Row():
325
  prompt = gr.Text(