Spaces:
Running on Zero
Running on Zero
fix(texture): lazy load IP adapter pipeline
Browse files- common.py +16 -8
- requirements.txt +1 -1
common.py
CHANGED
|
@@ -138,11 +138,7 @@ elif os.getenv("GRADIO_APP").startswith("textto3d"):
|
|
| 138 |
elif os.getenv("GRADIO_APP") == "texture_edit":
|
| 139 |
DELIGHT = DelightingModel()
|
| 140 |
IMAGESR_MODEL = ImageRealESRGAN(outscale=4)
|
| 141 |
-
PIPELINE_IP =
|
| 142 |
-
base_ckpt_dir="./weights",
|
| 143 |
-
ip_adapt_scale=0.7,
|
| 144 |
-
device="cuda",
|
| 145 |
-
)
|
| 146 |
PIPELINE = build_texture_gen_pipe(
|
| 147 |
base_ckpt_dir="./weights",
|
| 148 |
ip_adapt_scale=0,
|
|
@@ -657,7 +653,7 @@ def generate_condition(mesh_path: str, req: gr.Request, uuid: str = "sample"):
|
|
| 657 |
return None, None, None
|
| 658 |
|
| 659 |
|
| 660 |
-
@spaces.GPU
|
| 661 |
def generate_texture_mvimages(
|
| 662 |
prompt: str,
|
| 663 |
controlnet_cond_scale: float = 0.55,
|
|
@@ -671,9 +667,21 @@ def generate_texture_mvimages(
|
|
| 671 |
sub_idxs: tuple[tuple[int]] = ((0, 1, 2), (3, 4, 5)),
|
| 672 |
req: gr.Request = None,
|
| 673 |
) -> list[str]:
|
|
|
|
|
|
|
| 674 |
output_root = os.path.join(TMP_DIR, str(req.session_hash))
|
| 675 |
use_ip_adapter = True if ip_img_path and ip_adapt_scale > 0 else False
|
| 676 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 677 |
img_save_paths = infer_pipe(
|
| 678 |
index_file=f"{output_root}/condition/index.json",
|
| 679 |
controlnet_cond_scale=controlnet_cond_scale,
|
|
@@ -686,7 +694,7 @@ def generate_texture_mvimages(
|
|
| 686 |
prompt=prompt,
|
| 687 |
save_dir=f"{output_root}/multi_view",
|
| 688 |
sub_idxs=sub_idxs,
|
| 689 |
-
pipeline=
|
| 690 |
seed=seed,
|
| 691 |
)
|
| 692 |
|
|
|
|
| 138 |
elif os.getenv("GRADIO_APP") == "texture_edit":
|
| 139 |
DELIGHT = DelightingModel()
|
| 140 |
IMAGESR_MODEL = ImageRealESRGAN(outscale=4)
|
| 141 |
+
PIPELINE_IP = None
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
PIPELINE = build_texture_gen_pipe(
|
| 143 |
base_ckpt_dir="./weights",
|
| 144 |
ip_adapt_scale=0,
|
|
|
|
| 653 |
return None, None, None
|
| 654 |
|
| 655 |
|
| 656 |
+
@spaces.GPU(duration=240)
|
| 657 |
def generate_texture_mvimages(
|
| 658 |
prompt: str,
|
| 659 |
controlnet_cond_scale: float = 0.55,
|
|
|
|
| 667 |
sub_idxs: tuple[tuple[int]] = ((0, 1, 2), (3, 4, 5)),
|
| 668 |
req: gr.Request = None,
|
| 669 |
) -> list[str]:
|
| 670 |
+
global PIPELINE_IP
|
| 671 |
+
|
| 672 |
output_root = os.path.join(TMP_DIR, str(req.session_hash))
|
| 673 |
use_ip_adapter = True if ip_img_path and ip_adapt_scale > 0 else False
|
| 674 |
+
pipeline = PIPELINE
|
| 675 |
+
if use_ip_adapter:
|
| 676 |
+
if PIPELINE_IP is None:
|
| 677 |
+
PIPELINE_IP = build_texture_gen_pipe(
|
| 678 |
+
base_ckpt_dir="./weights",
|
| 679 |
+
ip_adapt_scale=ip_adapt_scale,
|
| 680 |
+
device="cuda",
|
| 681 |
+
)
|
| 682 |
+
PIPELINE_IP.set_ip_adapter_scale([ip_adapt_scale])
|
| 683 |
+
pipeline = PIPELINE_IP
|
| 684 |
+
|
| 685 |
img_save_paths = infer_pipe(
|
| 686 |
index_file=f"{output_root}/condition/index.json",
|
| 687 |
controlnet_cond_scale=controlnet_cond_scale,
|
|
|
|
| 694 |
prompt=prompt,
|
| 695 |
save_dir=f"{output_root}/multi_view",
|
| 696 |
sub_idxs=sub_idxs,
|
| 697 |
+
pipeline=pipeline,
|
| 698 |
seed=seed,
|
| 699 |
)
|
| 700 |
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
--extra-index-url https://download.pytorch.org/whl/
|
| 2 |
|
| 3 |
setuptools==80.10.2
|
| 4 |
wheel
|
|
|
|
| 1 |
+
--extra-index-url https://download.pytorch.org/whl/cu128
|
| 2 |
|
| 3 |
setuptools==80.10.2
|
| 4 |
wheel
|