-
Notifications
You must be signed in to change notification settings - Fork 15
sim-ready pipeline #271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
sim-ready pipeline #271
Changes from 8 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
14699c1
first version of sim_ready
XuanchaoPENG 06de01b
clean code
XuanchaoPENG 6148c21
clean code
XuanchaoPENG d44696b
Merge branch 'main' into xuanchao/sim_ready
yuecideng 8624b49
add bake and remesh
XuanchaoPENG d57e0ae
fix review bugs
XuanchaoPENG 9b8409d
change decimate_ratio to keep robust
XuanchaoPENG 0514d2f
run black command
XuanchaoPENG 11630e2
updata sim_ready config/create intro/update install config
XuanchaoPENG 856d071
add sim_ready pipeline
XuanchaoPENG ce0b37a
translate chinese to english
XuanchaoPENG 0cac1ca
add cli commands
XuanchaoPENG 8a40566
Merge branch 'main' into xuanchao/sim_ready
XuanchaoPENG f1afa96
run black command
XuanchaoPENG c66bd8b
Merge branch 'xuanchao/sim_ready' of github.com:DexForce/EmbodiChain …
XuanchaoPENG babb897
update bpy and pyrender install
XuanchaoPENG 3c0d7c8
move simready from toolkit to gensim and update relative docs
XuanchaoPENG 2c97592
delete bpy test
XuanchaoPENG 07ee920
add openai compatible api support and update the related docs and upd…
XuanchaoPENG 41f0019
refine the params in doc and api format
XuanchaoPENG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # ---------------------------------------------------------------------------- | ||
| # Copyright (c) 2021-2026 DexForce Technology Co., Ltd. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # ---------------------------------------------------------------------------- | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| __all__: list[str] = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # ---------------------------------------------------------------------------- | ||
| # Copyright (c) 2021-2026 DexForce Technology Co., Ltd. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # ---------------------------------------------------------------------------- | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| __all__: list[str] = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # ---------------------------------------------------------------------------- | ||
| # Copyright (c) 2021-2026 DexForce Technology Co., Ltd. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # ---------------------------------------------------------------------------- | ||
|
|
||
| import argparse | ||
| from pathlib import Path | ||
| import os | ||
|
|
||
| os.environ["PYOPENGL_PLATFORM"] = "egl" | ||
|
|
||
| from embodichain.toolkits.simready_pipeline.pipeline.ingest import ingest_one_asset | ||
| from embodichain.toolkits.simready_pipeline.io.json_store import JsonStore | ||
| from embodichain.toolkits.simready_pipeline.parser.base import ParserManager | ||
|
|
||
|
|
||
| def cli_ingest_single( | ||
| input_dir: str, output_dir: str, category: str, simple_ingest: bool | ||
| ): | ||
| input_path = Path(input_dir) | ||
| output_path = Path(output_dir) | ||
|
|
||
| if not input_path.exists(): | ||
| raise FileNotFoundError(f"Input directory not found: {input_path}") | ||
|
|
||
| output_path.mkdir(parents=True, exist_ok=True) | ||
| store = JsonStore(output_path) | ||
| manager = ParserManager() | ||
|
|
||
| print(f"Processing Single Asset: {input_path.name} (Category: {category})") | ||
|
|
||
| asset = ingest_one_asset( | ||
| asset_dir=input_path, | ||
| category=category, | ||
| output_root=output_path, | ||
| store=store, | ||
| manager=manager, | ||
| simple_ingest=simple_ingest, | ||
| ) | ||
|
|
||
| if asset: | ||
| print(f"Successfully Processed") | ||
| else: | ||
| print("no asset returned (might be direct_copy mode)") | ||
|
|
||
|
|
||
| def main(): | ||
| parser = argparse.ArgumentParser( | ||
| description="embodichain.toolkits.simready_pipeline Asset Ingestion Pipeline" | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "--input_dir", type=str, help="Path to the single asset directory" | ||
| ) | ||
| parser.add_argument("--output_root", type=str, help="Path to the output directory") | ||
| parser.add_argument( | ||
| "--category", | ||
| type=str, | ||
| required=True, | ||
| help="Specify the category for this asset (e.g., 'cup', 'chair')", | ||
| ) | ||
| parser.add_argument( | ||
| "--simple", action="store_true", help="trimesh only, skip Blender" | ||
| ) | ||
|
|
||
| args = parser.parse_args() | ||
|
|
||
| cli_ingest_single( | ||
| args.input_dir, args.output_root, args.category, simple_ingest=args.simple | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
19 changes: 19 additions & 0 deletions
19
embodichain/toolkits/simready_pipeline/configs/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # ---------------------------------------------------------------------------- | ||
| # Copyright (c) 2021-2026 DexForce Technology Co., Ltd. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # ---------------------------------------------------------------------------- | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| __all__: list[str] = [] |
28 changes: 28 additions & 0 deletions
28
embodichain/toolkits/simready_pipeline/configs/gen_config.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| { | ||
| "ingest": { | ||
| "canonical_asset_name": "asset.obj", | ||
| "unprocessed_formats": [".urdf", ".usd"], | ||
| "parseable_mesh_formats": [".glb", ".gltf", ".obj", ".ply", ".stl"], | ||
| "blender_texture_size": 2048, | ||
| "blender_texture_name": "surface_texture.png", | ||
| "blender_remesh_bake": { | ||
| "voxel_size": 0.01, | ||
| "decimate_ratio": 0.9 | ||
| } | ||
| }, | ||
| "geometry_cleanup": { | ||
| "ratio": 0.5, | ||
| "weld_distance": 0.0001, | ||
| "merge_dist": 0.00001, | ||
| "remove_non_manifold": true, | ||
| "triangulate": false | ||
| }, | ||
| "llm": { | ||
| "azure_openai": { | ||
| "api_key": "", | ||
| "model": "gpt-4o", | ||
| "base_url": "", | ||
| "api_version": "2024-02-15-preview" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # ---------------------------------------------------------------------------- | ||
| # Copyright (c) 2021-2026 DexForce Technology Co., Ltd. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # ---------------------------------------------------------------------------- | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| __all__: list[str] = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # ---------------------------------------------------------------------------- | ||
| # Copyright (c) 2021-2026 DexForce Technology Co., Ltd. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # ---------------------------------------------------------------------------- | ||
|
|
||
| from dataclasses import dataclass, field | ||
| from typing import Any, Dict, List, Optional | ||
| from datetime import datetime | ||
|
|
||
|
|
||
| @dataclass | ||
| class Asset: | ||
|
|
||
| asset_id: str | ||
|
|
||
| identity: Dict[str, Any] = field(default_factory=dict) | ||
| asset_data: Dict[str, Any] = field(default_factory=dict) | ||
|
|
||
| parsed: Dict[str, Any] = field( | ||
| default_factory=dict | ||
| ) # Visual, Geometry, Topology, 等解析或者入库时而来的信息 | ||
| semantics: Dict[str, Any] = field(default_factory=dict) | ||
| physics: Dict[str, Any] = field(default_factory=dict) | ||
| simulation: Dict[str, Any] = field(default_factory=dict) | ||
| affordance: Dict[str, Any] = field(default_factory=dict) | ||
| usd: Dict[str, Any] = field(default_factory=dict) | ||
|
|
||
| provenance: Dict[str, Any] = field(default_factory=dict) | ||
| quality: Dict[str, Any] = field(default_factory=dict) | ||
| status: Dict[str, Any] = field(default_factory=dict) | ||
| internal: Dict[str, Any] = field(default_factory=dict) | ||
|
|
||
| ingest_info: Dict[str, Any] = field(default_factory=dict) # ingest相关的临时信息 | ||
|
|
||
| def __post_init__(self) -> None: | ||
| self._init_simulation_defaults() | ||
| self.touch() | ||
|
|
||
| def _init_simulation_defaults(self) -> None: | ||
| self.simulation.setdefault("articulation", None) | ||
| self.simulation.setdefault("sim_ready", {}) | ||
|
|
||
| def touch(self) -> None: | ||
| self.status["last_updated"] = datetime.now().isoformat() | ||
|
|
||
| def to_dict(self) -> Dict[str, Any]: | ||
| return { | ||
| "asset_id": self.asset_id, | ||
| "identity": self.identity, | ||
| "asset_data": self.asset_data, | ||
| "parsed": self.parsed, | ||
| "quality": self.quality, | ||
| "semantics": self.semantics, | ||
| "physics": self.physics, | ||
| "simulation": self.simulation, | ||
| "usd": self.usd, | ||
| "provenance": self.provenance, | ||
| "status": self.status, | ||
| "internal": self.internal, | ||
| "affordance": self.affordance, | ||
| } | ||
|
|
||
| @classmethod | ||
| def from_dict(cls, data: Dict[str, Any]) -> "Asset": | ||
| return cls( | ||
| asset_id=data["asset_id"], | ||
| identity=data.get("identity", {}), | ||
| asset_data=data.get("asset_data", []), | ||
| parsed=data.get("parsed", {}), | ||
| quality=data.get("quality", {}), | ||
| semantics=data.get("semantics", {}), | ||
| physics=data.get("physics", {}), | ||
| simulation=data.get("simulation", {}), | ||
| usd=data.get("usd", {}), | ||
| provenance=data.get("provenance", {}), | ||
| status=data.get("status", {}), | ||
| internal=data.get("internal", {}), | ||
| affordance=data.get("affordance", {}), | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # ---------------------------------------------------------------------------- | ||
| # Copyright (c) 2021-2026 DexForce Technology Co., Ltd. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # ---------------------------------------------------------------------------- | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| __all__: list[str] = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| # ---------------------------------------------------------------------------- | ||
| # Copyright (c) 2021-2026 DexForce Technology Co., Ltd. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # ---------------------------------------------------------------------------- | ||
|
|
||
| import json | ||
| from pathlib import Path | ||
| from typing import Any, Optional | ||
|
|
||
| from embodichain.toolkits.simready_pipeline.core.asset import Asset | ||
|
|
||
|
|
||
| class JsonStore: | ||
| """ | ||
| Simple JSON-based store for Assets and a global registry. | ||
| """ | ||
|
|
||
| def __init__(self, root_dir: str | Path): | ||
| self.root = Path(root_dir) | ||
| self.registry_path = self.root / "registry.json" | ||
|
|
||
| def _get_asset_json_path(self, asset_id: str) -> Path: | ||
| return self.root / asset_id / "asset.json" | ||
|
|
||
| def load_registry(self) -> dict[str, Any]: | ||
| if not self.registry_path.exists(): | ||
| return {"assets": {}} | ||
|
|
||
| registry = json.loads(self.registry_path.read_text()) | ||
| registry.setdefault("assets", {}) | ||
| return registry | ||
|
|
||
| def _write_registry(self, registry: dict[str, Any]) -> None: | ||
| self.registry_path.parent.mkdir(parents=True, exist_ok=True) | ||
| self.registry_path.write_text(json.dumps(registry, indent=2)) | ||
|
|
||
| def _register_asset(self, asset_id: str, asset_json: dict[str, Any]) -> None: | ||
| registry = self.load_registry() | ||
| registry["assets"][asset_id] = { | ||
| "path": str(self.root / asset_id), | ||
| "category": asset_json.get("identity", {}).get("category"), | ||
| } | ||
| self._write_registry(registry) | ||
|
|
||
| def save_asset(self, asset: Asset) -> None: | ||
| asset_path = self._get_asset_json_path(asset.asset_id) | ||
| asset_path.parent.mkdir(parents=True, exist_ok=True) | ||
| asset_json = asset.to_dict() | ||
| asset_path.write_text(json.dumps(asset_json, indent=2)) | ||
| self._register_asset(asset.asset_id, asset_json) | ||
|
|
||
| def load_asset(self, asset_id: str) -> Optional[Asset]: | ||
| asset_path = self._get_asset_json_path(asset_id) | ||
| if not asset_path.exists(): | ||
| return None | ||
| data = json.loads(asset_path.read_text()) | ||
| return Asset.from_dict(data) | ||
|
|
||
| def write_asset(self, asset_id: str, asset_json: dict[str, Any]) -> None: | ||
| asset_root = self.root / asset_id | ||
| asset_root.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| asset_path = asset_root / "asset.json" | ||
| asset_path.write_text(json.dumps(asset_json, indent=2)) | ||
| self._register_asset(asset_id, asset_json) | ||
|
|
||
| def list_asset_ids(self) -> list[str]: | ||
| registry = self.load_registry() | ||
| return list(registry.get("assets", {}).keys()) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Translate all the Chinese into English