# aim-uofa/gsi-bench architecture

> Architecture diagram of the GitHub repository aim-uofa/gsi-bench, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aim-uofa/gsi-bench
- Repository: https://github.com/aim-uofa/gsi-bench

## Overview

#### Purpose and Top-Level Entry Points
GSI-Bench benchmarks generative image-editing models on 3D spatial understanding: instruction compliance (IC), spatial accuracy (SA), appearance consistency (AC), and edit locality (EL). The normal user entry point is `evaluation/run.sh` or the staged commands in `evaluation/eval.sh`, followed by `evaluation/eval/aggregate.py`. Two optional dataset-construction pipelines live independently under `robothor/` and `mesatask/`.

#### Evaluation Orchestration and Contracts
Evaluation consumes externally generated PNGs arranged per model and benchmark split, plus downloaded dataset and weight symlinks. `evaluation/eval.sh` orchestrates IC/SA/EL across models and datasets; `evaluation/eval/eval.py` is the core evaluator; `evaluation/eval/aggregate.py` merges metric outputs into final per-model/per-dataset reports. The principal boundary is filesystem-based: generators need not integrate with this repository if they emit the prescribed image naming/layout.

#### Vision-Based Spatial Scoring
The evaluation stack loads samples and edited images, detects/segments target objects, and compares edited versus reference geometry and image regions. `evaluation/models/model.py` provides model-facing evaluation integration, while `evaluation/utils/wrap_model.py` and `evaluation/utils/box_utils.py` support model invocation and spatial-box operations. DetAny3D is vendored as the central perception backend under `evaluation/utils/detect_anything/modeling/`, including image encoding, prompt encoding, mask decoding, and depth prediction.

#### Text-Grounded Detection Boundary
Optional text-prompt object detection is supplied by the vendored GroundingDINO package. Its inference integration is concentrated in `evaluation/src/groundingdino/groundingdino/util/inference.py`, with model registration in `evaluation/src/groundingdino/groundingdino/models/registry.py` and Swin configurations under `evaluation/src/groundingdino/groundingdino/config/`. It requires separately downloaded weights and is installed as an editable local package.

#### MLLM Appearance-Consistency Pipeline
AC is separated from the deterministic vision-metric path. `evaluation/mllm_eval/mllm_eval.py` runs inference using prompts from `evaluation/mllm_eval/prompts.py`; `evaluation/mllm_eval/build_lmdb.py` prepares image data; results are consumed during aggregation. This stage requires vLLM and an externally supplied Qwen3-VL model, making it a runtime/service boundary rather than a bundled model.

#### RoboTHOR Dataset Generation
`robothor/` produces indoor-scene edit records using AI2-THOR. Shell entry points such as `robothor/scripts/generate_train.sh` invoke scene/action generation, while `robothor/action_utils/environment_utils.py` manages simulator interaction and modules such as `robothor/action_utils/object_relative.py` implement command families. The output boundary is JSONL plus RGB/depth/segmentation assets; AI2-THOR scene assets, NVIDIA GPU, and headless CloudRendering/X are external dependencies.

#### MesaTask Dataset Generation
`mesatask/` transforms tabletop 3D layouts into paired image-editing examples. `mesatask/generate_atomic_transforms.py` creates move/rotate/scale variants; `mesatask/organize_image_editing_dataset.py` assembles rendered assets and metadata; `mesatask/tools/layout2scene/reconstruct_blender.py` supports Blender-based scene reconstruction. Layout assets come from the external MesaTask-10K dataset; Blender rendering and optional Drake physical optimization are distinct runtime boundaries.

