-
Notifications
You must be signed in to change notification settings - Fork 20
Add scene engine pipeline #436
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
Open
MuziWong
wants to merge
25
commits into
main
Choose a base branch
from
muzi/feat_scene_engine
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
61001a7
Add a new feature: gen_sim/scene_engine
MuziWong ad708e8
Using vhacd by default in the simulation environment
MuziWong b664562
RAN black
MuziWong fe6c1af
style(geometry-generation): fix CI formatting
MuziWong 4c0cfc7
Updated geometry generation client
MuziWong a67ac77
Modified the gym export to scene export
MuziWong c630f16
Make the 2D AABB optimization more robust
MuziWong 8ae888d
Add optional --config in cli
MuziWong c38c0fc
Register scene-engine and preview-scene in embodichain.__main__.COMMANDS
MuziWong b86c3b5
Fixed with the suggestion from Copilot
MuziWong c99182c
Added __init__.py and ran black.
MuziWong e7f3fbe
Merge branch 'main' of github.com:DexForce/EmbodiChain into muzi/feat…
XuanchaoPENG 79442f5
Fix import bug
MuziWong a0f6797
Add Viser support
XuanchaoPENG db438e7
Merge branch 'muzi/feat_scene_engine' of github.com:DexForce/EmbodiCh…
XuanchaoPENG d1b363a
test(scene_engine): add unit coverage
MuziWong 23947e5
Add test for the newly-modified scene-preview
MuziWong b0774a4
docs(scene_engine): add usage documentation
MuziWong ede8172
Change logger
MuziWong 73e285e
Correct the table id verification comment, make it more clear
MuziWong 244ab1b
Delete a bad comment line in scene_segmentation_utils.py
MuziWong 930af9b
Align the doc with the scene_engine_config
MuziWong 05f8a1a
Align the scene_engine config setup with the simready_pipeline
MuziWong d0d39ca
fix(scene_engine): validate geometry output object IDs
MuziWong 114734d
fix(scene_engine): restrict preview mesh paths
MuziWong 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
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,156 @@ | ||
| # Scene Engine | ||
|
|
||
| The Scene Engine converts one tabletop-scene image into a scene-only export. It | ||
| identifies a table and visible assets, generates their meshes, refines their | ||
| layout, settles them under gravity, and writes an EmbodiChain scene export. | ||
|
|
||
| ## Quick Start | ||
|
|
||
| Install EmbodiChain with the generative-simulation dependencies. See | ||
| [Installation (gensim extra)](../../quick_start/install.md#optional-generative-simulation-gensim). | ||
|
|
||
| Prepare a Scene Engine JSON config, then run: | ||
|
|
||
| ```bash | ||
| embodichain scene-engine \ | ||
| --image /path/to/scene.png \ | ||
| --output_root /path/to/scene_output \ | ||
| --config /path/to/scene_engine_config.json | ||
| ``` | ||
|
|
||
| Preview the result: | ||
|
|
||
| ```bash | ||
| embodichain preview-scene --output_root /path/to/scene_output | ||
| ``` | ||
|
|
||
| Use `--viser` for a browser-based preview, or `--headless` to validate the | ||
| export without opening a window: | ||
|
|
||
| ```bash | ||
| embodichain preview-scene \ | ||
| --output_root /path/to/scene_output \ | ||
| --viser | ||
| ``` | ||
|
|
||
| The equivalent module commands are: | ||
|
|
||
| ```bash | ||
| python -m embodichain.gen_sim.scene_engine.cli.start --help | ||
| python -m embodichain.gen_sim.scene_engine.cli.preview --help | ||
| ``` | ||
|
|
||
| ## Requirements and Configuration | ||
|
|
||
| The input must be one `.jpg`, `.jpeg`, or `.png` image with one main table and | ||
| visible, separate tabletop assets. The pipeline requires an OpenAI-compatible | ||
| VLM, an image-segmentation service, and a geometry-generation service. | ||
|
|
||
| Without `--config`, Scene Engine reads the official template at | ||
| `embodichain/gen_sim/scene_engine/configs/scene_engine_config.json`. The | ||
| checked-in template intentionally has empty service URLs and credentials. | ||
| Provide a complete user-owned JSON file with `--config`, or provide the | ||
| settings through environment variables. `--config` is an optional complete | ||
| JSON override; do not add credentials to the checked-in template. | ||
|
|
||
| Keep credentials outside version control. `OPENAI_API_KEY`, `OPENAI_MODEL`, | ||
| `OPENAI_BASE_URL`, and `OPENAI_MAX_ATTEMPTS` override the corresponding LLM | ||
| settings. For example: | ||
|
|
||
| ```bash | ||
| export OPENAI_API_KEY="<api-key>" | ||
| export OPENAI_MODEL="<vision-model>" | ||
| export OPENAI_BASE_URL="https://example.com/v1" | ||
| export OPENAI_MAX_ATTEMPTS="3" | ||
|
|
||
| export SCENE_ENGINE_IMAGE_SEGMENTATION_BASE_URL="http://segmentation-host:port" | ||
| export SCENE_ENGINE_IMAGE_SEGMENTATION_PATH="/predict" | ||
| export SCENE_ENGINE_GEOMETRY_GENERATION_BASE_URL="http://geometry-host:port" | ||
| export SCENE_ENGINE_GEOMETRY_GENERATION_PATH="/generate_multiple_objects" | ||
| ``` | ||
|
|
||
| `SCENE_ENGINE_IMAGE_SEGMENTATION_TIMEOUT_S`, | ||
| `SCENE_ENGINE_IMAGE_SEGMENTATION_MAX_ATTEMPTS`, | ||
| `SCENE_ENGINE_IMAGE_SEGMENTATION_HEALTH_PATH`, | ||
| `SCENE_ENGINE_GEOMETRY_GENERATION_TIMEOUT_S`, | ||
| `SCENE_ENGINE_GEOMETRY_GENERATION_MAX_ATTEMPTS`, and | ||
| `SCENE_ENGINE_GEOMETRY_GENERATION_HEALTH_PATH` override the remaining service | ||
| fields when needed. | ||
|
|
||
| ```json | ||
| { | ||
| "llm": { | ||
| "openai_compatible": { | ||
| "api_key": "<api-key>", | ||
| "model": "<vision-model>", | ||
| "base_url": "https://example.com/v1", | ||
| "default_query": {}, | ||
| "max_attempts": 3 | ||
| } | ||
| }, | ||
| "image_segmentation": { | ||
| "base_url": "http://segmentation-host:port", | ||
| "timeout_s": 120, | ||
| "max_attempts": 3, | ||
| "health_path": "/health", | ||
| "segment_single_object_path": "/predict" | ||
| }, | ||
| "geometry_generation": { | ||
| "base_url": "http://geometry-host:port", | ||
| "timeout_s": 600, | ||
| "max_attempts": 3, | ||
| "health_path": "/health", | ||
| "generate_objects_path": "/generate_multiple_objects" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| The endpoint paths above match the packaged template, but remain | ||
| service-specific placeholders: change them when the deployed services expose | ||
| different routes. Geometry uses one ordered multi-object request for all masks; | ||
| a single-object scene uses the same request with one mask. | ||
|
|
||
| ## Output | ||
|
|
||
| Each run refreshes the intermediate stage directories and writes the final | ||
| portable export: | ||
|
|
||
| ```text | ||
| <output_root>/ | ||
| |-- scene_understanding/ | ||
| |-- scene_segmentation/ | ||
| |-- scene_generation/ | ||
| `-- scene_export/ | ||
| |-- scene_config.json | ||
| `-- mesh_assets/ | ||
| |-- <table-id>/<table-id>.glb | ||
| `-- <asset-id>/<asset-id>.glb | ||
| ``` | ||
|
|
||
| `scene_export/scene_config.json` has format | ||
| `"embodichain.scene-export/v1"`. It contains the table under `background` and | ||
| the settled assets under `rigid_object`; mesh paths are relative to | ||
| `scene_export/`. | ||
|
|
||
| The internal scene layout is y-up. The exporter copies GLBs unchanged and | ||
| converts final positions and rotations to the simulator's z-up convention. | ||
| This is a scene-only export, not a `run-env` configuration: it does not define | ||
| a robot or task. | ||
|
|
||
| ## Python API | ||
|
|
||
| Use `generate_scene_from_image` to run the full pipeline: | ||
|
|
||
| ```python | ||
| from embodichain.gen_sim.scene_engine.pipeline.generate import ( | ||
| generate_scene_from_image, | ||
| ) | ||
|
|
||
| scene = generate_scene_from_image( | ||
| image_path="scene.png", | ||
| output_root="scene_output", | ||
| llm_config_path="scene_engine_config.json", | ||
| image_segmentation_config_path="scene_engine_config.json", | ||
| geometry_generation_config_path="scene_engine_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
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
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] = [] |
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.
[P1] The
gensimextra currently declares onlybpyandpyrender, while Scene Engine directly importsrequests, Pillow, SciPy, trimesh, Open3D, and matplotlib. A cleanembodichain[gensim]installation therefore relies on undeclared transitive dependencies. Please declare these dependencies directly, possibly under a dedicatedscene-engineextra, and exercise that installation path in CI.