Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -291,12 +291,9 @@ def reset_compo_inference_state():
|
|
291 |
models_b.generator.to("cpu")
|
292 |
|
293 |
# Move SAM model components to CPU if they exist
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
if hasattr(sam_model, 'text_encoder'):
|
298 |
-
sam_model.text_encoder.to("cpu")
|
299 |
-
|
300 |
# Clear CUDA cache
|
301 |
torch.cuda.empty_cache()
|
302 |
gc.collect()
|
@@ -340,10 +337,8 @@ def infer_compo(style_description, ref_style_file, caption, ref_sub_file):
|
|
340 |
sam_model = LangSAM()
|
341 |
|
342 |
# Move SAM model components to the correct device
|
343 |
-
|
344 |
-
|
345 |
-
if hasattr(sam_model, 'text_encoder'):
|
346 |
-
sam_model.text_encoder.to(device)
|
347 |
|
348 |
x0_preview_pil = T.ToPILImage()(x0_preview[0].cpu())
|
349 |
sam_mask, boxes, phrases, logits = sam_model.predict(x0_preview_pil, sam_prompt)
|
|
|
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")
|
296 |
+
|
|
|
|
|
|
|
297 |
# Clear CUDA cache
|
298 |
torch.cuda.empty_cache()
|
299 |
gc.collect()
|
|
|
337 |
sam_model = LangSAM()
|
338 |
|
339 |
# Move SAM model components to the correct device
|
340 |
+
models_to(sam_model, device)
|
341 |
+
models_to(sam_model.sam, device)
|
|
|
|
|
342 |
|
343 |
x0_preview_pil = T.ToPILImage()(x0_preview[0].cpu())
|
344 |
sam_mask, boxes, phrases, logits = sam_model.predict(x0_preview_pil, sam_prompt)
|