Spaces:
Running on Zero
Running on Zero
xinjie.wang commited on
Commit ·
7c8cbf6
1
Parent(s): 1d3e2bd
update
Browse files- README.md +1 -1
- app_style.py +1 -1
- common.py +18 -14
- embodied_gen/data/backproject_v2.py +1 -1
- embodied_gen/data/backproject_v3.py +1 -1
- embodied_gen/data/mesh_operator.py +1 -1
- embodied_gen/models/delight_model.py +1 -1
- embodied_gen/models/sam3d.py +6 -1
- embodied_gen/models/sr_model.py +2 -2
- embodied_gen/scripts/render_gs.py +1 -1
- embodied_gen/utils/monkey_patch/gradio.py +58 -0
- embodied_gen/utils/monkey_patch/sam3d.py +3 -2
- embodied_gen/utils/monkey_patch/trellis.py +1 -1
- embodied_gen/utils/process_media.py +1 -1
- embodied_gen/utils/trender.py +0 -5
- requirements.txt +17 -13
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 🎨
|
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
|
|
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 6.8.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
app_style.py
CHANGED
|
@@ -20,7 +20,7 @@ from gradio.themes.utils.colors import gray, neutral, slate, stone, teal, zinc
|
|
| 20 |
lighting_css = """
|
| 21 |
<style>
|
| 22 |
#lighter_mesh canvas {
|
| 23 |
-
filter: brightness(
|
| 24 |
}
|
| 25 |
</style>
|
| 26 |
"""
|
|
|
|
| 20 |
lighting_css = """
|
| 21 |
<style>
|
| 22 |
#lighter_mesh canvas {
|
| 23 |
+
filter: brightness(2.3) !important;
|
| 24 |
}
|
| 25 |
</style>
|
| 26 |
"""
|
common.py
CHANGED
|
@@ -18,6 +18,11 @@ import spaces
|
|
| 18 |
from embodied_gen.utils.monkey_patch.trellis import monkey_path_trellis
|
| 19 |
|
| 20 |
monkey_path_trellis()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
import gc
|
| 23 |
import logging
|
|
@@ -73,7 +78,6 @@ current_file_path = os.path.abspath(__file__)
|
|
| 73 |
current_dir = os.path.dirname(current_file_path)
|
| 74 |
sys.path.append(os.path.join(current_dir, ".."))
|
| 75 |
from thirdparty.TRELLIS.trellis.pipelines import TrellisImageTo3DPipeline
|
| 76 |
-
from thirdparty.TRELLIS.trellis.utils import postprocessing_utils
|
| 77 |
|
| 78 |
logging.basicConfig(
|
| 79 |
format="%(asctime)s - %(levelname)s - %(message)s", level=logging.INFO
|
|
@@ -81,7 +85,7 @@ logging.basicConfig(
|
|
| 81 |
logger = logging.getLogger(__name__)
|
| 82 |
|
| 83 |
os.environ["GRADIO_ANALYTICS_ENABLED"] = "false"
|
| 84 |
-
|
| 85 |
MAX_SEED = 100000
|
| 86 |
|
| 87 |
# DELIGHT = DelightingModel()
|
|
@@ -92,7 +96,7 @@ if os.getenv("GRADIO_APP").startswith("imageto3d"):
|
|
| 92 |
RBG14_REMOVER = BMGG14Remover()
|
| 93 |
SAM_PREDICTOR = SAMPredictor(model_type="vit_h", device="cpu")
|
| 94 |
if "sam3d" in os.getenv("GRADIO_APP"):
|
| 95 |
-
PIPELINE = Sam3dInference()
|
| 96 |
else:
|
| 97 |
PIPELINE = TrellisImageTo3DPipeline.from_pretrained(
|
| 98 |
"microsoft/TRELLIS-image-large"
|
|
@@ -110,7 +114,7 @@ elif os.getenv("GRADIO_APP").startswith("textto3d"):
|
|
| 110 |
RBG_REMOVER = RembgRemover()
|
| 111 |
RBG14_REMOVER = BMGG14Remover()
|
| 112 |
if "sam3d" in os.getenv("GRADIO_APP"):
|
| 113 |
-
PIPELINE = Sam3dInference()
|
| 114 |
else:
|
| 115 |
PIPELINE = TrellisImageTo3DPipeline.from_pretrained(
|
| 116 |
"microsoft/TRELLIS-image-large"
|
|
@@ -157,7 +161,6 @@ def end_session(req: gr.Request) -> None:
|
|
| 157 |
shutil.rmtree(user_dir)
|
| 158 |
|
| 159 |
|
| 160 |
-
@spaces.GPU(duration=120)
|
| 161 |
def preprocess_image_fn(
|
| 162 |
image: str | np.ndarray | Image.Image,
|
| 163 |
rmbg_tag: str = "rembg",
|
|
@@ -264,7 +267,7 @@ def select_point(
|
|
| 264 |
return (image, masks), seg_image
|
| 265 |
|
| 266 |
|
| 267 |
-
@spaces.GPU(duration=
|
| 268 |
def image_to_3d(
|
| 269 |
image: Image.Image,
|
| 270 |
seed: int,
|
|
@@ -276,7 +279,7 @@ def image_to_3d(
|
|
| 276 |
sam_image: Image.Image = None,
|
| 277 |
is_sam_image: bool = False,
|
| 278 |
req: gr.Request = None,
|
| 279 |
-
) -> tuple[
|
| 280 |
if is_sam_image:
|
| 281 |
seg_image = filter_image_small_connected_components(sam_image)
|
| 282 |
seg_image = Image.fromarray(seg_image, mode="RGBA")
|
|
@@ -286,6 +289,7 @@ def image_to_3d(
|
|
| 286 |
if isinstance(seg_image, np.ndarray):
|
| 287 |
seg_image = Image.fromarray(seg_image)
|
| 288 |
|
|
|
|
| 289 |
if isinstance(PIPELINE, Sam3dInference):
|
| 290 |
outputs = PIPELINE.run(
|
| 291 |
seg_image,
|
|
@@ -334,7 +338,7 @@ def image_to_3d(
|
|
| 334 |
|
| 335 |
|
| 336 |
def extract_3d_representations_v2(
|
| 337 |
-
state:
|
| 338 |
enable_delight: bool,
|
| 339 |
texture_size: int,
|
| 340 |
req: gr.Request,
|
|
@@ -401,7 +405,7 @@ def extract_3d_representations_v2(
|
|
| 401 |
|
| 402 |
|
| 403 |
def extract_3d_representations_v3(
|
| 404 |
-
state:
|
| 405 |
enable_delight: bool,
|
| 406 |
texture_size: int,
|
| 407 |
req: gr.Request,
|
|
@@ -564,7 +568,7 @@ def extract_urdf(
|
|
| 564 |
)
|
| 565 |
|
| 566 |
|
| 567 |
-
@spaces.GPU
|
| 568 |
def text2image_fn(
|
| 569 |
prompt: str,
|
| 570 |
guidance_scale: float,
|
|
@@ -620,7 +624,7 @@ def text2image_fn(
|
|
| 620 |
return save_paths + save_paths
|
| 621 |
|
| 622 |
|
| 623 |
-
@spaces.GPU
|
| 624 |
def generate_condition(mesh_path: str, req: gr.Request, uuid: str = "sample"):
|
| 625 |
output_root = os.path.join(TMP_DIR, str(req.session_hash))
|
| 626 |
|
|
@@ -636,7 +640,7 @@ def generate_condition(mesh_path: str, req: gr.Request, uuid: str = "sample"):
|
|
| 636 |
return None, None, None
|
| 637 |
|
| 638 |
|
| 639 |
-
@spaces.GPU
|
| 640 |
def generate_texture_mvimages(
|
| 641 |
prompt: str,
|
| 642 |
controlnet_cond_scale: float = 0.55,
|
|
@@ -723,7 +727,7 @@ def backproject_texture(
|
|
| 723 |
return output_glb_mesh, output_obj_mesh, zip_file
|
| 724 |
|
| 725 |
|
| 726 |
-
@spaces.GPU
|
| 727 |
def backproject_texture_v2(
|
| 728 |
mesh_path: str,
|
| 729 |
input_image: str,
|
|
@@ -770,7 +774,7 @@ def backproject_texture_v2(
|
|
| 770 |
return output_glb_mesh, output_obj_mesh, zip_file
|
| 771 |
|
| 772 |
|
| 773 |
-
@spaces.GPU
|
| 774 |
def render_result_video(
|
| 775 |
mesh_path: str, video_size: int, req: gr.Request, uuid: str = ""
|
| 776 |
) -> str:
|
|
|
|
| 18 |
from embodied_gen.utils.monkey_patch.trellis import monkey_path_trellis
|
| 19 |
|
| 20 |
monkey_path_trellis()
|
| 21 |
+
from embodied_gen.utils.monkey_patch.gradio import (
|
| 22 |
+
_patch_open3d_cuda_device_count_bug,
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
_patch_open3d_cuda_device_count_bug()
|
| 26 |
|
| 27 |
import gc
|
| 28 |
import logging
|
|
|
|
| 78 |
current_dir = os.path.dirname(current_file_path)
|
| 79 |
sys.path.append(os.path.join(current_dir, ".."))
|
| 80 |
from thirdparty.TRELLIS.trellis.pipelines import TrellisImageTo3DPipeline
|
|
|
|
| 81 |
|
| 82 |
logging.basicConfig(
|
| 83 |
format="%(asctime)s - %(levelname)s - %(message)s", level=logging.INFO
|
|
|
|
| 85 |
logger = logging.getLogger(__name__)
|
| 86 |
|
| 87 |
os.environ["GRADIO_ANALYTICS_ENABLED"] = "false"
|
| 88 |
+
os.environ.setdefault("OPENAI_API_KEY", "sk-placeholder")
|
| 89 |
MAX_SEED = 100000
|
| 90 |
|
| 91 |
# DELIGHT = DelightingModel()
|
|
|
|
| 96 |
RBG14_REMOVER = BMGG14Remover()
|
| 97 |
SAM_PREDICTOR = SAMPredictor(model_type="vit_h", device="cpu")
|
| 98 |
if "sam3d" in os.getenv("GRADIO_APP"):
|
| 99 |
+
PIPELINE = Sam3dInference(device="cuda")
|
| 100 |
else:
|
| 101 |
PIPELINE = TrellisImageTo3DPipeline.from_pretrained(
|
| 102 |
"microsoft/TRELLIS-image-large"
|
|
|
|
| 114 |
RBG_REMOVER = RembgRemover()
|
| 115 |
RBG14_REMOVER = BMGG14Remover()
|
| 116 |
if "sam3d" in os.getenv("GRADIO_APP"):
|
| 117 |
+
PIPELINE = Sam3dInference(device="cuda")
|
| 118 |
else:
|
| 119 |
PIPELINE = TrellisImageTo3DPipeline.from_pretrained(
|
| 120 |
"microsoft/TRELLIS-image-large"
|
|
|
|
| 161 |
shutil.rmtree(user_dir)
|
| 162 |
|
| 163 |
|
|
|
|
| 164 |
def preprocess_image_fn(
|
| 165 |
image: str | np.ndarray | Image.Image,
|
| 166 |
rmbg_tag: str = "rembg",
|
|
|
|
| 267 |
return (image, masks), seg_image
|
| 268 |
|
| 269 |
|
| 270 |
+
@spaces.GPU(duration=120)
|
| 271 |
def image_to_3d(
|
| 272 |
image: Image.Image,
|
| 273 |
seed: int,
|
|
|
|
| 279 |
sam_image: Image.Image = None,
|
| 280 |
is_sam_image: bool = False,
|
| 281 |
req: gr.Request = None,
|
| 282 |
+
) -> tuple[object, str]:
|
| 283 |
if is_sam_image:
|
| 284 |
seg_image = filter_image_small_connected_components(sam_image)
|
| 285 |
seg_image = Image.fromarray(seg_image, mode="RGBA")
|
|
|
|
| 289 |
if isinstance(seg_image, np.ndarray):
|
| 290 |
seg_image = Image.fromarray(seg_image)
|
| 291 |
|
| 292 |
+
logger.info("Start generating 3D representation from image...")
|
| 293 |
if isinstance(PIPELINE, Sam3dInference):
|
| 294 |
outputs = PIPELINE.run(
|
| 295 |
seg_image,
|
|
|
|
| 338 |
|
| 339 |
|
| 340 |
def extract_3d_representations_v2(
|
| 341 |
+
state: object,
|
| 342 |
enable_delight: bool,
|
| 343 |
texture_size: int,
|
| 344 |
req: gr.Request,
|
|
|
|
| 405 |
|
| 406 |
|
| 407 |
def extract_3d_representations_v3(
|
| 408 |
+
state: object,
|
| 409 |
enable_delight: bool,
|
| 410 |
texture_size: int,
|
| 411 |
req: gr.Request,
|
|
|
|
| 568 |
)
|
| 569 |
|
| 570 |
|
| 571 |
+
@spaces.GPU
|
| 572 |
def text2image_fn(
|
| 573 |
prompt: str,
|
| 574 |
guidance_scale: float,
|
|
|
|
| 624 |
return save_paths + save_paths
|
| 625 |
|
| 626 |
|
| 627 |
+
@spaces.GPU
|
| 628 |
def generate_condition(mesh_path: str, req: gr.Request, uuid: str = "sample"):
|
| 629 |
output_root = os.path.join(TMP_DIR, str(req.session_hash))
|
| 630 |
|
|
|
|
| 640 |
return None, None, None
|
| 641 |
|
| 642 |
|
| 643 |
+
@spaces.GPU
|
| 644 |
def generate_texture_mvimages(
|
| 645 |
prompt: str,
|
| 646 |
controlnet_cond_scale: float = 0.55,
|
|
|
|
| 727 |
return output_glb_mesh, output_obj_mesh, zip_file
|
| 728 |
|
| 729 |
|
| 730 |
+
@spaces.GPU
|
| 731 |
def backproject_texture_v2(
|
| 732 |
mesh_path: str,
|
| 733 |
input_image: str,
|
|
|
|
| 774 |
return output_glb_mesh, output_obj_mesh, zip_file
|
| 775 |
|
| 776 |
|
| 777 |
+
@spaces.GPU
|
| 778 |
def render_result_video(
|
| 779 |
mesh_path: str, video_size: int, req: gr.Request, uuid: str = ""
|
| 780 |
) -> str:
|
embodied_gen/data/backproject_v2.py
CHANGED
|
@@ -596,7 +596,7 @@ class TextureBacker:
|
|
| 596 |
|
| 597 |
return texture
|
| 598 |
|
| 599 |
-
@spaces.GPU
|
| 600 |
def compute_texture(
|
| 601 |
self,
|
| 602 |
colors: list[Image.Image],
|
|
|
|
| 596 |
|
| 597 |
return texture
|
| 598 |
|
| 599 |
+
@spaces.GPU
|
| 600 |
def compute_texture(
|
| 601 |
self,
|
| 602 |
colors: list[Image.Image],
|
embodied_gen/data/backproject_v3.py
CHANGED
|
@@ -425,7 +425,7 @@ def parse_args():
|
|
| 425 |
return args
|
| 426 |
|
| 427 |
|
| 428 |
-
@spaces.GPU
|
| 429 |
def entrypoint(
|
| 430 |
delight_model: DelightingModel = None,
|
| 431 |
imagesr_model: ImageRealESRGAN = None,
|
|
|
|
| 425 |
return args
|
| 426 |
|
| 427 |
|
| 428 |
+
@spaces.GPU
|
| 429 |
def entrypoint(
|
| 430 |
delight_model: DelightingModel = None,
|
| 431 |
imagesr_model: ImageRealESRGAN = None,
|
embodied_gen/data/mesh_operator.py
CHANGED
|
@@ -412,7 +412,7 @@ class MeshFixer(object):
|
|
| 412 |
dtype=torch.int32,
|
| 413 |
)
|
| 414 |
|
| 415 |
-
@spaces.GPU
|
| 416 |
def __call__(
|
| 417 |
self,
|
| 418 |
filter_ratio: float,
|
|
|
|
| 412 |
dtype=torch.int32,
|
| 413 |
)
|
| 414 |
|
| 415 |
+
@spaces.GPU
|
| 416 |
def __call__(
|
| 417 |
self,
|
| 418 |
filter_ratio: float,
|
embodied_gen/models/delight_model.py
CHANGED
|
@@ -140,7 +140,7 @@ class DelightingModel(object):
|
|
| 140 |
|
| 141 |
return new_image
|
| 142 |
|
| 143 |
-
@spaces.GPU
|
| 144 |
@torch.no_grad()
|
| 145 |
def __call__(
|
| 146 |
self,
|
|
|
|
| 140 |
|
| 141 |
return new_image
|
| 142 |
|
| 143 |
+
@spaces.GPU
|
| 144 |
@torch.no_grad()
|
| 145 |
def __call__(
|
| 146 |
self,
|
embodied_gen/models/sam3d.py
CHANGED
|
@@ -51,6 +51,7 @@ class Sam3dInference:
|
|
| 51 |
Args:
|
| 52 |
local_dir (str): Directory to store or load model weights and configs.
|
| 53 |
compile (bool): Whether to compile the model for faster inference.
|
|
|
|
| 54 |
|
| 55 |
Methods:
|
| 56 |
merge_mask_to_rgba(image, mask):
|
|
@@ -62,7 +63,10 @@ class Sam3dInference:
|
|
| 62 |
"""
|
| 63 |
|
| 64 |
def __init__(
|
| 65 |
-
self,
|
|
|
|
|
|
|
|
|
|
| 66 |
) -> None:
|
| 67 |
if not os.path.exists(local_dir):
|
| 68 |
snapshot_download("facebook/sam-3d-objects", local_dir=local_dir)
|
|
@@ -78,6 +82,7 @@ class Sam3dInference:
|
|
| 78 |
config["slat_decoder_gs_ckpt_path"] = config.pop(
|
| 79 |
"slat_decoder_gs_4_ckpt_path", "slat_decoder_gs_4.ckpt"
|
| 80 |
)
|
|
|
|
| 81 |
self.pipeline: InferencePipelinePointMap = instantiate(config)
|
| 82 |
|
| 83 |
def merge_mask_to_rgba(
|
|
|
|
| 51 |
Args:
|
| 52 |
local_dir (str): Directory to store or load model weights and configs.
|
| 53 |
compile (bool): Whether to compile the model for faster inference.
|
| 54 |
+
device (str): Device to run the model on (e.g., "cuda" or "cpu").
|
| 55 |
|
| 56 |
Methods:
|
| 57 |
merge_mask_to_rgba(image, mask):
|
|
|
|
| 63 |
"""
|
| 64 |
|
| 65 |
def __init__(
|
| 66 |
+
self,
|
| 67 |
+
local_dir: str = "weights/sam-3d-objects",
|
| 68 |
+
compile: bool = False,
|
| 69 |
+
device: str = "cuda",
|
| 70 |
) -> None:
|
| 71 |
if not os.path.exists(local_dir):
|
| 72 |
snapshot_download("facebook/sam-3d-objects", local_dir=local_dir)
|
|
|
|
| 82 |
config["slat_decoder_gs_ckpt_path"] = config.pop(
|
| 83 |
"slat_decoder_gs_4_ckpt_path", "slat_decoder_gs_4.ckpt"
|
| 84 |
)
|
| 85 |
+
config["device"] = device
|
| 86 |
self.pipeline: InferencePipelinePointMap = instantiate(config)
|
| 87 |
|
| 88 |
def merge_mask_to_rgba(
|
embodied_gen/models/sr_model.py
CHANGED
|
@@ -80,7 +80,7 @@ class ImageStableSR:
|
|
| 80 |
self.up_pipeline_x4.set_progress_bar_config(disable=True)
|
| 81 |
# self.up_pipeline_x4.enable_model_cpu_offload()
|
| 82 |
|
| 83 |
-
@spaces.GPU
|
| 84 |
def __call__(
|
| 85 |
self,
|
| 86 |
image: Union[Image.Image, np.ndarray],
|
|
@@ -196,7 +196,7 @@ class ImageRealESRGAN:
|
|
| 196 |
half=True,
|
| 197 |
)
|
| 198 |
|
| 199 |
-
@spaces.GPU
|
| 200 |
def __call__(self, image: Union[Image.Image, np.ndarray]) -> Image.Image:
|
| 201 |
"""Performs super-resolution on the input image.
|
| 202 |
|
|
|
|
| 80 |
self.up_pipeline_x4.set_progress_bar_config(disable=True)
|
| 81 |
# self.up_pipeline_x4.enable_model_cpu_offload()
|
| 82 |
|
| 83 |
+
@spaces.GPU
|
| 84 |
def __call__(
|
| 85 |
self,
|
| 86 |
image: Union[Image.Image, np.ndarray],
|
|
|
|
| 196 |
half=True,
|
| 197 |
)
|
| 198 |
|
| 199 |
+
@spaces.GPU
|
| 200 |
def __call__(self, image: Union[Image.Image, np.ndarray]) -> Image.Image:
|
| 201 |
"""Performs super-resolution on the input image.
|
| 202 |
|
embodied_gen/scripts/render_gs.py
CHANGED
|
@@ -96,7 +96,7 @@ def parse_args():
|
|
| 96 |
return args
|
| 97 |
|
| 98 |
|
| 99 |
-
@spaces.GPU
|
| 100 |
def entrypoint(**kwargs) -> None:
|
| 101 |
args = parse_args()
|
| 102 |
for k, v in kwargs.items():
|
|
|
|
| 96 |
return args
|
| 97 |
|
| 98 |
|
| 99 |
+
@spaces.GPU
|
| 100 |
def entrypoint(**kwargs) -> None:
|
| 101 |
args = parse_args()
|
| 102 |
for k, v in kwargs.items():
|
embodied_gen/utils/monkey_patch/gradio.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Project EmbodiedGen
|
| 2 |
+
#
|
| 3 |
+
# Copyright (c) 2025 Horizon Robotics. All Rights Reserved.
|
| 4 |
+
#
|
| 5 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
# you may not use this file except in compliance with the License.
|
| 7 |
+
# You may obtain a copy of the License at
|
| 8 |
+
#
|
| 9 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
#
|
| 11 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 14 |
+
# implied. See the License for the specific language governing
|
| 15 |
+
# permissions and limitations under the License.
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
import fileinput
|
| 19 |
+
import site
|
| 20 |
+
|
| 21 |
+
import gradio_client.utils as gradio_client_utils
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def _patch_gradio_schema_bool_bug() -> None:
|
| 25 |
+
"""Patch schema parser for bool-style for gradio<5.33."""
|
| 26 |
+
original_get_type = gradio_client_utils.get_type
|
| 27 |
+
original_json_schema_to_python_type = (
|
| 28 |
+
gradio_client_utils._json_schema_to_python_type
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
def _safe_get_type(schema):
|
| 32 |
+
if isinstance(schema, bool):
|
| 33 |
+
return {}
|
| 34 |
+
return original_get_type(schema)
|
| 35 |
+
|
| 36 |
+
def _safe_json_schema_to_python_type(schema, defs):
|
| 37 |
+
if isinstance(schema, bool):
|
| 38 |
+
return "Any"
|
| 39 |
+
return original_json_schema_to_python_type(schema, defs)
|
| 40 |
+
|
| 41 |
+
gradio_client_utils.get_type = _safe_get_type
|
| 42 |
+
gradio_client_utils._json_schema_to_python_type = (
|
| 43 |
+
_safe_json_schema_to_python_type
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def _patch_open3d_cuda_device_count_bug() -> None:
|
| 48 |
+
"""Patch open3d to avoid cuda device count bug."""
|
| 49 |
+
with fileinput.FileInput(
|
| 50 |
+
f'{site.getsitepackages()[0]}/open3d/__init__.py', inplace=True
|
| 51 |
+
) as file:
|
| 52 |
+
for line in file:
|
| 53 |
+
print(
|
| 54 |
+
line.replace(
|
| 55 |
+
'_pybind_cuda.open3d_core_cuda_device_count()', '1'
|
| 56 |
+
),
|
| 57 |
+
end='',
|
| 58 |
+
)
|
embodied_gen/utils/monkey_patch/sam3d.py
CHANGED
|
@@ -30,6 +30,7 @@ def monkey_patch_sam3d():
|
|
| 30 |
from embodied_gen.utils.log import logger
|
| 31 |
|
| 32 |
os.environ["LIDRA_SKIP_INIT"] = "true"
|
|
|
|
| 33 |
|
| 34 |
current_file_path = os.path.abspath(__file__)
|
| 35 |
current_dir = os.path.dirname(current_file_path)
|
|
@@ -379,7 +380,7 @@ def monkey_patch_sam3d():
|
|
| 379 |
|
| 380 |
InferencePipeline.__init__ = patch_init
|
| 381 |
|
| 382 |
-
patch_pointmap_infer_pipeline()
|
| 383 |
-
patch_infer_init()
|
| 384 |
|
| 385 |
return
|
|
|
|
| 30 |
from embodied_gen.utils.log import logger
|
| 31 |
|
| 32 |
os.environ["LIDRA_SKIP_INIT"] = "true"
|
| 33 |
+
os.environ['ATTN_BACKEND'] = "xformers"
|
| 34 |
|
| 35 |
current_file_path = os.path.abspath(__file__)
|
| 36 |
current_dir = os.path.dirname(current_file_path)
|
|
|
|
| 380 |
|
| 381 |
InferencePipeline.__init__ = patch_init
|
| 382 |
|
| 383 |
+
patch_pointmap_infer_pipeline() # patch
|
| 384 |
+
patch_infer_init() # patch
|
| 385 |
|
| 386 |
return
|
embodied_gen/utils/monkey_patch/trellis.py
CHANGED
|
@@ -37,7 +37,7 @@ def monkey_path_trellis():
|
|
| 37 |
os.environ["TORCH_EXTENSIONS_DIR"] = os.path.expanduser(
|
| 38 |
"~/.cache/torch_extensions"
|
| 39 |
)
|
| 40 |
-
os.environ["SPCONV_ALGO"] = "
|
| 41 |
os.environ['ATTN_BACKEND'] = (
|
| 42 |
"xformers" # Can be 'flash-attn' or 'xformers'
|
| 43 |
)
|
|
|
|
| 37 |
os.environ["TORCH_EXTENSIONS_DIR"] = os.path.expanduser(
|
| 38 |
"~/.cache/torch_extensions"
|
| 39 |
)
|
| 40 |
+
os.environ["SPCONV_ALGO"] = "native" # Can be 'native' or 'auto'
|
| 41 |
os.environ['ATTN_BACKEND'] = (
|
| 42 |
"xformers" # Can be 'flash-attn' or 'xformers'
|
| 43 |
)
|
embodied_gen/utils/process_media.py
CHANGED
|
@@ -53,7 +53,7 @@ __all__ = [
|
|
| 53 |
]
|
| 54 |
|
| 55 |
|
| 56 |
-
@spaces.GPU
|
| 57 |
def render_asset3d(
|
| 58 |
mesh_path: str,
|
| 59 |
output_root: str,
|
|
|
|
| 53 |
]
|
| 54 |
|
| 55 |
|
| 56 |
+
@spaces.GPU
|
| 57 |
def render_asset3d(
|
| 58 |
mesh_path: str,
|
| 59 |
output_root: str,
|
embodied_gen/utils/trender.py
CHANGED
|
@@ -19,7 +19,6 @@ import sys
|
|
| 19 |
from collections import defaultdict
|
| 20 |
|
| 21 |
import numpy as np
|
| 22 |
-
import spaces
|
| 23 |
import torch
|
| 24 |
from easydict import EasyDict as edict
|
| 25 |
from tqdm import tqdm
|
|
@@ -43,7 +42,6 @@ __all__ = [
|
|
| 43 |
]
|
| 44 |
|
| 45 |
|
| 46 |
-
@spaces.GPU(duration=120)
|
| 47 |
def render_mesh_frames(sample, extrinsics, intrinsics, options={}, **kwargs):
|
| 48 |
renderer = MeshRenderer()
|
| 49 |
renderer.rendering_options.resolution = options.get("resolution", 512)
|
|
@@ -66,7 +64,6 @@ def render_mesh_frames(sample, extrinsics, intrinsics, options={}, **kwargs):
|
|
| 66 |
return rets
|
| 67 |
|
| 68 |
|
| 69 |
-
@spaces.GPU(duration=120)
|
| 70 |
def render_gs_frames(
|
| 71 |
sample,
|
| 72 |
extrinsics,
|
|
@@ -117,7 +114,6 @@ def render_gs_frames(
|
|
| 117 |
return dict(outputs)
|
| 118 |
|
| 119 |
|
| 120 |
-
@spaces.GPU(duration=120)
|
| 121 |
def render_video(
|
| 122 |
sample,
|
| 123 |
resolution=512,
|
|
@@ -149,7 +145,6 @@ def render_video(
|
|
| 149 |
return result
|
| 150 |
|
| 151 |
|
| 152 |
-
@spaces.GPU(duration=120)
|
| 153 |
def pack_state(gs: Gaussian, mesh: MeshExtractResult) -> dict:
|
| 154 |
return {
|
| 155 |
"gaussian": {
|
|
|
|
| 19 |
from collections import defaultdict
|
| 20 |
|
| 21 |
import numpy as np
|
|
|
|
| 22 |
import torch
|
| 23 |
from easydict import EasyDict as edict
|
| 24 |
from tqdm import tqdm
|
|
|
|
| 42 |
]
|
| 43 |
|
| 44 |
|
|
|
|
| 45 |
def render_mesh_frames(sample, extrinsics, intrinsics, options={}, **kwargs):
|
| 46 |
renderer = MeshRenderer()
|
| 47 |
renderer.rendering_options.resolution = options.get("resolution", 512)
|
|
|
|
| 64 |
return rets
|
| 65 |
|
| 66 |
|
|
|
|
| 67 |
def render_gs_frames(
|
| 68 |
sample,
|
| 69 |
extrinsics,
|
|
|
|
| 114 |
return dict(outputs)
|
| 115 |
|
| 116 |
|
|
|
|
| 117 |
def render_video(
|
| 118 |
sample,
|
| 119 |
resolution=512,
|
|
|
|
| 145 |
return result
|
| 146 |
|
| 147 |
|
|
|
|
| 148 |
def pack_state(gs: Gaussian, mesh: MeshExtractResult) -> dict:
|
| 149 |
return {
|
| 150 |
"gaussian": {
|
requirements.txt
CHANGED
|
@@ -20,7 +20,8 @@ igraph==0.11.8
|
|
| 20 |
pyvista==0.36.1
|
| 21 |
openai==1.58.1
|
| 22 |
transformers==4.42.4
|
| 23 |
-
gradio
|
|
|
|
| 24 |
sentencepiece==0.2.0
|
| 25 |
diffusers==0.31.0
|
| 26 |
xatlas==0.0.9
|
|
@@ -31,18 +32,10 @@ basicsr==1.4.2
|
|
| 31 |
realesrgan==0.3.0
|
| 32 |
pydantic
|
| 33 |
vtk==9.3.1
|
| 34 |
-
spaces
|
| 35 |
# utils3d@git+https://github.com/EasternJournalist/utils3d.git@9a4eb15e4021b67b12c460c7057d642626897ec8
|
| 36 |
clip@git+https://github.com/openai/CLIP.git
|
| 37 |
kolors@git+https://github.com/Kwai-Kolors/Kolors.git#egg=038818d
|
| 38 |
segment-anything@git+https://github.com/facebookresearch/segment-anything.git#egg=dca509f
|
| 39 |
-
https://github.com/nerfstudio-project/gsplat/releases/download/v1.5.0/gsplat-1.5.0+pt24cu121-cp310-cp310-linux_x86_64.whl
|
| 40 |
-
https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.0.post2/flash_attn-2.7.0.post2+cu12torch2.4cxx11abiFALSE-cp310-cp310-linux_x86_64.whl
|
| 41 |
-
# kaolin@git+https://github.com/NVIDIAGameWorks/kaolin.git@v0.16.0
|
| 42 |
-
https://huggingface.co/xinjjj/RoboAssetGen/resolve/main/wheel_cu121/kaolin-0.16.0-cp310-cp310-linux_x86_64.whl
|
| 43 |
-
# nvdiffrast@git+https://github.com/NVlabs/nvdiffrast.git#egg=729261d
|
| 44 |
-
https://huggingface.co/xinjjj/RoboAssetGen/resolve/main/wheel_cu121/nvdiffrast-0.3.3-cp310-cp310-linux_x86_64.whl
|
| 45 |
-
https://huggingface.co/xinjjj/RoboAssetGen/resolve/main/wheel_cu121/diff_gaussian_rasterization-0.0.0-cp310-cp310-linux_x86_64.whl
|
| 46 |
colorlog
|
| 47 |
json-repair
|
| 48 |
scikit-learn
|
|
@@ -62,8 +55,19 @@ loguru
|
|
| 62 |
seaborn
|
| 63 |
hydra-core
|
| 64 |
modelscope
|
| 65 |
-
# git+https://github.com/facebookresearch/pytorch3d.git@stable
|
| 66 |
-
https://huggingface.co/xinjjj/RoboAssetGen/resolve/main/wheel_cu121/pytorch3d-0.7.8-cp310-cp310-linux_x86_64.whl
|
| 67 |
timm
|
| 68 |
-
open3d
|
| 69 |
-
MoGe@git+https://github.com/microsoft/MoGe.git@a8c3734
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
pyvista==0.36.1
|
| 21 |
openai==1.58.1
|
| 22 |
transformers==4.42.4
|
| 23 |
+
gradio==6.8.0
|
| 24 |
+
spaces==0.47.0
|
| 25 |
sentencepiece==0.2.0
|
| 26 |
diffusers==0.31.0
|
| 27 |
xatlas==0.0.9
|
|
|
|
| 32 |
realesrgan==0.3.0
|
| 33 |
pydantic
|
| 34 |
vtk==9.3.1
|
|
|
|
| 35 |
# utils3d@git+https://github.com/EasternJournalist/utils3d.git@9a4eb15e4021b67b12c460c7057d642626897ec8
|
| 36 |
clip@git+https://github.com/openai/CLIP.git
|
| 37 |
kolors@git+https://github.com/Kwai-Kolors/Kolors.git#egg=038818d
|
| 38 |
segment-anything@git+https://github.com/facebookresearch/segment-anything.git#egg=dca509f
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
colorlog
|
| 40 |
json-repair
|
| 41 |
scikit-learn
|
|
|
|
| 55 |
seaborn
|
| 56 |
hydra-core
|
| 57 |
modelscope
|
|
|
|
|
|
|
| 58 |
timm
|
| 59 |
+
# open3d
|
| 60 |
+
# MoGe@git+https://github.com/microsoft/MoGe.git@a8c3734
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
# git+https://github.com/facebookresearch/pytorch3d.git@stable
|
| 64 |
+
# https://huggingface.co/xinjjj/RoboAssetGen/resolve/main/wheel_cu121/pytorch3d-0.7.8-cp310-cp310-linux_x86_64.whl
|
| 65 |
+
# git+https://github.com/nerfstudio-project/gsplat.git@v1.5.3
|
| 66 |
+
https://github.com/nerfstudio-project/gsplat/releases/download/v1.5.0/gsplat-1.5.0+pt24cu121-cp310-cp310-linux_x86_64.whl
|
| 67 |
+
# flash-attn==2.7.0.post2
|
| 68 |
+
# https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.0.post2/flash_attn-2.7.0.post2+cu12torch2.4cxx11abiFALSE-cp310-cp310-linux_x86_64.whl
|
| 69 |
+
# kaolin@git+https://github.com/NVIDIAGameWorks/kaolin.git@v0.16.0
|
| 70 |
+
https://huggingface.co/xinjjj/RoboAssetGen/resolve/main/wheel_cu121/kaolin-0.16.0-cp310-cp310-linux_x86_64.whl
|
| 71 |
+
# nvdiffrast@git+https://github.com/NVlabs/nvdiffrast.git#egg=729261d
|
| 72 |
+
https://huggingface.co/xinjjj/RoboAssetGen/resolve/main/wheel_cu121/nvdiffrast-0.3.3-cp310-cp310-linux_x86_64.whl
|
| 73 |
+
https://huggingface.co/xinjjj/RoboAssetGen/resolve/main/wheel_cu121/diff_gaussian_rasterization-0.0.0-cp310-cp310-linux_x86_64.whl
|