Main entry points: [`evaluation/eval/eval.py`](https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/eval/eval.py) (Core evaluator), [`evaluation/mllm_eval/mllm_eval.py`](https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/mllm_eval/mllm_eval.py) (MLLM AC scoring), [`evaluation/eval/aggregate.py`](https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/eval/aggregate.py) (Report aggregation), [`evaluation/run.sh`](https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/run.sh) (Evaluation entrypoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_evaluation["Evaluation"]
  node_generated_images["Generated PNGs<br/>input contract"]
  node_eval_run["Evaluation entrypoint<br/>shell workflow<br/>[run.sh]"]
  node_eval_orchestrator["Metric orchestration<br/>shell workflow<br/>[eval.sh]"]
  node_core_evaluator["Core evaluator<br/>Python evaluator<br/>[eval.py]"]
  node_model_integration["Model integration<br/>evaluation adapter<br/>[model.py]"]
  node_spatial_utils["Spatial utilities<br/>vision utilities<br/>[box_utils.py]"]
  node_mllm_ac["MLLM AC scoring<br/>vLLM pipeline<br/>[mllm_eval.py]"]
  node_ac_prompts["AC prompts<br/>prompt definitions<br/>[prompts.py]"]
  node_lmdb_builder["AC image preparation<br/>LMDB builder<br/>[build_lmdb.py]"]
  node_aggregator["Report aggregation<br/>Python aggregator<br/>[aggregate.py]"]
  node_reports["Benchmark reports<br/>output"]
end

subgraph group_perception["Vision Backends"]
  node_detany3d["DetAny3D<br/>perception backend<br/>[__init__.py]"]
  node_grounding_inference["GroundingDINO inference<br/>text-grounded detection<br/>[inference.py]"]
  node_grounding_registry["GroundingDINO registry<br/>model registration<br/>[registry.py]"]
end

subgraph group_robothor["RoboTHOR Generation"]
  node_robothor_entry["RoboTHOR generation<br/>shell workflow<br/>[generate_train.sh]"]
  node_robothor_environment["Simulator interaction<br/>AI2-THOR adapter"]
  node_robothor_records["RoboTHOR records<br/>dataset output"]
end

subgraph group_mesatask["MesaTask Generation"]
  node_mesatask_transforms["Atomic transforms<br/>dataset generator"]
  node_mesatask_assembly["Dataset assembly<br/>dataset builder"]
  node_blender_reconstruction["Blender reconstruction<br/>rendering workflow"]
  node_mesatask_examples["MesaTask examples<br/>dataset output"]
end

node_generated_images -->|"input images"| node_eval_run
node_eval_run -->|"starts"| node_eval_orchestrator
node_eval_orchestrator -->|"runs IC/SA/EL"| node_core_evaluator
node_generated_images -->|"loads edits"| node_core_evaluator
node_core_evaluator -->|"uses"| node_model_integration
node_model_integration -->|"uses"| node_spatial_utils
node_core_evaluator -->|"segments and estimates depth"| node_detany3d
node_core_evaluator -.->|"optional text detection"| node_grounding_inference
node_grounding_inference -->|"resolves model"| node_grounding_registry
node_generated_images -->|"prepares images"| node_lmdb_builder
node_lmdb_builder -->|"image store"| node_mllm_ac
node_ac_prompts -->|"prompts"| node_mllm_ac
node_mllm_ac -->|"AC results"| node_aggregator
node_core_evaluator -->|"IC/SA/EL outputs"| node_aggregator
node_aggregator -->|"publishes"| node_reports
node_robothor_entry -->|"drives"| node_robothor_environment
node_robothor_environment -->|"writes"| node_robothor_records
node_mesatask_transforms -->|"scene variants"| node_blender_reconstruction
node_blender_reconstruction -->|"rendered assets"| node_mesatask_assembly
node_mesatask_assembly -->|"writes"| node_mesatask_examples

click node_eval_run "https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/run.sh"
click node_eval_orchestrator "https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/eval.sh"
click node_core_evaluator "https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/eval/eval.py"
click node_model_integration "https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/models/model.py"
click node_spatial_utils "https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/utils/box_utils.py"
click node_mllm_ac "https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/mllm_eval/mllm_eval.py"
click node_ac_prompts "https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/mllm_eval/prompts.py"
click node_lmdb_builder "https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/mllm_eval/build_lmdb.py"
click node_aggregator "https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/eval/aggregate.py"
click node_detany3d "https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/utils/detect_anything/modeling/__init__.py"
click node_grounding_inference "https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/src/groundingdino/groundingdino/util/inference.py"
click node_grounding_registry "https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/src/groundingdino/groundingdino/models/registry.py"
click node_robothor_entry "https://github.com/aim-uofa/gsi-bench/blob/main/robothor/scripts/generate_train.sh"
click node_robothor_environment "https://github.com/aim-uofa/gsi-bench/blob/main/robothor/action_utils/environment_utils.py"
click node_mesatask_transforms "https://github.com/aim-uofa/gsi-bench/blob/main/mesatask/generate_atomic_transforms.py"
click node_mesatask_assembly "https://github.com/aim-uofa/gsi-bench/blob/main/mesatask/organize_image_editing_dataset.py"
click node_blender_reconstruction "https://github.com/aim-uofa/gsi-bench/blob/main/mesatask/tools/layout2scene/reconstruct_blender.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_generated_images,node_eval_run,node_eval_orchestrator,node_core_evaluator,node_model_integration,node_spatial_utils,node_mllm_ac,node_ac_prompts,node_lmdb_builder,node_aggregator,node_reports toneBlue
class node_detany3d,node_grounding_inference,node_grounding_registry toneAmber
class node_robothor_entry,node_robothor_environment,node_robothor_records toneMint
class node_mesatask_transforms,node_mesatask_assembly,node_blender_reconstruction,node_mesatask_examples toneRose
```

## Components

### Evaluation

Scores externally generated benchmark edits.

- **Generated PNGs**: input contract · Images must follow the prescribed model and split layout.
- [Evaluation entrypoint](https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/run.sh): shell workflow · Normal user entrypoint for staged evaluation. · `evaluation/run.sh`
- [Metric orchestration](https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/eval.sh): shell workflow · Runs IC, SA, and EL across models and datasets. · `evaluation/eval.sh`
- [Core evaluator](https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/eval/eval.py): Python evaluator · Loads samples and compares edits with references. · `evaluation/eval/eval.py`
- [Model integration](https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/models/model.py): evaluation adapter · Model-facing evaluation interface. · `evaluation/models/model.py`
- [Spatial utilities](https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/utils/box_utils.py): vision utilities · Model wrapping and spatial-box operations. · `evaluation/utils/box_utils.py`
- [MLLM AC scoring](https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/mllm_eval/mllm_eval.py): vLLM pipeline · Appearance-consistency inference using external Qwen3-VL. · `evaluation/mllm_eval/mllm_eval.py`
- [AC prompts](https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/mllm_eval/prompts.py): prompt definitions · `evaluation/mllm_eval/prompts.py`
- [AC image preparation](https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/mllm_eval/build_lmdb.py): LMDB builder · `evaluation/mllm_eval/build_lmdb.py`
- [Report aggregation](https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/eval/aggregate.py): Python aggregator · Merges deterministic metrics and AC results per model and dataset. · `evaluation/eval/aggregate.py`
- **Benchmark reports**: output · Final per-model and per-dataset metric reports.

### Vision Backends

Vendored spatial and text-grounded perception.

- [DetAny3D](https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/utils/detect_anything/modeling/__init__.py): perception backend · Encodes images and prompts, decodes masks, and predicts depth. · `evaluation/utils/detect_anything/modeling/__init__.py`
- [GroundingDINO inference](https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/src/groundingdino/groundingdino/util/inference.py): text-grounded detection · Optional prompt-based object detection integration. · `evaluation/src/groundingdino/groundingdino/util/inference.py`
- [GroundingDINO registry](https://github.com/aim-uofa/gsi-bench/blob/main/evaluation/src/groundingdino/groundingdino/models/registry.py): model registration · `evaluation/src/groundingdino/groundingdino/models/registry.py`

### RoboTHOR Generation

Indoor-scene dataset construction pipeline.

- [RoboTHOR generation](https://github.com/aim-uofa/gsi-bench/blob/main/robothor/scripts/generate_train.sh): shell workflow · Generates indoor scene edit records through AI2-THOR. · `robothor/scripts/generate_train.sh`
- [Simulator interaction](https://github.com/aim-uofa/gsi-bench/blob/main/robothor/action_utils/environment_utils.py): AI2-THOR adapter · Manages simulator scenes and actions. · `robothor/action_utils/environment_utils.py`
- **RoboTHOR records**: dataset output · JSONL records with RGB, depth, and segmentation assets.

### MesaTask Generation

Tabletop dataset construction pipeline.

- [Atomic transforms](https://github.com/aim-uofa/gsi-bench/blob/main/mesatask/generate_atomic_transforms.py): dataset generator · Creates move, rotate, and scale variants. · `mesatask/generate_atomic_transforms.py`
- [Dataset assembly](https://github.com/aim-uofa/gsi-bench/blob/main/mesatask/organize_image_editing_dataset.py): dataset builder · Assembles rendered assets and editing metadata. · `mesatask/organize_image_editing_dataset.py`
- [Blender reconstruction](https://github.com/aim-uofa/gsi-bench/blob/main/mesatask/tools/layout2scene/reconstruct_blender.py): rendering workflow · Reconstructs scenes for rendering. · `mesatask/tools/layout2scene/reconstruct_blender.py`
- **MesaTask examples**: dataset output · Paired tabletop image-editing examples.

## Connections

- Generated PNGs → Evaluation entrypoint: input images
- Evaluation entrypoint → Metric orchestration: starts
- Metric orchestration → Core evaluator: runs IC/SA/EL
- Generated PNGs → Core evaluator: loads edits
- Core evaluator → Model integration: uses
- Model integration → Spatial utilities: uses
- Core evaluator → DetAny3D: segments and estimates depth
- Core evaluator → GroundingDINO inference: optional text detection
- GroundingDINO inference → GroundingDINO registry: resolves model
- Generated PNGs → AC image preparation: prepares images
- AC image preparation → MLLM AC scoring: image store
- AC prompts → MLLM AC scoring: prompts
- MLLM AC scoring → Report aggregation: AC results
- Core evaluator → Report aggregation: IC/SA/EL outputs
- Report aggregation → Benchmark reports: publishes
- RoboTHOR generation → Simulator interaction: drives
- Simulator interaction → RoboTHOR records: writes
- Atomic transforms → Blender reconstruction: scene variants
- Blender reconstruction → Dataset assembly: rendered assets
- Dataset assembly → MesaTask examples: writes
