Spaces:
Running on Zero
Running on Zero
fix(texture): unload IP adapter after generation
Browse files
common.py
CHANGED
|
@@ -693,24 +693,32 @@ def generate_texture_mvimages(
|
|
| 693 |
if PIPELINE_HAS_IP_ADAPTER:
|
| 694 |
PIPELINE.set_ip_adapter_scale([ip_adapt_scale if use_ip_adapter else 0.0])
|
| 695 |
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
| 700 |
-
|
| 701 |
-
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
|
| 711 |
-
|
| 712 |
-
|
| 713 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 714 |
|
| 715 |
return img_save_paths + img_save_paths
|
| 716 |
|
|
|
|
| 693 |
if PIPELINE_HAS_IP_ADAPTER:
|
| 694 |
PIPELINE.set_ip_adapter_scale([ip_adapt_scale if use_ip_adapter else 0.0])
|
| 695 |
|
| 696 |
+
try:
|
| 697 |
+
img_save_paths = infer_pipe(
|
| 698 |
+
index_file=f"{output_root}/condition/index.json",
|
| 699 |
+
controlnet_cond_scale=controlnet_cond_scale,
|
| 700 |
+
guidance_scale=guidance_scale,
|
| 701 |
+
strength=strength,
|
| 702 |
+
num_inference_steps=num_inference_steps,
|
| 703 |
+
ip_adapt_scale=ip_adapt_scale if use_ip_adapter else 0.0,
|
| 704 |
+
ip_img_path=ip_img_path if use_ip_adapter else None,
|
| 705 |
+
uid=uid,
|
| 706 |
+
prompt=prompt,
|
| 707 |
+
save_dir=f"{output_root}/multi_view",
|
| 708 |
+
sub_idxs=sub_idxs,
|
| 709 |
+
pipeline=PIPELINE,
|
| 710 |
+
seed=seed,
|
| 711 |
+
)
|
| 712 |
+
finally:
|
| 713 |
+
if use_ip_adapter and PIPELINE_HAS_IP_ADAPTER:
|
| 714 |
+
logger.info("Unload IP adapter from default texture pipeline")
|
| 715 |
+
if hasattr(PIPELINE, "unload_ip_adapter"):
|
| 716 |
+
PIPELINE.unload_ip_adapter()
|
| 717 |
+
else:
|
| 718 |
+
PIPELINE = None
|
| 719 |
+
PIPELINE_HAS_IP_ADAPTER = False
|
| 720 |
+
gc.collect()
|
| 721 |
+
torch.cuda.empty_cache()
|
| 722 |
|
| 723 |
return img_save_paths + img_save_paths
|
| 724 |
|