From 705fbc9dfc83c904c6ed8bfd17b314ba40bfa15a Mon Sep 17 00:00:00 2001 From: "xinjie.wang" Date: Sun, 28 Dec 2025 15:13:57 +0800 Subject: [PATCH] More robust formatting of the results returned by gpt. --- README.md | 4 ++-- docs/tutorials/image_to_3d.md | 2 +- docs/tutorials/layout_gen.md | 2 +- embodied_gen/scripts/imageto3d.py | 4 ++-- embodied_gen/validators/urdf_convertor.py | 9 +++++++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9a14480..81d4cb0 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ CUDA_VISIBLE_DEVICES=0 nohup python apps/image_to_3d.py > /dev/null 2>&1 & Generate physically plausible 3D assets from image input via the command-line API. ```sh img3d-cli --image_path apps/assets/example_image/sample_00.jpg apps/assets/example_image/sample_01.jpg \ ---n_retry 1 --output_root outputs/imageto3d +--n_retry 2 --output_root outputs/imageto3d # See result(.urdf/mesh.obj/mesh.glb/gs.ply) in ${output_root}/sample_xx/result ``` @@ -246,7 +246,7 @@ Remove `--insert_robot` if you don't consider the robot pose in layout generatio CUDA_VISIBLE_DEVICES=0 nohup layout-cli \ --task_descs "apps/assets/example_layout/task_list.txt" \ --bg_list "outputs/bg_scenes/scene_list.txt" \ ---n_image_retry 4 --n_asset_retry 3 --n_pipe_retry 2 \ +--n_image_retry 4 --n_asset_retry 3 --n_pipe_retry 3 \ --output_root "outputs/layouts_gens" --insert_robot > layouts_gens.log & ``` diff --git a/docs/tutorials/image_to_3d.md b/docs/tutorials/image_to_3d.md index 705ed35..0081d6b 100644 --- a/docs/tutorials/image_to_3d.md +++ b/docs/tutorials/image_to_3d.md @@ -10,7 +10,7 @@ Support the use of [SAM3D](https://github.com/facebookresearch/sam-3d-objects) o ```bash img3d-cli --image_path apps/assets/example_image/sample_00.jpg \ apps/assets/example_image/sample_01.jpg \ ---n_retry 1 --output_root outputs/imageto3d +--n_retry 2 --output_root outputs/imageto3d ``` You will get the following results: diff --git a/docs/tutorials/layout_gen.md b/docs/tutorials/layout_gen.md index 6eeb642..0f56543 100644 --- a/docs/tutorials/layout_gen.md +++ b/docs/tutorials/layout_gen.md @@ -60,7 +60,7 @@ You can also run multiple tasks via a task list file in the backend. CUDA_VISIBLE_DEVICES=0 nohup layout-cli \ --task_descs "apps/assets/example_layout/task_list.txt" \ --bg_list "outputs/bg_scenes/scene_list.txt" \ - --n_image_retry 4 --n_asset_retry 3 --n_pipe_retry 2 \ + --n_image_retry 4 --n_asset_retry 3 --n_pipe_retry 3 \ --output_root "outputs/layouts_gens" \ --insert_robot > layouts_gens.log & ``` diff --git a/embodied_gen/scripts/imageto3d.py b/embodied_gen/scripts/imageto3d.py index dfbc8e4..9d930ab 100644 --- a/embodied_gen/scripts/imageto3d.py +++ b/embodied_gen/scripts/imageto3d.py @@ -105,7 +105,7 @@ def parse_args(): parser.add_argument( "--n_retry", type=int, - default=2, + default=3, ) parser.add_argument("--disable_decompose_convex", action="store_true") parser.add_argument("--texture_size", type=int, default=2048) @@ -163,7 +163,7 @@ def entrypoint(**kwargs): outputs = image3d_model_infer(PIPELINE, seg_image, seed) except Exception as e: logger.error( - f"[Pipeline Failed] process {image_path}: {e}, skip." + f"[Image3D Failed] process {image_path}: {e}, retry: {try_idx+1}/{args.n_retry}" ) continue diff --git a/embodied_gen/validators/urdf_convertor.py b/embodied_gen/validators/urdf_convertor.py index 8a48e94..83009f5 100644 --- a/embodied_gen/validators/urdf_convertor.py +++ b/embodied_gen/validators/urdf_convertor.py @@ -204,8 +204,13 @@ def parse_response(self, response: str) -> dict[str, any]: Returns: dict[str, any]: Parsed attributes. """ - lines = response.split("\n") - lines = [line.strip() for line in lines if line] + raw_lines = response.split("\n") + lines = [] + for line in raw_lines: + line = line.strip() + if line and not line.startswith("```") and ":" in line: + lines.append(line) + category = lines[0].split(": ")[1] description = lines[1].split(": ")[1] min_height, max_height = map(