How chenguolin/diffsplat works
Main Components and Their Roles
• Data & Asset Management:
• Assets Folder: Stores demo images, videos, and prompt examples for visualization.
• Dataset Preprocessing: Found in src/data (e.g., gobjaverse_parquet_dataset.py) which handles preprocessing and packaging large-scale datasets (from G-Objaverse).
• Configuration & Setup:
• Configs Directory: Contains YAML configuration files (e.g., gsdiff_sd15.yaml, elevest.yaml) for various training and inference experiments.
• Settings: Contains requirements and setup scripts (setup.sh, requirements.txt) to initialize the environment.
• Model Architecture:
• Model Modules in src/models: Implements core model classes (GSRecon, GSVAEs, and network modules such as attention and rendering utilities).
• Extensions (extensions/diffusers_diffsplat): Contains modifications to the diffusers library. This includes new attention mechanisms (“multi-view attention”), custom UNet/Transformer initializations (via from_pretrained_new), and pipelines for variants like PixArt, SD1.5, SD3.5m, and ControlNet.
• Training Pipelines:
• Training Scripts (src/train_*.py): Separate scripts for training each component (e.g., train_gsdiff_sd.py, train_gsvae.py) with corresponding options defined in both src/options.py and YAML config files.
• Shell Scripts (scripts/train.sh): Environment setup and orchestration to kick off training processes.
• Inference Pipelines:
• Inference Scripts (src/infer_*.py): Scripts specific to running inference for different modes – text-conditioned, image-conditioned, and controlnet-based generation.
• Shell Scripts (scripts/infer.sh): Wrappers that set proper arguments (including model checkpoint usage) and environment variables.
• Checkpoint Management:
• download_ckpt.py: Handles downloading and organizing pretrained models from HuggingFace, ensuring that both text- and image-conditioned weights are readily available.
Out the Interactions and Data Flow
• Start from “Input” Sources:
• Data sources include text prompts, single-view images, control signals (e.g., canny or normal maps), and precomputed text embeddings (from extensions/encode_prompt_embeds.py).
• Preprocessing and Data Pipeline:
• Raw data is preprocessed using dataset utilities (src/data) and stored in efficient formats (e.g., parquet) before being fed into training or inference modules.
• Model Training Flow:
• Training scripts read configuration from the YAML files (configs) and options defined in src/options.py.
• The modified diffusers library (in extensions/diffusers_diffsplat) is used by model classes under src/models to perform training (using multi-view attention and flexible UNet architectures).
• Training involves both reconstruction (GSRecon, GSVAEs) and diffusion-based generation (DiffSplat) modes. Optionally, a tiny decoder may be employed to speed up rendering-loss calculations.
• Inference Flow:
• Wrapped by scripts/infer.sh, inference scripts load pretrained models (downloaded via download_ckpt.py) and run through the modified pipeline (that may include control signals from ControlNet).
• The output is a rendered 3D Gaussian splats video/gif along with optional ply file generation.
• External Dependencies:
• The system integrates with HuggingFace for model downloading and caching, and leverages PyTorch and the diffusers library (with custom modifications).
Implementation Steps
• Within the Model Architecture, subdivide into core models (GSRecon, GSVAEs, DiffSplat) and extensions (modified diffusers, control modules).