How zju3dv/4k4d works
Project Type and Purpose
• This is a research‐oriented, full-stack Python/CUDA codebase for real-time neural volumetric video synthesis at 4K resolution (“4K4D”), built on top of the modular “EasyVolcap” framework.
• It provides:
• A core library (easyvolcap/…) for data loading, model definition, sampling, rendering, visualization, WebSocket viewer and training loops.
• A CLI frontend (scripts/… and entry points like evc-gui, evc-test, evc-train, evc-ws).
• A configuration system (configs/…) driving experiments, datasets, model specs, project presets, and run profiles.
• Documentation (docs/…), assets (assets/…), tests (tests/…) and glue files (pyproject.toml, environment.yml).
File-Structure Analysis
• Top-level directories:
• easyvolcap/ – core Python package with submodules:
– dataloaders – dataset classes and samplers
– engine – config parsing, registry, file I/O, handlers (YAML, JSON, Pickle)
– models – camera models, network architectures (embedders, regressors, renderers, samplers)
– runners – training/evaluation loops, optimizers, recorders, WebSocket server
– utils – low-level utilities (CUDA, OpenGL, mesh, image, profiling, IO, shaders…)
– scripts – Python entry scripts (main.py, client.py, wrappers)
• configs/ – hierarchical YAML files for:
– Base settings (base.yaml),
– Dataset definitions (configs/datasets/...),
– Experiment presets (configs/exps/...),
– Model architectures (configs/models/...),
– Project workflows (configs/projects/...),
– Spec overrides (configs/specs/...).
• scripts/ – standalone preprocessing, dataset conversion, camera calibration, fusion, dataset download, and project-specific utilities.
• docs/ – architectural design docs, usage guides, API references.
• assets/ – fonts, images, 3D meshes (for demos).
• tests/ – unit and integration tests (CUDA, rendering, memory).
Insights from README
• The README emphasizes:
• Modularity through YAML configs and registry-based instantiation
• Two main workflows: Training (evc-train) and Rendering/Inference (evc-gui, evc-test, evc-ws)
• Support for GPU backends: CUDA-tile rasterizer, PyTorch, PyTorch3D, tiny-cuda-nn, Open3D
• WebSocket server/client pairing for remote interactive viewing
• Preprocessing scripts for minimal datasets, visual hull extraction, optimized camera calibration
a. Main Components
1. CLI Frontend
– Commands: evc-train, evc-test, evc-gui, evc-ws
– Parses command-line args & points to one or more config YAMLs
2. Config Manager & Registry
– easyvolcap.engine.parse reads/merges YAMLs
– easyvolcap.engine.registry maps config keys to Python classes
3. File Client & I/O Handlers
– Abstracts local/remote files, supports JSON/YAML/Pickle
4. Data Pipeline
– dataloaders → dataset objects → batched samples (images, masks, cameras)
5. Model Pipeline
– Camera module → Embedder → Network → Sampler → Renderer
6. GPU Compute & Backends
– Tiny-cuda-nn networks, CUDA kernels (tile rasterizer), PyTorch ops, PyTorch3D
7. Runners & Optimizers
– Training/Evaluation loops manage forward/backward, optimizers, schedulers
8. Visualization & Viewer
– Native GUI rendering (evc-gui)
– WebSocket server (easyvolcap.runners.websocket_server)
– WebSocket client (scripts/client.py or evc-ws)
9. Storage
– Input data (datasets folder)
– Trained models (data/trained_model)
– Logs, tensorboard, checkpoints (data/record, data/result)
b. Relationships & Data Flow
• CLI → Config Manager → Registry → Instantiate Components
• File Client loads config & data → Dataloader → Model → Sampler → Renderer
• Renderer outputs frames → Visualizer (GUI or streamed via WebSocket)
• In training: Runner loops over data → Model forward/backward → Optimizer → Checkpoint
• In inference: Renderer forward only → Output images/video
c. Architectural Patterns & Design Principles
– Plugin/Registry pattern for easy extension of cameras, embedders, samplers, renderers
– Config-driven architecture: decoupling code from experiments
– Separation of concerns:
• I/O & Config (engine)
• Data (dataloaders)
• Compute (models, samplers, renderers)
• Control flow (runners)
• UX (GUI, WebSocket)
– GPU/CPU hybrid partitioning for high performance
– Modular CLI toolchain
d. Key Technologies & External Dependencies
– Python 3.8+ (PyTorch, PyTorch3D, tiny-cuda-nn, Open3D)
– CUDA (custom kernels, tile-based rasterizer)
– YAML/JSON config parsing
– WebSocket (remote viewing)
– Third-party scripts: Colmap, Blender, OpenGL, segmentation nets
Essential Elements to Capture
• Config file merging & registry instantiation
• Engine/FileClient abstraction
• Data pipeline (image/mask/camera sampling)
• Model/sampler/renderer separation
• Training loop vs inference flow
• Visualization: native GUI and WebSocket paths
• External and optional preprocessors (e.g., dataset conversion scripts)