Skip to content
/ mars Public

Automated pipeline to generate 3D scenes from images

Notifications You must be signed in to change notification settings

nalinraut/mars

Repository files navigation

MARS - Multi Asset Reconstruction for Simulation

Transform 2D images into physics-ready 3D scene assets for robotics training.

Overview

MARS (Multi Asset Reconstruction for Simulation) is a complete pipeline that:

  • Detects objects using hybrid vision-language models (Qwen 2.5 VL + GroundingDINO)
  • Segments objects from images using SAM (Segment Anything Model)
  • Reconstructs full 3D geometry and textures using SAM 3D Objects
  • Estimates physics properties (mass, friction, inertia)
  • Validates scenes with PyBullet physics simulation
  • Exports to multiple formats (USD, MJCF, URDF)

Key Features

  • Rich TUI Summary: Pipeline displays a comprehensive summary table at completion showing all detected objects, segmentation results, reconstruction status, physics properties, and validation results
  • Prefect Integration: Full workflow orchestration with Prefect, including plain-text logging compatible with Prefect's logging system
  • Configurable Models: Support for multiple model variants (Qwen 3B/7B, GroundingDINO tiny/base)
  • Intelligent Filtering: NMS-based duplicate removal and configurable area filters with include_background option for large objects

Example: From Image to Simulation

Input: A simple 2D image of a real-world setup

Input Setup

Output: Physics-ready 3D scene imported into Isaac Sim

USD Import in Isaac Sim

The pipeline automatically detects objects, reconstructs their 3D geometry, estimates physics properties, and exports a complete USD scene ready for robotics simulation.

Architecture

Image → Detection → Segmentation → 3D Reconstruction → Physics → Validation → Export
        (Qwen+DINO)   (SAM 3)        (SAM 3D Objects)

Pipeline Stages

  1. Ingestion - Image validation and deduplication
  2. Detection - Object detection with Qwen 2.5 VL + GroundingDINO (hybrid approach)
  3. Segmentation - Precise mask generation with SAM 3
  4. 3D Reconstruction - Mesh generation with SAM 3D Objects + V-HACD collision meshes
  5. Physics Estimation - Material properties and mass calculation
  6. Scene Composition - Spatial layout reconstruction
  7. Validation - PyBullet physics simulation testing
  8. Storage - Indexing and export to multiple formats

Pipeline Summary Display

At the end of each pipeline run, MARS displays a comprehensive TUI summary showing:

  • Detection Results: Objects detected with confidence scores and bounding boxes
  • Segmentation Results: Mask areas, stability scores, and IoU predictions
  • Reconstruction Results: Mesh details, collision mesh status, vertex/face counts
  • Physics Properties: Mass, friction, restitution for each object
  • Validation Results: Stability scores and displacement measurements

See docs/DESIGN.md for detailed setup and usage instructions.

Quick Start

# Build and start container
cd develop
./scripts/build.sh
./scripts/start.sh

# Run test pipeline
./tests/scripts/test_pipeline.sh

See docs/QUICKSTART.md for detailed setup and usage instructions.

Development

Project Structure

MARS/
├── develop/              # Docker and development tools
│   ├── Dockerfile
│   ├── docker-compose.yml
│   └── scripts/
│       ├── build.sh
│       ├── start.sh
│       ├── enter.sh
│       ├── stop.sh
│       └── logs.sh
├── src/                  # Source code (mounted to container)
│   └── mars/
│       ├── pipeline.py   # Main pipeline orchestrator
│       ├── ingestion/    # Stage 1: Image validation
│       ├── detection/    # Stage 2: Object detection (Qwen + DINO)
│       ├── segmentation/ # Stage 3: Mask generation (SAM)
│       ├── reconstruction/ # Stage 4: 3D mesh generation
│       ├── physics/      # Stage 5: Physics estimation
│       ├── composition/  # Stage 6: Scene layout
│       ├── validation/   # Stage 7: PyBullet validation
│       ├── storage/      # Stage 8: Indexing/export
│       ├── exporters/    # Export utilities (USD, MJCF, URDF)
│       └── utils/        # Shared utilities
│           ├── display.py      # TUI summary tables (Rich)
│           └── logging_config.py  # Prefect-compatible logging
├── config/               # Configuration files
├── tests/                # Test suite
├── assets/               # Example assets and outputs
│   ├── images/           # Test input images
│   └── usd/              # Example USD scene files
└── README.md             # This file

Source Code is Mounted

The src/ directory is mounted to /workspace/src in the container, so:

  • Edit code on your host machine
  • Changes are immediately available in the container
  • No need to rebuild for code changes

Development Workflow

# 1. Edit code on host
vim src/mars/segmentation/segmentation.py

# 2. Test in container
cd develop
./scripts/enter.sh

# Inside container:
python -m pytest /workspace/src/tests/

# 3. Run pipeline
python -m mars.pipeline --input ...

Container Management

cd develop

# Build container
./scripts/build.sh

# Start container
./scripts/start.sh

# Enter container
./scripts/enter.sh

# View logs
./scripts/logs.sh

# Stop container
./scripts/stop.sh

# Rebuild from scratch
./scripts/rebuild.sh

Configuration

Edit configuration files in config/ to customize pipeline behavior:

Detection (config/detection.yaml)

  • Model selection: hybrid (Qwen + GroundingDINO) or qwen_direct
  • Model variants: Qwen 3B/7B, GroundingDINO tiny/base
  • NMS threshold for duplicate removal
  • Confidence thresholds

Segmentation (config/segmentation.yaml)

  • max_area_ratio: Maximum mask area relative to image (default: 0.80)
  • include_background: Keep large objects like tables even if they exceed max_area_ratio
  • Stability and IoU score thresholds

Reconstruction (config/reconstruction.yaml)

  • V-HACD collision mesh parameters
  • Mesh repair settings

Physics (config/physics.yaml)

  • Material properties (density, friction, restitution)
  • Category-to-material mapping

Pipeline (config/pipeline.yaml)

  • Stage selection
  • Output formats
  • Logging verbosity

Testing

Use the test script to run the pipeline on test images:

./tests/scripts/test_pipeline.sh [image_path] [--run-until STAGE] [--output-dir DIR]

See docs/QUICKSTART.md for detailed testing instructions.

Integration

Output Contract:

  • Scene configs (JSON with meshes, physics, zones)
  • Queryable index (task type, objects, quality)
  • Multiple export formats (USD, MJCF, URDF)
  • Randomization bounds for domain randomization

Documentation

  • develop/docs/ - Full architecture documentation
  • config/ - Configuration examples
  • src/mars/ - Code documentation (docstrings)

License

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.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

About

Automated pipeline to generate 3D scenes from images

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published