AlekseyCalvin commited on
Commit
96cd6a5
1 Parent(s): 7c99d39

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -22
app.py CHANGED
@@ -695,15 +695,14 @@ with EmptyInitWrapper():
695
  sd = {k.replace("model.", ""): v for k, v in sd.items()}
696
  result = model.load_state_dict(sd)
697
 
698
- @torch.cuda.empty_cache()
699
-
700
  @spaces.GPU(duration=70)
701
- @torch.no_grad()
702
  def generate_image(
703
  prompt, neg_prompt,num_steps ,width, height, guidance, seed,
704
  do_img2img, init_image, image2image_strength, resize_img, lora_scale,
705
  progress=gr.Progress(track_tqdm=True)
706
- ):
707
  if seed == 0:
708
  seed = int(random.random() * 1000000)
709
 
@@ -753,22 +752,6 @@ def generate_image(
753
 
754
  return img, seed
755
 
756
- class calculateDuration:
757
- def __init__(self, activity_name=""):
758
- self.activity_name = activity_name
759
-
760
- def __enter__(self):
761
- self.start_time = time.time()
762
- return self
763
-
764
- def __exit__(self, exc_type, exc_value, traceback):
765
- self.end_time = time.time()
766
- self.elapsed_time = self.end_time - self.start_time
767
- if self.activity_name:
768
- print(f"Elapsed time for {self.activity_name}: {self.elapsed_time:.6f} seconds")
769
- else:
770
- print(f"Elapsed time: {self.elapsed_time:.6f} seconds")
771
-
772
  def update_selection(evt: gr.SelectData, width, height):
773
  selected_lora = loras[evt.index]
774
  new_placeholder = f"Type a prompt for {selected_lora['title']}"
@@ -820,8 +803,6 @@ def run_lora(
820
  pipe.unload_lora_weights()
821
  return image, seed
822
 
823
- run_lora.zerogpu = True
824
-
825
  css = '''
826
  #gen_btn{height: 100%}
827
  #title{text-align: center}
 
695
  sd = {k.replace("model.", ""): v for k, v in sd.items()}
696
  result = model.load_state_dict(sd)
697
 
698
+ #@torch.cuda.empty_cache()
 
699
  @spaces.GPU(duration=70)
700
+ #@torch.no_grad()
701
  def generate_image(
702
  prompt, neg_prompt,num_steps ,width, height, guidance, seed,
703
  do_img2img, init_image, image2image_strength, resize_img, lora_scale,
704
  progress=gr.Progress(track_tqdm=True)
705
+ ):
706
  if seed == 0:
707
  seed = int(random.random() * 1000000)
708
 
 
752
 
753
  return img, seed
754
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
755
  def update_selection(evt: gr.SelectData, width, height):
756
  selected_lora = loras[evt.index]
757
  new_placeholder = f"Type a prompt for {selected_lora['title']}"
 
803
  pipe.unload_lora_weights()
804
  return image, seed
805
 
 
 
806
  css = '''
807
  #gen_btn{height: 100%}
808
  #title{text-align: center}