Spaces:
Running on Zero
Running on Zero
Replace bake_texture with TexturePipeline (mvadapter API change)
Browse filesbake_texture() was removed from mvadapter.utils.mesh_utils.
Replace with TexturePipeline(upscaler=None, inpainter=None) which
does pure UV projection (inpaint_mode='uv') without requiring any
additional checkpoint downloads.
- No upscaler needed (view_upscale=False)
- No network inpainter needed (inpaint_mode='uv' uses UV-space projection only)
- UV unwrapped at 1024px resolution
app.py
CHANGED
|
@@ -1026,17 +1026,24 @@ def apply_texture(glb_path, input_image, remove_background, variant, tex_seed,
|
|
| 1026 |
|
| 1027 |
# ββ Bake textures onto mesh βββββββββββββββββββββββββββββββββββββ
|
| 1028 |
progress(0.85, desc="Baking UV texture onto mesh...")
|
| 1029 |
-
from mvadapter.
|
| 1030 |
-
NVDiffRastContextWrapper, load_mesh, bake_texture,
|
| 1031 |
-
)
|
| 1032 |
-
|
| 1033 |
-
ctx = NVDiffRastContextWrapper(device=DEVICE, context_type="cuda")
|
| 1034 |
-
mesh = load_mesh(glb_path, rescale=True, device=DEVICE)
|
| 1035 |
-
tex_pil = Image.open(mv_path)
|
| 1036 |
|
| 1037 |
-
|
| 1038 |
-
|
| 1039 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1040 |
|
| 1041 |
final_path = "/tmp/triposg_textured.glb"
|
| 1042 |
shutil.copy(out_glb, final_path)
|
|
|
|
| 1026 |
|
| 1027 |
# ββ Bake textures onto mesh βββββββββββββββββββββββββββββββββββββ
|
| 1028 |
progress(0.85, desc="Baking UV texture onto mesh...")
|
| 1029 |
+
from mvadapter.pipelines.pipeline_texture import TexturePipeline, ModProcessConfig
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1030 |
|
| 1031 |
+
texture_pipe = TexturePipeline(
|
| 1032 |
+
upscaler_ckpt_path=None, # no upscaler needed
|
| 1033 |
+
inpaint_ckpt_path=None, # inpaint_mode="uv" does not use network inpainter
|
| 1034 |
+
device=DEVICE,
|
| 1035 |
+
)
|
| 1036 |
+
tex_out = texture_pipe(
|
| 1037 |
+
mesh_path=glb_path,
|
| 1038 |
+
save_dir=out_dir,
|
| 1039 |
+
save_name="textured",
|
| 1040 |
+
uv_unwarp=True,
|
| 1041 |
+
uv_size=1024,
|
| 1042 |
+
rgb_path=mv_path,
|
| 1043 |
+
rgb_process_config=ModProcessConfig(view_upscale=False, inpaint_mode="uv"),
|
| 1044 |
+
camera_azimuth_deg=[0, 45, 90, 180, 270, 315],
|
| 1045 |
+
)
|
| 1046 |
+
out_glb = tex_out.shaded_model_save_path
|
| 1047 |
|
| 1048 |
final_path = "/tmp/triposg_textured.glb"
|
| 1049 |
shutil.copy(out_glb, final_path)
|