Data API
embodied_gen.data.asset_converter
AssetConverterBase
Bases: ABC
Abstract base class for asset converters.
Provides context management and mesh transformation utilities.
__enter__
__enter__()
Context manager entry.
Source code in embodied_gen/data/asset_converter.py
157 158 159 | |
__exit__
__exit__(exc_type, exc_val, exc_tb)
Context manager exit.
Source code in embodied_gen/data/asset_converter.py
161 162 163 | |
convert
abstractmethod
convert(urdf_path: str, output_path: str, **kwargs) -> str
Convert an asset file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
urdf_path
|
str
|
Path to input URDF file. |
required |
output_path
|
str
|
Path to output file. |
required |
**kwargs
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Path to converted asset. |
Source code in embodied_gen/data/asset_converter.py
113 114 115 116 117 118 119 120 121 122 123 124 125 | |
transform_mesh
transform_mesh(input_mesh: str, output_mesh: str, mesh_origin: Element) -> None
Apply transform to mesh based on URDF origin element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_mesh
|
str
|
Path to input mesh. |
required |
output_mesh
|
str
|
Path to output mesh. |
required |
mesh_origin
|
Element
|
Origin element from URDF. |
required |
Source code in embodied_gen/data/asset_converter.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
AssetConverterFactory
Factory for creating asset converters based on target and source types.
Example
from embodied_gen.data.asset_converter import AssetConverterFactory
from embodied_gen.utils.enum import AssetType
converter = AssetConverterFactory.create(
target_type=AssetType.USD, source_type=AssetType.MESH
)
with converter:
for urdf_path, output_file in zip(urdf_paths, output_files):
converter.convert(urdf_path, output_file)
create
staticmethod
create(target_type: AssetType, source_type: AssetType = 'urdf', **kwargs) -> AssetConverterBase
Creates an asset converter instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_type
|
AssetType
|
Target asset type. |
required |
source_type
|
AssetType
|
Source asset type. |
'urdf'
|
**kwargs
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
AssetConverterBase |
AssetConverterBase
|
Converter instance. |
Source code in embodied_gen/data/asset_converter.py
851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 | |
MeshtoMJCFConverter
MeshtoMJCFConverter(**kwargs)
Bases: AssetConverterBase
Converts mesh-based URDF files to MJCF format.
Handles geometry, materials, and asset copying.
Source code in embodied_gen/data/asset_converter.py
172 173 174 175 176 | |
add_geometry
add_geometry(mujoco_element: Element, link: Element, body: Element, tag: str, input_dir: str, output_dir: str, mesh_name: str, material: Element | None = None, is_collision: bool = False) -> None
Adds geometry to MJCF body from URDF link.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mujoco_element
|
Element
|
MJCF asset element. |
required |
link
|
Element
|
URDF link element. |
required |
body
|
Element
|
MJCF body element. |
required |
tag
|
str
|
Tag name ("visual" or "collision"). |
required |
input_dir
|
str
|
Input directory. |
required |
output_dir
|
str
|
Output directory. |
required |
mesh_name
|
str
|
Mesh name. |
required |
material
|
Element
|
Material element. |
None
|
is_collision
|
bool
|
If True, treat as collision geometry. |
False
|
Source code in embodied_gen/data/asset_converter.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
add_materials
add_materials(mujoco_element: Element, link: Element, tag: str, input_dir: str, output_dir: str, name: str, reflectance: float = 0.2) -> ET.Element
Adds materials to MJCF asset from URDF link.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mujoco_element
|
Element
|
MJCF asset element. |
required |
link
|
Element
|
URDF link element. |
required |
tag
|
str
|
Tag name. |
required |
input_dir
|
str
|
Input directory. |
required |
output_dir
|
str
|
Output directory. |
required |
name
|
str
|
Material name. |
required |
reflectance
|
float
|
Reflectance value. |
0.2
|
Returns:
| Type | Description |
|---|---|
Element
|
ET.Element: Material element. |
Source code in embodied_gen/data/asset_converter.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
convert
convert(urdf_path: str, mjcf_path: str)
Converts a URDF file to MJCF format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
urdf_path
|
str
|
Path to URDF file. |
required |
mjcf_path
|
str
|
Path to output MJCF file. |
required |
Source code in embodied_gen/data/asset_converter.py
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | |
MeshtoUSDConverter
MeshtoUSDConverter(force_usd_conversion: bool = True, make_instanceable: bool = False, simulation_app=None, **kwargs)
Bases: AssetConverterBase
Converts mesh-based URDF files to USD format.
Adds physics APIs and post-processes collision meshes.
Initializes the converter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force_usd_conversion
|
bool
|
Force USD conversion. |
True
|
make_instanceable
|
bool
|
Make prims instanceable. |
False
|
simulation_app
|
optional
|
Simulation app instance. |
None
|
**kwargs
|
Additional arguments. |
{}
|
Source code in embodied_gen/data/asset_converter.py
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | |
__enter__
__enter__()
Context manager entry, launches simulation app if needed.
Source code in embodied_gen/data/asset_converter.py
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 | |
__exit__
__exit__(exc_type, exc_val, exc_tb)
Context manager exit, closes simulation app if created.
Source code in embodied_gen/data/asset_converter.py
548 549 550 551 552 553 554 555 556 557 | |
convert
convert(urdf_path: str, output_file: str)
Converts a URDF file to USD and post-processes collision meshes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
urdf_path
|
str
|
Path to URDF file. |
required |
output_file
|
str
|
Path to output USD file. |
required |
Source code in embodied_gen/data/asset_converter.py
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 | |
PhysicsUSDAdder
PhysicsUSDAdder(force_usd_conversion: bool = True, make_instanceable: bool = False, simulation_app=None, **kwargs)
Bases: MeshtoUSDConverter
Adds physics APIs and collision properties to USD assets.
Useful for post-processing USD files for simulation.
Source code in embodied_gen/data/asset_converter.py
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | |
convert
convert(usd_path: str, output_file: str = None)
Adds physics APIs and collision properties to a USD file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
usd_path
|
str
|
Path to input USD file. |
required |
output_file
|
str
|
Path to output USD file. |
None
|
Source code in embodied_gen/data/asset_converter.py
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 | |
URDFtoMJCFConverter
URDFtoMJCFConverter(**kwargs)
Bases: MeshtoMJCFConverter
Converts URDF files with joints to MJCF format, handling joint transformations.
Handles fixed joints and hierarchical body structure.
Source code in embodied_gen/data/asset_converter.py
172 173 174 175 176 | |
convert
convert(urdf_path: str, mjcf_path: str, **kwargs) -> str
Converts a URDF file with joints to MJCF format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
urdf_path
|
str
|
Path to URDF file. |
required |
mjcf_path
|
str
|
Path to output MJCF file. |
required |
**kwargs
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Path to converted MJCF file. |
Source code in embodied_gen/data/asset_converter.py
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 | |
URDFtoUSDConverter
URDFtoUSDConverter(fix_base: bool = False, merge_fixed_joints: bool = False, make_instanceable: bool = True, force_usd_conversion: bool = True, collision_from_visuals: bool = True, joint_drive=None, rotate_wxyz: tuple[float] | None = None, simulation_app=None, **kwargs)
Bases: MeshtoUSDConverter
Converts URDF files to USD format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fix_base
|
bool
|
Fix the base link. |
False
|
merge_fixed_joints
|
bool
|
Merge fixed joints. |
False
|
make_instanceable
|
bool
|
Make prims instanceable. |
True
|
force_usd_conversion
|
bool
|
Force conversion to USD. |
True
|
collision_from_visuals
|
bool
|
Generate collisions from visuals. |
True
|
joint_drive
|
optional
|
Joint drive configuration. |
None
|
rotate_wxyz
|
tuple[float]
|
Quaternion for rotation. |
None
|
simulation_app
|
optional
|
Simulation app instance. |
None
|
**kwargs
|
Additional arguments. |
{}
|
Initializes the converter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fix_base
|
bool
|
Fix the base link. |
False
|
merge_fixed_joints
|
bool
|
Merge fixed joints. |
False
|
make_instanceable
|
bool
|
Make prims instanceable. |
True
|
force_usd_conversion
|
bool
|
Force conversion to USD. |
True
|
collision_from_visuals
|
bool
|
Generate collisions from visuals. |
True
|
joint_drive
|
optional
|
Joint drive configuration. |
None
|
rotate_wxyz
|
tuple[float]
|
Quaternion for rotation. |
None
|
simulation_app
|
optional
|
Simulation app instance. |
None
|
**kwargs
|
Additional arguments. |
{}
|
Source code in embodied_gen/data/asset_converter.py
730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 | |
convert
convert(urdf_path: str, output_file: str)
Converts a URDF file to USD and post-processes collision meshes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
urdf_path
|
str
|
Path to URDF file. |
required |
output_file
|
str
|
Path to output USD file. |
required |
Source code in embodied_gen/data/asset_converter.py
768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 | |
cvt_embodiedgen_asset_to_anysim
cvt_embodiedgen_asset_to_anysim(urdf_files: list[str], target_dirs: list[str], target_type: AssetType, source_type: AssetType, overwrite: bool = False, **kwargs) -> dict[str, str]
Convert URDF files generated by EmbodiedGen into formats required by simulators.
Supported simulators include SAPIEN, Isaac Sim, MuJoCo, Isaac Gym, Genesis, and Pybullet.
Converting to the USD format requires isaacsim to be installed.
Example
from embodied_gen.data.asset_converter import cvt_embodiedgen_asset_to_anysim
from embodied_gen.utils.enum import AssetType
dst_asset_path = cvt_embodiedgen_asset_to_anysim(
urdf_files=[
"path1_to_embodiedgen_asset/asset.urdf",
"path2_to_embodiedgen_asset/asset.urdf",
],
target_dirs=[
"path1_to_target_dir/asset.usd",
"path2_to_target_dir/asset.usd",
],
target_type=AssetType.USD,
source_type=AssetType.MESH,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
urdf_files
|
list[str]
|
List of URDF file paths. |
required |
target_dirs
|
list[str]
|
List of target directories. |
required |
target_type
|
AssetType
|
Target asset type. |
required |
source_type
|
AssetType
|
Source asset type. |
required |
overwrite
|
bool
|
Overwrite existing files. |
False
|
**kwargs
|
Additional converter arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
dict[str, str]: Mapping from URDF file to converted asset file. |
Source code in embodied_gen/data/asset_converter.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
embodied_gen.data.datasets
PanoGSplatDataset
PanoGSplatDataset(data_dir: str, split: str = Literal['train', 'eval'], data_name: str = 'gs_data.pt', max_sample_num: int = None)
Bases: Dataset
A PyTorch Dataset for loading panorama-based 3D Gaussian Splatting data.
This dataset is designed to be compatible with train and eval pipelines that use COLMAP-style camera conventions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_dir
|
str
|
Root directory where the dataset file is located. |
required |
split
|
str
|
Dataset split to use, either "train" or "eval". |
Literal['train', 'eval']
|
data_name
|
str
|
Name of the dataset file (default: "gs_data.pt"). |
'gs_data.pt'
|
max_sample_num
|
int
|
Maximum number of samples to load. If None, all available samples in the split will be used. |
None
|
Source code in embodied_gen/data/datasets.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
embodied_gen.data.differentiable_render
ImageRender
ImageRender(render_items: list[RenderItems], camera_params: CameraSetting, recompute_vtx_normal: bool = True, with_mtl: bool = False, gen_color_gif: bool = False, gen_color_mp4: bool = False, gen_viewnormal_mp4: bool = False, gen_glonormal_mp4: bool = False, no_index_file: bool = False, light_factor: float = 1.0)
Bases: object
Differentiable mesh renderer supporting multi-view rendering.
This class wraps differentiable rasterization using nvdiffrast to render mesh
geometry to various maps (normal, depth, alpha, albedo, etc.) and supports
saving images and videos.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
render_items
|
list[RenderItems]
|
List of rendering targets. |
required |
camera_params
|
CameraSetting
|
Camera parameters for rendering. |
required |
recompute_vtx_normal
|
bool
|
Recompute vertex normals. Defaults to True. |
True
|
with_mtl
|
bool
|
Load mesh material files. Defaults to False. |
False
|
gen_color_gif
|
bool
|
Generate GIF of color images. Defaults to False. |
False
|
gen_color_mp4
|
bool
|
Generate MP4 of color images. Defaults to False. |
False
|
gen_viewnormal_mp4
|
bool
|
Generate MP4 of view-space normals. Defaults to False. |
False
|
gen_glonormal_mp4
|
bool
|
Generate MP4 of global-space normals. Defaults to False. |
False
|
no_index_file
|
bool
|
Skip saving index file. Defaults to False. |
False
|
light_factor
|
float
|
PBR light intensity multiplier. Defaults to 1.0. |
1.0
|
Example
from embodied_gen.data.differentiable_render import ImageRender
from embodied_gen.data.utils import CameraSetting
from embodied_gen.utils.enum import RenderItems
camera_params = CameraSetting(
num_images=6,
elevation=[20, -10],
distance=5,
resolution_hw=(512,512),
fov=math.radians(30),
device='cuda',
)
render_items = [RenderItems.IMAGE.value, RenderItems.DEPTH.value]
renderer = ImageRender(
render_items,
camera_params,
with_mtl=args.with_mtl,
gen_color_mp4=True,
)
renderer.render_mesh(mesh_path='mesh.obj', output_root='./renders')
Source code in embodied_gen/data/differentiable_render.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
__call__
__call__(mesh_path: str, output_dir: str, prompt: str = None) -> dict[str, str]
Renders a single mesh and returns output paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh_path
|
str
|
Path to mesh file. |
required |
output_dir
|
str
|
Directory to save outputs. |
required |
prompt
|
str
|
Caption prompt for MP4 metadata. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
dict[str, str]: Mapping of render types to saved image paths. |
Source code in embodied_gen/data/differentiable_render.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | |
render_mesh
render_mesh(mesh_path: Union[str, List[str]], output_root: str, uuid: Union[str, List[str]] = None, prompts: List[str] = None) -> None
Renders one or more meshes and saves outputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh_path
|
Union[str, List[str]]
|
Path(s) to mesh files. |
required |
output_root
|
str
|
Directory to save outputs. |
required |
uuid
|
Union[str, List[str]]
|
Unique IDs for outputs. |
None
|
prompts
|
List[str]
|
Text prompts for videos. |
None
|
Source code in embodied_gen/data/differentiable_render.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
create_gif_from_images
create_gif_from_images(images: list[ndarray], output_path: str, fps: int = 10) -> None
Creates a GIF animation from a list of images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images
|
list[ndarray]
|
List of images as numpy arrays. |
required |
output_path
|
str
|
Path to save the GIF file. |
required |
fps
|
int
|
Frames per second. Defaults to 10. |
10
|
Source code in embodied_gen/data/differentiable_render.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
create_mp4_from_images
create_mp4_from_images(images: list[ndarray], output_path: str, fps: int = 10, prompt: str = None)
Creates an MP4 video from a list of images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images
|
list[ndarray]
|
List of images as numpy arrays. |
required |
output_path
|
str
|
Path to save the MP4 file. |
required |
fps
|
int
|
Frames per second. Defaults to 10. |
10
|
prompt
|
str
|
Optional text prompt overlay. |
None
|
Source code in embodied_gen/data/differentiable_render.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
embodied_gen.data.mesh_operator
MeshFixer
MeshFixer(vertices: Union[Tensor, ndarray], faces: Union[Tensor, ndarray], device: str = 'cuda')
Bases: object
MeshFixer simplifies and repairs 3D triangle meshes by TSDF.
Attributes:
| Name | Type | Description |
|---|---|---|
vertices |
Tensor
|
A tensor of shape (V, 3) representing vertex positions. |
faces |
Tensor
|
A tensor of shape (F, 3) representing face indices. |
device |
str
|
Device to run computations on, typically "cuda" or "cpu". |
Main logic reference: https://github.com/microsoft/TRELLIS/blob/main/trellis/utils/postprocessing_utils.py#L22
Source code in embodied_gen/data/mesh_operator.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
__call__
__call__(filter_ratio: float, max_hole_size: float, resolution: int, num_views: int, norm_mesh_ratio: float = 1.0) -> Tuple[np.ndarray, np.ndarray]
Post-process the mesh by simplifying and filling holes.
This method performs a two-step process: 1. Simplifies mesh by reducing faces using quadric edge decimation. 2. Fills holes by removing invisible faces, repairing small boundaries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter_ratio
|
float
|
Ratio of faces to simplify out. Must be in the range (0, 1). |
required |
max_hole_size
|
float
|
Maximum area of a hole to fill. Connected components of holes larger than this size will not be repaired. |
required |
resolution
|
int
|
Resolution of the rasterization buffer. |
required |
num_views
|
int
|
Number of viewpoints to sample for rasterization. |
required |
norm_mesh_ratio
|
float
|
A scaling factor applied to the vertices of the mesh during processing. |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[ndarray, ndarray]
|
Tuple[np.ndarray, np.ndarray]: - vertices: Simplified and repaired vertex array of (V, 3). - faces: Simplified and repaired face array of (F, 3). |
Source code in embodied_gen/data/mesh_operator.py
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | |
simplify
simplify(ratio: float) -> None
Simplify the mesh using quadric edge collapse decimation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ratio
|
float
|
Ratio of faces to filter out. |
required |
Source code in embodied_gen/data/mesh_operator.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
embodied_gen.data.backproject_v2
TextureBacker
TextureBacker(camera_params: CameraSetting, view_weights: list[float], render_wh: tuple[int, int] = (2048, 2048), texture_wh: tuple[int, int] = (2048, 2048), bake_angle_thresh: int = 75, mask_thresh: float = 0.5, smooth_texture: bool = True, inpaint_smooth: bool = False)
Texture baking pipeline for multi-view projection and fusion.
This class generates UV-based textures for a 3D mesh using multi-view images, depth, and normal information. It includes mesh normalization, UV unwrapping, visibility-aware back-projection, confidence-weighted fusion, and inpainting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
camera_params
|
CameraSetting
|
Camera intrinsics and extrinsics. |
required |
view_weights
|
list[float]
|
Weights for each view in texture fusion. |
required |
render_wh
|
tuple[int, int]
|
Intermediate rendering resolution. |
(2048, 2048)
|
texture_wh
|
tuple[int, int]
|
Output texture resolution. |
(2048, 2048)
|
bake_angle_thresh
|
int
|
Max angle for valid projection. |
75
|
mask_thresh
|
float
|
Threshold for visibility masks. |
0.5
|
smooth_texture
|
bool
|
Apply post-processing to texture. |
True
|
inpaint_smooth
|
bool
|
Apply inpainting smoothing. |
False
|
Example
from embodied_gen.data.backproject_v2 import TextureBacker
from embodied_gen.data.utils import CameraSetting
import trimesh
from PIL import Image
camera_params = CameraSetting(
num_images=6,
elevation=[20, -10],
distance=5,
resolution_hw=(2048,2048),
fov=math.radians(30),
device='cuda',
)
view_weights = [1, 0.1, 0.02, 0.1, 1, 0.02]
mesh = trimesh.load('mesh.obj')
images = [Image.open(f'view_{i}.png') for i in range(6)]
texture_backer = TextureBacker(camera_params, view_weights)
textured_mesh = texture_backer(images, mesh, 'output.obj')
Source code in embodied_gen/data/backproject_v2.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
__call__
__call__(colors: list[Image], mesh: Trimesh, output_path: str) -> trimesh.Trimesh
Runs the texture baking and exports the textured mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colors
|
list[Image]
|
List of input view images. |
required |
mesh
|
Trimesh
|
Input mesh to be textured. |
required |
output_path
|
str
|
Path to save the output textured mesh. |
required |
Returns:
| Type | Description |
|---|---|
Trimesh
|
trimesh.Trimesh: The textured mesh with UV and texture image. |
Source code in embodied_gen/data/backproject_v2.py
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 | |
back_project
back_project(image, vis_mask, depth, normal, uv) -> tuple[torch.Tensor, torch.Tensor]
Back-projects image and confidence to UV texture space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Image or ndarray
|
Input image. |
required |
vis_mask
|
Tensor
|
Visibility mask. |
required |
depth
|
Tensor
|
Depth map. |
required |
normal
|
Tensor
|
Normal map. |
required |
uv
|
Tensor
|
UV coordinates. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Tensor, Tensor]
|
tuple[torch.Tensor, torch.Tensor]: Texture and confidence map. |
Source code in embodied_gen/data/backproject_v2.py
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | |
compute_enhanced_viewnormal
compute_enhanced_viewnormal(mv_mtx: Tensor, vertices: Tensor, faces: Tensor) -> torch.Tensor
Computes enhanced view normals for mesh faces.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv_mtx
|
Tensor
|
View matrices. |
required |
vertices
|
Tensor
|
Mesh vertices. |
required |
faces
|
Tensor
|
Mesh faces. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: View normals. |
Source code in embodied_gen/data/backproject_v2.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | |
compute_texture
compute_texture(colors: list[Image], mesh: Trimesh) -> trimesh.Trimesh
Computes the fused texture for the mesh from multi-view images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colors
|
list[Image]
|
List of view images. |
required |
mesh
|
Trimesh
|
Mesh to texture. |
required |
Returns:
| Type | Description |
|---|---|
Trimesh
|
tuple[np.ndarray, np.ndarray]: Texture and mask. |
Source code in embodied_gen/data/backproject_v2.py
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 | |
fast_bake_texture
fast_bake_texture(textures: list[Tensor], confidence_maps: list[Tensor]) -> tuple[torch.Tensor, torch.Tensor]
Fuses multiple textures and confidence maps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
textures
|
list[Tensor]
|
List of textures. |
required |
confidence_maps
|
list[Tensor]
|
List of confidence maps. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Tensor, Tensor]
|
tuple[torch.Tensor, torch.Tensor]: Fused texture and mask. |
Source code in embodied_gen/data/backproject_v2.py
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 | |
get_mesh_np_attrs
get_mesh_np_attrs(mesh: Trimesh, scale: float = None, center: ndarray = None) -> tuple[np.ndarray, np.ndarray, np.ndarray]
Gets mesh attributes as numpy arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Trimesh
|
Input mesh. |
required |
scale
|
float
|
Scale factor. |
None
|
center
|
ndarray
|
Center offset. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[ndarray, ndarray, ndarray]
|
(vertices, faces, uv_map) |
Source code in embodied_gen/data/backproject_v2.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | |
load_mesh
load_mesh(mesh: Trimesh) -> trimesh.Trimesh
Normalizes mesh and unwraps UVs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Trimesh
|
Input mesh. |
required |
Returns:
| Type | Description |
|---|---|
Trimesh
|
trimesh.Trimesh: Mesh with normalized vertices and UVs. |
Source code in embodied_gen/data/backproject_v2.py
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | |
uv_inpaint
uv_inpaint(mesh: Trimesh, texture: ndarray, mask: ndarray) -> np.ndarray
Inpaints missing regions in the UV texture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Trimesh
|
Mesh. |
required |
texture
|
ndarray
|
Texture image. |
required |
mask
|
ndarray
|
Mask image. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Inpainted texture. |
Source code in embodied_gen/data/backproject_v2.py
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | |
entrypoint
entrypoint(delight_model: DelightingModel = None, imagesr_model: ImageRealESRGAN = None, **kwargs) -> trimesh.Trimesh
Entrypoint for texture backprojection from multi-view images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
delight_model
|
DelightingModel
|
Delighting model. |
None
|
imagesr_model
|
ImageRealESRGAN
|
Super-resolution model. |
None
|
**kwargs
|
Additional arguments to override CLI. |
{}
|
Returns:
| Type | Description |
|---|---|
Trimesh
|
trimesh.Trimesh: Textured mesh. |
Source code in embodied_gen/data/backproject_v2.py
774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 | |
parse_args
parse_args()
Parses command-line arguments for texture backprojection.
Returns:
| Type | Description |
|---|---|
|
argparse.Namespace: Parsed arguments. |
Source code in embodied_gen/data/backproject_v2.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 | |
embodied_gen.data.convex_decomposer
decompose_convex_coacd
decompose_convex_coacd(filename: str, outfile: str, params: dict, verbose: bool = False, auto_scale: bool = True, scale_factor: float = 1.0) -> None
Decomposes a mesh using CoACD and saves the result.
This function loads a mesh from a file, runs the CoACD algorithm with the given parameters, optionally scales the resulting convex hulls to match the original mesh's bounding box, and exports the combined result to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the input mesh file. |
required |
outfile
|
str
|
Path to save the decomposed output mesh. |
required |
params
|
dict
|
A dictionary of parameters for the CoACD algorithm. |
required |
verbose
|
bool
|
If True, sets the CoACD log level to 'info'. |
False
|
auto_scale
|
bool
|
If True, automatically computes a scale factor to match the decomposed mesh's bounding box to the visual mesh's bounding box. |
True
|
scale_factor
|
float
|
An additional scaling factor applied to the vertices of the decomposed mesh parts. |
1.0
|
Source code in embodied_gen/data/convex_decomposer.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
decompose_convex_mesh
decompose_convex_mesh(filename: str, outfile: str, threshold: float = 0.05, max_convex_hull: int = -1, preprocess_mode: str = 'auto', preprocess_resolution: int = 30, resolution: int = 2000, mcts_nodes: int = 20, mcts_iterations: int = 150, mcts_max_depth: int = 3, pca: bool = False, merge: bool = True, seed: int = 0, auto_scale: bool = True, scale_factor: float = 1.005, verbose: bool = False) -> str
Decomposes a mesh into convex parts with retry logic.
This function serves as a wrapper for decompose_convex_coacd, providing
explicit parameters for the CoACD algorithm and implementing a retry
mechanism. If the initial decomposition fails, it attempts again with
preprocess_mode set to 'on'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the input mesh file. |
required |
outfile
|
str
|
Path to save the decomposed output mesh. |
required |
threshold
|
float
|
CoACD parameter. See CoACD documentation for details. |
0.05
|
max_convex_hull
|
int
|
CoACD parameter. See CoACD documentation for details. |
-1
|
preprocess_mode
|
str
|
CoACD parameter. See CoACD documentation for details. |
'auto'
|
preprocess_resolution
|
int
|
CoACD parameter. See CoACD documentation for details. |
30
|
resolution
|
int
|
CoACD parameter. See CoACD documentation for details. |
2000
|
mcts_nodes
|
int
|
CoACD parameter. See CoACD documentation for details. |
20
|
mcts_iterations
|
int
|
CoACD parameter. See CoACD documentation for details. |
150
|
mcts_max_depth
|
int
|
CoACD parameter. See CoACD documentation for details. |
3
|
pca
|
bool
|
CoACD parameter. See CoACD documentation for details. |
False
|
merge
|
bool
|
CoACD parameter. See CoACD documentation for details. |
True
|
seed
|
int
|
CoACD parameter. See CoACD documentation for details. |
0
|
auto_scale
|
bool
|
If True, automatically scale the output to match the input bounding box. |
True
|
scale_factor
|
float
|
Additional scaling factor to apply. |
1.005
|
verbose
|
bool
|
If True, enables detailed logging. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The path to the output file if decomposition is successful. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If convex decomposition fails after all attempts. |
Source code in embodied_gen/data/convex_decomposer.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
decompose_convex_mp
decompose_convex_mp(filename: str, outfile: str, threshold: float = 0.05, max_convex_hull: int = -1, preprocess_mode: str = 'auto', preprocess_resolution: int = 30, resolution: int = 2000, mcts_nodes: int = 20, mcts_iterations: int = 150, mcts_max_depth: int = 3, pca: bool = False, merge: bool = True, seed: int = 0, verbose: bool = False, auto_scale: bool = True) -> str
Decomposes a mesh into convex parts in a separate process.
This function uses the multiprocessing module to run the CoACD algorithm
in a spawned subprocess. This is useful for isolating the decomposition
process to prevent potential memory leaks or crashes in the main process.
It includes a retry mechanism similar to decompose_convex_mesh.
See https://simulately.wiki/docs/toolkits/ConvexDecomp for details.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the input mesh file. |
required |
outfile
|
str
|
Path to save the decomposed output mesh. |
required |
threshold
|
float
|
CoACD parameter. |
0.05
|
max_convex_hull
|
int
|
CoACD parameter. |
-1
|
preprocess_mode
|
str
|
CoACD parameter. |
'auto'
|
preprocess_resolution
|
int
|
CoACD parameter. |
30
|
resolution
|
int
|
CoACD parameter. |
2000
|
mcts_nodes
|
int
|
CoACD parameter. |
20
|
mcts_iterations
|
int
|
CoACD parameter. |
150
|
mcts_max_depth
|
int
|
CoACD parameter. |
3
|
pca
|
bool
|
CoACD parameter. |
False
|
merge
|
bool
|
CoACD parameter. |
True
|
seed
|
int
|
CoACD parameter. |
0
|
verbose
|
bool
|
If True, enables detailed logging in the subprocess. |
False
|
auto_scale
|
bool
|
If True, automatically scale the output. |
True
|
Returns:
| Type | Description |
|---|---|
str
|
The path to the output file if decomposition is successful. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If convex decomposition fails after all attempts. |
Source code in embodied_gen/data/convex_decomposer.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |