fix(pipeline): respect pretrained rembg (RMBG-2.0); optional NEAR_REMBG_MODEL
Browse files
app.py
CHANGED
|
@@ -179,6 +179,8 @@ def _ensure_models() -> None:
|
|
| 179 |
if PIPELINE is not None:
|
| 180 |
return
|
| 181 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
|
|
|
| 182 |
near_id = os.environ.get("NEAR_PRETRAINED", "luh0502/NeAR")
|
| 183 |
gp = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained("tencent/Hunyuan3D-2.1")
|
| 184 |
gp.to(device)
|
|
|
|
| 179 |
if PIPELINE is not None:
|
| 180 |
return
|
| 181 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 182 |
+
# briaai/RMBG-2.0 is gated: accept the license on the model card, then add HF_TOKEN
|
| 183 |
+
# (read) in Space Settings -> Secrets. Never commit tokens into git.
|
| 184 |
near_id = os.environ.get("NEAR_PRETRAINED", "luh0502/NeAR")
|
| 185 |
gp = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained("tencent/Hunyuan3D-2.1")
|
| 186 |
gp.to(device)
|
trellis/pipelines/near_image_to_relightable_3d.py
CHANGED
|
@@ -95,12 +95,10 @@ class NeARImageToRelightable3DPipeline(Pipeline):
|
|
| 95 |
rembg_spec = args["rembg_model"]
|
| 96 |
rembg_name = rembg_spec["name"]
|
| 97 |
rembg_kwargs = dict(rembg_spec["args"])
|
|
|
|
|
|
|
|
|
|
| 98 |
rembg_cls = getattr(rembg, rembg_name)
|
| 99 |
-
# HF model config.json may still point at gated briaai/RMBG-2.0; Space demo uses open BiRefNet.
|
| 100 |
-
if rembg_name == "BiRefNet":
|
| 101 |
-
rembg_kwargs["model_name"] = os.environ.get(
|
| 102 |
-
"NEAR_REMBG_MODEL", "ZhengPeng7/BiRefNet"
|
| 103 |
-
)
|
| 104 |
new_pipeline.rembg_model = rembg_cls(**rembg_kwargs)
|
| 105 |
new_pipeline._init_image_cond_model(args["image_cond_model"])
|
| 106 |
new_pipeline.hdri_processor = HDRI_Preprocessor(envmap_h=512, envmap_w=1024)
|
|
|
|
| 95 |
rembg_spec = args["rembg_model"]
|
| 96 |
rembg_name = rembg_spec["name"]
|
| 97 |
rembg_kwargs = dict(rembg_spec["args"])
|
| 98 |
+
env_rembg = os.environ.get("NEAR_REMBG_MODEL")
|
| 99 |
+
if env_rembg:
|
| 100 |
+
rembg_kwargs["model_name"] = env_rembg
|
| 101 |
rembg_cls = getattr(rembg, rembg_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
new_pipeline.rembg_model = rembg_cls(**rembg_kwargs)
|
| 103 |
new_pipeline._init_image_cond_model(args["image_cond_model"])
|
| 104 |
new_pipeline.hdri_processor = HDRI_Preprocessor(envmap_h=512, envmap_w=1024)
|