Ashoka74 commited on
Commit
fd0e8bb
ยท
verified ยท
1 Parent(s): a74b98c

Update merged_app2.py

Browse files
Files changed (1) hide show
  1. merged_app2.py +14 -9
merged_app2.py CHANGED
@@ -202,8 +202,8 @@ except ImportError:
202
  XFORMERS_AVAILABLE = False
203
  print("xformers not available - Using default attention")
204
 
205
- fill_pipe.enable_model_cpu_offload()
206
- fill_pipe.enable_vae_slicing()
207
  #fill_pipe.enable_xformers_memory_efficient_attention()
208
 
209
 
@@ -491,8 +491,8 @@ pipe = prepare_pipeline(
491
  dtype=dtype,
492
  )
493
 
494
- pipe.enable_model_cpu_offload()
495
- pipe.enable_vae_slicing()
496
  #pipe.enable_xformers_memory_efficient_attention()
497
 
498
  # Move models to device with consistent dtype
@@ -543,8 +543,8 @@ t2i_pipe = StableDiffusionPipeline(
543
  image_encoder=None
544
  )
545
 
546
- t2i_pipe.enable_model_cpu_offload()
547
- t2i_pipe.enable_vae_slicing()
548
  #t2i_pipe.enable_xformers_memory_efficient_attention()
549
 
550
  i2i_pipe = StableDiffusionImg2ImgPipeline(
@@ -559,8 +559,8 @@ i2i_pipe = StableDiffusionImg2ImgPipeline(
559
  image_encoder=None
560
  )
561
 
562
- i2i_pipe.enable_model_cpu_offload()
563
- i2i_pipe.enable_vae_slicing()
564
  #i2i_pipe.enable_xformers_memory_efficient_attention()
565
 
566
  @torch.inference_mode()
@@ -1742,7 +1742,10 @@ with gr.Blocks() as app:
1742
 
1743
  with gr.Row():
1744
  with gr.Group():
1745
- prompt = gr.Textbox(label="Prompt")
 
 
 
1746
  bg_source = gr.Radio(choices=[e.value for e in list(BGSource)[2:]],
1747
  value=BGSource.LEFT.value,
1748
  label="Lighting Preference (Initial Latent)", type='value')
@@ -1795,7 +1798,9 @@ with gr.Blocks() as app:
1795
  # outputs=[result_gallery, output_bg],
1796
  # run_on_click=True, examples_per_page=1024
1797
  # )
 
1798
  ips = [extracted_fg, prompt, image_width, image_height, num_samples, seed, steps, a_prompt, n_prompt, cfg, highres_scale, highres_denoise, lowres_denoise, bg_source]
 
1799
  relight_button.click(fn=process_relight, inputs=ips, outputs=[result_gallery]).then(clear_memory, inputs=[], outputs=[])
1800
  example_quick_prompts.click(lambda x, y: ', '.join(y.split(', ')[:2] + [x[0]]), inputs=[example_quick_prompts, prompt], outputs=prompt, show_progress=False, queue=False)
1801
  example_quick_subjects.click(lambda x: x[0], inputs=example_quick_subjects, outputs=prompt, show_progress=False, queue=False)
 
202
  XFORMERS_AVAILABLE = False
203
  print("xformers not available - Using default attention")
204
 
205
+ # fill_pipe.enable_model_cpu_offload()
206
+ # fill_pipe.enable_vae_slicing()
207
  #fill_pipe.enable_xformers_memory_efficient_attention()
208
 
209
 
 
491
  dtype=dtype,
492
  )
493
 
494
+ # pipe.enable_model_cpu_offload()
495
+ # pipe.enable_vae_slicing()
496
  #pipe.enable_xformers_memory_efficient_attention()
497
 
498
  # Move models to device with consistent dtype
 
543
  image_encoder=None
544
  )
545
 
546
+ # t2i_pipe.enable_model_cpu_offload()
547
+ # t2i_pipe.enable_vae_slicing()
548
  #t2i_pipe.enable_xformers_memory_efficient_attention()
549
 
550
  i2i_pipe = StableDiffusionImg2ImgPipeline(
 
559
  image_encoder=None
560
  )
561
 
562
+ # i2i_pipe.enable_model_cpu_offload()
563
+ # i2i_pipe.enable_vae_slicing()
564
  #i2i_pipe.enable_xformers_memory_efficient_attention()
565
 
566
  @torch.inference_mode()
 
1742
 
1743
  with gr.Row():
1744
  with gr.Group():
1745
+ with gr.Column():
1746
+ prompt = gr.Textbox(label="Prompt")
1747
+ with gr.Column():
1748
+ augment_prompt = gr.Button(value='+')
1749
  bg_source = gr.Radio(choices=[e.value for e in list(BGSource)[2:]],
1750
  value=BGSource.LEFT.value,
1751
  label="Lighting Preference (Initial Latent)", type='value')
 
1798
  # outputs=[result_gallery, output_bg],
1799
  # run_on_click=True, examples_per_page=1024
1800
  # )
1801
+ augment_prompt.click(generate_description, inputs=[prompt,None], outputs=[prompt])
1802
  ips = [extracted_fg, prompt, image_width, image_height, num_samples, seed, steps, a_prompt, n_prompt, cfg, highres_scale, highres_denoise, lowres_denoise, bg_source]
1803
+
1804
  relight_button.click(fn=process_relight, inputs=ips, outputs=[result_gallery]).then(clear_memory, inputs=[], outputs=[])
1805
  example_quick_prompts.click(lambda x, y: ', '.join(y.split(', ')[:2] + [x[0]]), inputs=[example_quick_prompts, prompt], outputs=prompt, show_progress=False, queue=False)
1806
  example_quick_subjects.click(lambda x: x[0], inputs=example_quick_subjects, outputs=prompt, show_progress=False, queue=False)