fffiloni commited on
Commit
e237549
1 Parent(s): 43f7a39

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -290,6 +290,10 @@ def reset_compo_inference_state():
290
  models_to(models_rbm, device="cpu")
291
  models_b.generator.to("cpu")
292
 
 
 
 
 
293
  # Move SAM model components to CPU if they exist
294
  models_to(sam_model, device="cpu")
295
  models_to(sam_model.sam, device="cpu")
@@ -351,8 +355,8 @@ def infer_compo(style_description, ref_style_file, caption, ref_sub_file):
351
 
352
  if low_vram:
353
  models_to(models_rbm, device="cpu", excepts=["generator", "previewer"])
354
- models_to(sam_model, device)
355
- models_to(sam_model.sam, device)
356
 
357
  # Stage C reverse process.
358
  sampling_c = extras.gdf.sample(
 
290
  models_to(models_rbm, device="cpu")
291
  models_b.generator.to("cpu")
292
 
293
+ # Clear CUDA cache
294
+ torch.cuda.empty_cache()
295
+ gc.collect()
296
+
297
  # Move SAM model components to CPU if they exist
298
  models_to(sam_model, device="cpu")
299
  models_to(sam_model.sam, device="cpu")
 
355
 
356
  if low_vram:
357
  models_to(models_rbm, device="cpu", excepts=["generator", "previewer"])
358
+ models_to(sam_model, device="cpu")
359
+ models_to(sam_model.sam, device="cpu")
360
 
361
  # Stage C reverse process.
362
  sampling_c = extras.gdf.sample(