multimodalart HF staff commited on
Commit
46108bd
1 Parent(s): c9d95ee

Fix caching examples by counting the state variable again

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -335,8 +335,11 @@ help_text = """
335
 
336
  with gr.Blocks(css="style.css") as demo:
337
 
338
- def remove_concept(sega_concepts_counter):
339
- sega_concepts_counter -= 1
 
 
 
340
  rows_visibility = [gr.update(visible=False) for _ in range(4)]
341
  rows_visibility[sega_concepts_counter] = gr.update(visible=True)
342
 
@@ -608,9 +611,9 @@ with gr.Blocks(css="style.css") as demo:
608
  remove_2.click(fn = update_display_concept, inputs=[remove_2, edit_concept_2, neg_guidance_2 ,sega_concepts_counter], outputs=[box2, concept_2, guidnace_scale_2,neg_guidance_2,row2, row3,sega_concepts_counter],queue=False)
609
  remove_3.click(fn = update_display_concept, inputs=[remove_3, edit_concept_3, neg_guidance_3, sega_concepts_counter], outputs=[box3, concept_3, guidnace_scale_3,neg_guidance_3, row3, row4, sega_concepts_counter],queue=False)
610
 
611
- remove_concept1.click(fn = remove_concept, inputs=sega_concepts_counter, outputs= [box1, concept_1, edit_concept_1, guidnace_scale_1,neg_guidance_1, add_1, dropdown1, row1, row2, row3, row4, sega_concepts_counter],queue=False)
612
- remove_concept2.click(fn = remove_concept, inputs=sega_concepts_counter, outputs=[box2, concept_2, edit_concept_2, guidnace_scale_2,neg_guidance_2, add_2 , dropdown2, row1, row2, row3, row4, sega_concepts_counter],queue=False)
613
- remove_concept3.click(fn = remove_concept, inputs=sega_concepts_counter, outputs=[box3, concept_3, edit_concept_3, guidnace_scale_3,neg_guidance_3, add_3, dropdown3, row1, row2, row3, row4, sega_concepts_counter],queue=False)
614
 
615
  #add_concept_button.click(fn = update_display_concept, inputs=sega_concepts_counter,
616
  # outputs= [row2, row2_advanced, row3, row3_advanced, add_concept_button, sega_concepts_counter], queue = False)
@@ -780,6 +783,7 @@ with gr.Blocks(css="style.css") as demo:
780
  sega_concepts_counter
781
  ],
782
  outputs=[box1, concept_1, guidnace_scale_1,neg_guidance_1, row1, row2,box2, concept_2, guidnace_scale_2,neg_guidance_2,row2, row3,sega_concepts_counter],
 
783
  )
784
 
785
 
 
335
 
336
  with gr.Blocks(css="style.css") as demo:
337
 
338
+ def remove_concept(sega_concepts_counter,edit_concept1,edit_concept2,edit_concept3):
339
+ if(not sega_concepts_counter):
340
+ sega_concepts_counter = len([concept for concept in [edit_concept1, edit_concept2, edit_concept3] if concept != ''])-1
341
+ else:
342
+ sega_concepts_counter -= 1
343
  rows_visibility = [gr.update(visible=False) for _ in range(4)]
344
  rows_visibility[sega_concepts_counter] = gr.update(visible=True)
345
 
 
611
  remove_2.click(fn = update_display_concept, inputs=[remove_2, edit_concept_2, neg_guidance_2 ,sega_concepts_counter], outputs=[box2, concept_2, guidnace_scale_2,neg_guidance_2,row2, row3,sega_concepts_counter],queue=False)
612
  remove_3.click(fn = update_display_concept, inputs=[remove_3, edit_concept_3, neg_guidance_3, sega_concepts_counter], outputs=[box3, concept_3, guidnace_scale_3,neg_guidance_3, row3, row4, sega_concepts_counter],queue=False)
613
 
614
+ remove_concept1.click(fn = remove_concept, inputs=[sega_concepts_counter,edit_concept_1,edit_concept_2,edit_concept_3], outputs= [box1, concept_1, edit_concept_1, guidnace_scale_1,neg_guidance_1, add_1, dropdown1, row1, row2, row3, row4, sega_concepts_counter],queue=False)
615
+ remove_concept2.click(fn = remove_concept, inputs=[sega_concepts_counter,edit_concept_1,edit_concept_2,edit_concept_3], outputs=[box2, concept_2, edit_concept_2, guidnace_scale_2,neg_guidance_2, add_2 , dropdown2, row1, row2, row3, row4, sega_concepts_counter],queue=False)
616
+ remove_concept3.click(fn = remove_concept, inputs=[sega_concepts_counter,edit_concept_1,edit_concept_2,edit_concept_3], outputs=[box3, concept_3, edit_concept_3, guidnace_scale_3,neg_guidance_3, add_3, dropdown3, row1, row2, row3, row4, sega_concepts_counter],queue=False)
617
 
618
  #add_concept_button.click(fn = update_display_concept, inputs=sega_concepts_counter,
619
  # outputs= [row2, row2_advanced, row3, row3_advanced, add_concept_button, sega_concepts_counter], queue = False)
 
783
  sega_concepts_counter
784
  ],
785
  outputs=[box1, concept_1, guidnace_scale_1,neg_guidance_1, row1, row2,box2, concept_2, guidnace_scale_2,neg_guidance_2,row2, row3,sega_concepts_counter],
786
+ cache_examples=True
787
  )
788
 
789