cbensimon HF Staff commited on
Commit
5745e6f
·
verified ·
1 Parent(s): 9922d45

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -9
app.py CHANGED
@@ -61,11 +61,6 @@ canny = CannyDetector()
61
  anyline = AnylineDetector.from_pretrained("TheMistoAI/MistoLine", filename="MTEED.pth", subfolder="Anyline")
62
  open_pose = OpenposeDetector.from_pretrained("lllyasviel/Annotators")
63
 
64
- torch.backends.cuda.matmul.allow_tf32 = True
65
- pipe.vae.enable_tiling()
66
- pipe.vae.enable_slicing()
67
- pipe.enable_model_cpu_offload() # for saving memory
68
-
69
  def convert_from_image_to_cv2(img: Image) -> np.ndarray:
70
  return cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
71
 
@@ -147,7 +142,7 @@ def resize_img(input_image, max_side=1024, min_side=768, size=None,
147
 
148
  @spaces.GPU(duration=180)
149
  def infer(cond_in, image_in, prompt, inference_steps, guidance_scale, control_mode, control_strength, control_guidance_end, seed, progress=gr.Progress(track_tqdm=True)):
150
-
151
  if cond_in is None:
152
  if image_in is not None:
153
  image_in = resize_img(load_image(image_in))
@@ -165,7 +160,8 @@ def infer(cond_in, image_in, prompt, inference_steps, guidance_scale, control_mo
165
  control_image = resize_img(load_image(cond_in))
166
 
167
  width, height = control_image.size
168
-
 
169
  image = pipe(
170
  prompt,
171
  control_image=[control_image],
@@ -177,8 +173,7 @@ def infer(cond_in, image_in, prompt, inference_steps, guidance_scale, control_mo
177
  guidance_scale=guidance_scale,
178
  generator=torch.manual_seed(seed),
179
  ).images[0]
180
-
181
- torch.cuda.empty_cache()
182
 
183
  return image, control_image, gr.update(visible=True)
184
 
 
61
  anyline = AnylineDetector.from_pretrained("TheMistoAI/MistoLine", filename="MTEED.pth", subfolder="Anyline")
62
  open_pose = OpenposeDetector.from_pretrained("lllyasviel/Annotators")
63
 
 
 
 
 
 
64
  def convert_from_image_to_cv2(img: Image) -> np.ndarray:
65
  return cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
66
 
 
142
 
143
  @spaces.GPU(duration=180)
144
  def infer(cond_in, image_in, prompt, inference_steps, guidance_scale, control_mode, control_strength, control_guidance_end, seed, progress=gr.Progress(track_tqdm=True)):
145
+ print('infer')
146
  if cond_in is None:
147
  if image_in is not None:
148
  image_in = resize_img(load_image(image_in))
 
160
  control_image = resize_img(load_image(cond_in))
161
 
162
  width, height = control_image.size
163
+
164
+ print('pipe ...')
165
  image = pipe(
166
  prompt,
167
  control_image=[control_image],
 
173
  guidance_scale=guidance_scale,
174
  generator=torch.manual_seed(seed),
175
  ).images[0]
176
+ print('pipe DONE')
 
177
 
178
  return image, control_image, gr.update(visible=True)
179