diff --git a/REPOSITORY_ANALYSIS.md b/REPOSITORY_ANALYSIS.md
new file mode 100644
index 0000000..64084b4
--- /dev/null
+++ b/REPOSITORY_ANALYSIS.md
@@ -0,0 +1,559 @@
+# CityGaussian Repository - Comprehensive Analysis
+**Analysis Date:** 2026-02-07
+**Repository:** Linketic/CityGaussian
+
+---
+
+## 📋 Executive Summary
+
+**CityGaussian** is a state-of-the-art framework for **large-scale 3D scene reconstruction and rendering** using Gaussian Splatting technology. It implements two major research papers (ECCV 2024, ICLR 2025) and provides production-grade tools for reconstructing massive urban scenes with real-time rendering capabilities.
+
+---
+
+## 🎯 Core Functionality
+
+### Purpose
+CityGaussian reconstructs expansive 3D scenes (particularly urban environments like city blocks, campuses, and aerial views) from multi-view image datasets while maintaining:
+- **Real-time rendering performance** (interactive frame rates)
+- **High visual quality** (photorealistic results)
+- **Geometric accuracy** (precise surface reconstruction)
+- **Scalability** (scenes with millions of Gaussians)
+
+### Main Capabilities
+
+1. **Large-Scale Scene Reconstruction**
+ - Process datasets with thousands of images
+ - Handle scenes spanning hundreds of meters
+ - Support multi-GPU distributed training
+ - Memory-efficient partition-based processing
+
+2. **Multiple Rendering Modes**
+ - Standard 3D Gaussian Splatting
+ - 2D Gaussian Splatting (for mesh extraction)
+ - Deformable Gaussians (for dynamic scenes)
+ - MipSplatting (anti-aliased rendering)
+ - Appearance-aware rendering (lighting variations)
+
+3. **Comprehensive Dataset Support**
+ - 15+ dataset format parsers
+ - Popular formats: COLMAP, Blender, NeRF, NSVF
+ - Custom formats: MatrixCity, PhotoTourism, Mega-NeRF
+ - Automatic dataset type detection
+
+4. **Geometric Evaluation**
+ - Mesh extraction from Gaussians
+ - Precision/Recall/F1-Score metrics
+ - Depth map comparison
+ - Surface reconstruction quality assessment
+
+5. **Joint Optimization**
+ - Camera pose refinement
+ - Gaussian parameters optimization
+ - Appearance embedding learning
+ - Integration with foundation models (VGGT-X)
+
+---
+
+## 🏗️ Architecture Overview
+
+### High-Level System Design
+
+```
+┌─────────────────────────────────────────────────────────────┐
+│ CLI Entry Point │
+│ (internal/entrypoints/gspl.py) │
+│ Commands: fit, validate, test, predict, render │
+└───────────────────────┬─────────────────────────────────────┘
+ │
+ ┌───────────────┼───────────────┐
+ │ │ │
+ ▼ ▼ ▼
+┌──────────────┐ ┌────────────┐ ┌──────────────┐
+│ Dataset │ │ Gaussian │ │ Renderer │
+│ Module │ │ Model │ │ Engine │
+│ (dataset.py) │ │ (models/) │ │ (renderers/) │
+└──────┬───────┘ └─────┬──────┘ └──────┬───────┘
+ │ │ │
+ │ ┌─────────┴──────┐ │
+ │ │ │ │
+ ▼ ▼ ▼ ▼
+ ┌─────────────┐ ┌──────────────────┐
+ │ DataParser │ │ Density │
+ │ (15+ types) │ │ Controller │
+ └─────────────┘ └──────────────────┘
+```
+
+### Core Components
+
+| Component | Location | Responsibility |
+|-----------|----------|----------------|
+| **GaussianSplatting** | `internal/gaussian_splatting.py` | PyTorch Lightning module orchestrating training/validation |
+| **Gaussian Models** | `internal/models/` | 3D scene representations (10+ variants) |
+| **Renderers** | `internal/renderers/` | Splatting algorithms (30+ specialized renderers) |
+| **Density Controllers** | `internal/density_controllers/` | Gaussian lifecycle management (split/clone/prune) |
+| **Data Parsers** | `internal/dataparsers/` | Dataset format parsers (15+ types) |
+| **Dataset Module** | `dataset.py` | Data loading, preprocessing, caching |
+| **Metrics** | `internal/metrics/` | Loss functions and evaluation metrics |
+| **Callbacks** | `internal/callbacks.py` | Training callbacks (logging, checkpointing) |
+| **Optimizers** | `internal/optimizers.py` | Custom optimizers (Sparse Adam, Selective Adam) |
+
+---
+
+## 🔧 Key Features
+
+### 1. Multi-Model Support
+
+| Model Type | File | Description |
+|------------|------|-------------|
+| VanillaGaussian | `vanilla_gaussian.py` | Standard 3DGS implementation |
+| DeformModel | `deform_model.py` | Time-varying deformable Gaussians |
+| AppearanceMipGaussian | `appearance_mip_gaussian.py` | Multi-scale with appearance |
+| Gaussian2DModel | `gaussian_2d.py` | 2D Gaussians for mesh extraction |
+| SparseAdamGaussian | `sparse_adam_gaussian.py` | Memory-efficient variant |
+
+### 2. Rendering Engines (30+ Variants)
+
+**Core Renderers:**
+- **GSplatRenderer**: GPU-accelerated via gsplat library
+- **VanillaRenderer**: Original 3DGS implementation
+- **MipSplattingRenderer**: Anti-aliased rendering
+- **PartitionLoDRenderer**: Level-of-detail for large scenes
+- **DistributedRenderer**: Multi-GPU rendering
+
+**Specialized Renderers:**
+- Appearance-aware (lighting variation handling)
+- Depth renderers (depth map generation)
+- Feature renderers (semantic features)
+- Deformation renderers (dynamic scenes)
+
+### 3. Density Control Strategies
+
+**Operations:**
+- **Densification**: Add Gaussians in under-reconstructed areas
+- **Splitting**: Split large Gaussians
+- **Cloning**: Duplicate high-gradient Gaussians
+- **Pruning**: Remove insignificant Gaussians
+
+**Strategies:**
+- Vanilla (standard 3DGS approach)
+- LightGaussian (aggressive pruning)
+- MCMC-based (probabilistic control)
+- Scale regularization
+
+### 4. Dataset Parsers (15+ Types)
+
+| Parser | Dataset Format | Features |
+|--------|----------------|----------|
+| Colmap | COLMAP reconstruction | SfM camera poses, sparse points |
+| Blender | Synthetic NeRF | Perfect ground truth |
+| MatrixCity | Large urban scenes | Block-based partitioning |
+| NSVF | Neural Volumes | Bounded scenes |
+| Nerfies | Dynamic scenes | Time-varying capture |
+| PhotoTourism | Tourist photos | Appearance variation |
+| MegaNeRF | Massive scenes | Multi-block support |
+
+### 5. Training Pipeline
+
+**Initialization:**
+1. Load dataset with DataParser
+2. Initialize Gaussian positions from point cloud
+3. Set up camera parameters (with optional undistortion)
+4. Configure model, renderer, and density controller
+
+**Training Loop:**
+```
+For each iteration:
+ 1. Sample batch of images
+ 2. Render from Gaussian model
+ 3. Compute loss (L1 + SSIM + auxiliary losses)
+ 4. Backward pass
+ 5. Update Gaussians via optimizer
+ 6. Density control (every N iterations):
+ - Evaluate Gaussian statistics
+ - Split/clone/prune as needed
+ 7. Log metrics and visualizations
+```
+
+**Advanced Features:**
+- Gradient normalization
+- Learning rate scheduling
+- Appearance embedding optimization
+- Joint pose refinement
+- Multi-GPU synchronization
+
+### 6. Evaluation Metrics
+
+**Rendering Quality:**
+- PSNR (Peak Signal-to-Noise Ratio)
+- SSIM (Structural Similarity)
+- LPIPS (Learned Perceptual Image Patch Similarity)
+
+**Geometric Quality:**
+- Precision (accuracy of reconstructed surfaces)
+- Recall (completeness of reconstruction)
+- F1-Score (harmonic mean of precision/recall)
+- Depth error metrics
+
+### 7. Configuration System
+
+**YAML-Based Configuration:**
+- 60+ pre-configured YAML files in `configs/`
+- Hierarchical configuration structure
+- Override system via command line
+- Dataclass-based validation
+
+**Configuration Categories:**
+```yaml
+model: # Gaussian model type and parameters
+renderer: # Rendering algorithm selection
+density: # Density control strategy
+optimizer: # Optimizer and learning rates
+data: # Dataset loading and preprocessing
+trainer: # PyTorch Lightning trainer settings
+```
+
+---
+
+## 📊 Performance Characteristics
+
+### Benchmark Results (CityGaussian V2)
+
+| Scene | SSIM↑ | PSNR↑ | LPIPS↓ | Precision↑ | Recall↑ | F1↑ | Gaussians |
+|-------|------|------|--------|-----------|---------|-----|-----------|
+| LFLS | 0.744 | 23.44 | 0.246 | 0.556 | 0.400 | 0.466 | 8.19M |
+| SMBU | 0.794 | 24.00 | 0.185 | 0.559 | 0.523 | 0.541 | 5.33M |
+| Upper Campus | 0.779 | 25.78 | 0.186 | 0.654 | 0.394 | 0.491 | 7.87M |
+| MatrixCity Aerial | 0.859 | 27.26 | 0.175 | 0.432 | 0.790 | 0.559 | 8.57M |
+| MatrixCity Street | 0.791 | 22.32 | 0.344 | 0.325 | 0.797 | 0.461 | 7.40M |
+
+### Scalability
+- **Scene size**: Handles scenes spanning 500m+
+- **Image count**: Processes datasets with 5000+ images
+- **Gaussian count**: Manages 5-10 million Gaussians per scene
+- **GPU memory**: Configurable caching (50-1024 images)
+- **Multi-GPU**: Supports unlimited GPU count via DDP
+
+---
+
+## 🐛 Identified Bugs and Issues
+
+### 🔴 CRITICAL Bugs
+
+#### 1. Division by Zero in Gradient Normalization
+**File:** `internal/gaussian_splatting.py:404`
+
+**Code:**
+```python
+outputs["viewspace_points"].grad = org_grad * max(
+ self.hparams["density"].densify_grad_scaler * grad_norm_avg_final / grad_norm_avg, 1.0
+)
+```
+
+**Issue:**
+When the visibility filter has no visible Gaussians, `grad_norm_avg` can be zero or extremely small, causing division by zero or numerical instability (`inf`/`nan` gradients).
+
+**Impact:**
+- Training crashes with gradient explosions
+- `nan` losses that propagate through the model
+- Most likely to occur in early training iterations or with sparse visibility
+
+**Recommended Fix:**
+```python
+# Add epsilon for numerical stability
+grad_norm_avg_safe = torch.clamp(grad_norm_avg, min=1e-10)
+outputs["viewspace_points"].grad = org_grad * max(
+ self.hparams["density"].densify_grad_scaler * grad_norm_avg_final / grad_norm_avg_safe, 1.0
+)
+```
+
+---
+
+#### 2. Index Bounds Mismatch in Density Controller
+**File:** `internal/density_controllers/vanilla_density_controller.py:198-199`
+
+**Code:**
+```python
+padded_grad = torch.zeros((n_init_points,), device=device)
+padded_grad[:grads.shape[0]] = grads.squeeze()
+```
+
+**Issue:**
+After Gaussian cloning operations, `grads.shape[0]` may exceed `n_init_points`, causing index out of bounds. Additionally, `squeeze()` can fail if grads has unexpected dimensions.
+
+**Impact:**
+- `RuntimeError: index [X] is out of bounds for dimension 0 with size [Y]`
+- Occurs during densification when Gaussians are cloned
+- Training crashes mid-process
+
+**Recommended Fix:**
+```python
+padded_grad = torch.zeros((n_init_points,), device=device)
+# Ensure we don't exceed bounds
+valid_size = min(grads.shape[0], n_init_points)
+padded_grad[:valid_size] = grads.squeeze()[:valid_size]
+```
+
+---
+
+#### 3. Shape Mismatch in SH Channel Assignment
+**File:** `internal/models/vanilla_gaussian.py:115-116`
+
+**Code:**
+```python
+shs[:, :3, 0] = fused_color
+shs[:, 3:, 1:] = 0.0
+```
+
+**Issue:**
+The second line tries to assign to `shs[:, 3:, 1:]` but spherical harmonics only have 3 color channels (RGB). The index `shs[:, 3:, ...]` would select beyond the available channels. This appears to be a typo - should likely be `shs[:, :, 1:]` (all color channels, all SH degrees except DC component).
+
+**Impact:**
+- Silent failure if broadcasting doesn't catch it
+- Incorrect SH initialization
+- Potential shape mismatch errors during training
+
+**Recommended Fix:**
+```python
+shs[:, :3, 0] = fused_color
+shs[:, :, 1:] = 0.0 # Zero out all higher-order SH coefficients for all channels
+```
+
+---
+
+### 🟠 HIGH Priority Issues
+
+#### 4. Type Error in Tensor Size Calculation
+**File:** `internal/density_controllers/vanilla_density_controller.py:222`
+
+**Code:**
+```python
+torch.zeros(
+ N * selected_pts_mask.sum(),
+ device=device,
+ dtype=torch.bool,
+)
+```
+
+**Issue:**
+`selected_pts_mask.sum()` returns a tensor, not a Python integer. The expression `N * tensor` produces a tensor, which cannot be used as the size argument to `torch.zeros()`.
+
+**Impact:**
+- `TypeError: 'Tensor' object cannot be interpreted as an integer`
+- Fails during Gaussian splitting operations
+- Prevents density control from functioning
+
+**Recommended Fix:**
+```python
+torch.zeros(
+ N * int(selected_pts_mask.sum()), # Convert to Python int
+ device=device,
+ dtype=torch.bool,
+)
+```
+
+---
+
+#### 5. RGBA Image Handling with uint8 Mode
+**File:** `dataset.py:104-114`
+
+**Code:**
+```python
+if self.image_uint8:
+ image = torch.from_numpy(numpy_image)
+ assert image.dtype == torch.uint8
+ assert image.shape[2] == 3 # ← Fails for RGBA
+else:
+ image = torch.from_numpy(numpy_image.astype(np.float64) / 255.0)
+ if image.shape[2] == 4: # RGBA handling only in else branch
+ # ... alpha blending ...
+```
+
+**Issue:**
+When `image_uint8=True`, the code asserts that images must have exactly 3 channels. However, many datasets use RGBA images with 4 channels. The alpha channel handling only exists in the float path.
+
+**Impact:**
+- Training fails immediately when loading RGBA images with `image_uint8=True`
+- `AssertionError: image.shape[2] == 3`
+- Limits dataset compatibility
+
+**Recommended Fix:**
+```python
+if self.image_uint8:
+ image = torch.from_numpy(numpy_image)
+ assert image.dtype == torch.uint8
+ # Handle RGBA
+ if image.shape[2] == 4:
+ # Convert to RGB by alpha blending (with background assumed black)
+ alpha = image[:, :, 3:4].float() / 255.0
+ image = image[:, :, :3].float() * alpha + 0.0 * (1 - alpha)
+ image = image.to(torch.uint8)
+ assert image.shape[2] == 3
+```
+
+---
+
+#### 6. Distributed Data Splitting Logic Error
+**File:** `dataset.py:166-171`
+
+**Code:**
+```python
+image_num_to_use = math.ceil(len(self.indices) / world_size)
+start = global_rank * image_num_to_use
+end = start + image_num_to_use
+indices = self.indices[start:end]
+indices += self.indices[:image_num_to_use - len(indices)] # Padding
+```
+
+**Issue:**
+The padding logic wraps around to the start of the dataset when the last rank has fewer images. This causes:
+- Some images to be seen by multiple ranks (duplicated training data)
+- Uneven training data distribution
+- First few images get disproportionate weight
+
+**Impact:**
+- Biased training in multi-GPU setups
+- Some data points trained more than others
+- Degraded model quality in distributed training
+
+**Recommended Fix:**
+```python
+# Distribute images more evenly
+indices_per_rank = np.array_split(self.indices, world_size)
+indices = indices_per_rank[global_rank].tolist()
+```
+
+---
+
+### 🟡 MEDIUM Priority Issues
+
+#### 7. Overly Broad Exception Handling
+**File:** `dataset.py:287-290`
+
+**Code:**
+```python
+try:
+ del cached
+except:
+ pass
+```
+
+**Issue:**
+Bare `except:` clause catches ALL exceptions, including `MemoryError`, `KeyboardInterrupt`, and `SystemExit`. This masks real errors and can lead to silent failures.
+
+**Impact:**
+- Resource leaks may go unnoticed
+- Debugging becomes harder (errors silently swallowed)
+- Potential memory issues not caught early
+
+**Recommended Fix:**
+```python
+try:
+ del cached
+except NameError: # Only catch "variable doesn't exist"
+ pass
+```
+
+---
+
+#### 8. Thread Safety in Async Caching
+**File:** `dataset.py:202-220` (async caching implementation)
+
+**Potential Issue:**
+The `_async_cache` method runs in a separate thread and accesses shared state (`self.indices`, `self.generator`). While Python's GIL provides some protection, there's potential for race conditions if these are modified during iteration.
+
+**Impact:**
+- Rare race conditions in multi-threaded caching
+- Potential data corruption or crashes
+- Difficult to reproduce bugs
+
+**Recommendation:**
+Add proper synchronization or make copies of shared data at thread start.
+
+---
+
+## 📈 Code Quality Assessment
+
+### Strengths
+✅ **Modular Architecture**: Well-separated concerns (models, renderers, controllers)
+✅ **Extensive Configuration**: Flexible YAML-based configuration system
+✅ **Good Documentation**: Comprehensive README with examples
+✅ **Type Hints**: Many functions include type annotations
+✅ **Error Messages**: Informative assertions and error messages
+✅ **Testing Infrastructure**: Has test directory with test cases
+
+### Areas for Improvement
+⚠️ **Error Handling**: Several bare except clauses and missing edge case handling
+⚠️ **Type Safety**: Some tensor operations assume shapes without validation
+⚠️ **Numerical Stability**: Missing epsilon values in divisions
+⚠️ **Thread Safety**: Async caching could benefit from better synchronization
+⚠️ **Input Validation**: Some functions don't validate input ranges/types
+
+---
+
+## 🔍 Testing Recommendations
+
+To verify and prevent the identified bugs:
+
+### 1. Unit Tests Needed
+```python
+# Test gradient normalization with zero visibility
+def test_zero_visibility_gradient_normalization():
+ # Create scenario where visibility_filter is all False
+ # Verify no division by zero occurs
+
+# Test RGBA image loading with uint8 mode
+def test_rgba_image_uint8_loading():
+ # Load RGBA image with image_uint8=True
+ # Verify proper alpha blending
+
+# Test distributed data splitting
+def test_distributed_indices_no_overlap():
+ # Verify no image appears in multiple ranks
+ # Check even distribution
+```
+
+### 2. Integration Tests
+- Test full training pipeline with edge cases (single image, single Gaussian)
+- Test multi-GPU training with various world sizes
+- Test all dataset parsers with minimal datasets
+
+### 3. Stress Tests
+- Large-scale training (10M+ Gaussians)
+- Memory pressure scenarios (limited GPU VRAM)
+- Long training runs (check for memory leaks)
+
+---
+
+## 📝 Summary
+
+**CityGaussian** is a sophisticated, well-engineered framework for large-scale 3D reconstruction. It successfully implements cutting-edge research with production-grade code organization.
+
+**Key Strengths:**
+- Comprehensive feature set covering multiple research directions
+- Modular, extensible architecture
+- Strong performance on challenging large-scale scenes
+- Excellent documentation and examples
+
+**Critical Bugs Found:** 8 total
+- 🔴 **3 Critical**: Could cause training crashes
+- 🟠 **3 High**: Affect functionality or correctness
+- 🟡 **2 Medium**: Code quality and error handling
+
+**Recommendation:**
+Address the critical bugs immediately before production use. The high-priority issues should be fixed to ensure robust multi-GPU training and broad dataset compatibility. Medium-priority issues can be addressed as time permits for improved maintainability.
+
+---
+
+## 🔗 References
+
+- **CityGaussian V1**: [ECCV 2024 Paper](https://arxiv.org/pdf/2404.01133)
+- **CityGaussian V2**: [ICLR 2025 Paper](https://arxiv.org/pdf/2411.00771)
+- **Project Pages**:
+ - [V1](https://dekuliutesla.github.io/citygs/)
+ - [V2](https://dekuliutesla.github.io/CityGaussianV2/)
+- **Base Framework**: [Gaussian Lightning](https://github.com/yzslab/gaussian-splatting-lightning)
+
+---
+
+**Analysis Completed By:** GitHub Copilot AI Agent
+**Date:** February 7, 2026
diff --git a/REPOSITORY_ANALYSIS_CN.md b/REPOSITORY_ANALYSIS_CN.md
new file mode 100644
index 0000000..70c3efd
--- /dev/null
+++ b/REPOSITORY_ANALYSIS_CN.md
@@ -0,0 +1,541 @@
+# CityGaussian 代码仓库 - 综合分析报告
+**分析日期:** 2026-02-07
+**代码仓库:** Linketic/CityGaussian
+
+---
+
+## 📋 执行摘要
+
+**CityGaussian** 是一个最先进的**大规模3D场景重建和渲染**框架,使用高斯点云技术(Gaussian Splatting)。它实现了两篇重要研究论文(ECCV 2024, ICLR 2025),并提供了生产级工具来重建大规模城市场景,同时保持实时渲染能力。
+
+---
+
+## 🎯 核心功能
+
+### 主要用途
+CityGaussian 从多视图图像数据集重建大规模3D场景(特别是城市环境,如城市街区、校园和航拍视图),同时保持:
+- **实时渲染性能**(交互式帧率)
+- **高视觉质量**(真实感渲染结果)
+- **几何精度**(精确的表面重建)
+- **可扩展性**(处理数百万高斯点的场景)
+
+### 主要能力
+
+1. **大规模场景重建**
+ - 处理包含数千张图像的数据集
+ - 处理跨越数百米的场景
+ - 支持多GPU分布式训练
+ - 内存高效的分区处理
+
+2. **多种渲染模式**
+ - 标准3D高斯点云渲染
+ - 2D高斯点云渲染(用于网格提取)
+ - 可变形高斯点(用于动态场景)
+ - MipSplatting(抗锯齿渲染)
+ - 外观感知渲染(处理光照变化)
+
+3. **全面的数据集支持**
+ - 15+种数据集格式解析器
+ - 常见格式:COLMAP、Blender、NeRF、NSVF
+ - 自定义格式:MatrixCity、PhotoTourism、Mega-NeRF
+ - 自动检测数据集类型
+
+4. **几何评估**
+ - 从高斯点提取网格
+ - 精确度/召回率/F1分数指标
+ - 深度图比较
+ - 表面重建质量评估
+
+5. **联合优化**
+ - 相机位姿优化
+ - 高斯参数优化
+ - 外观嵌入学习
+ - 与基础模型集成(VGGT-X)
+
+---
+
+## 🏗️ 架构概览
+
+### 高层系统设计
+
+```
+┌─────────────────────────────────────────────────────────────┐
+│ CLI 入口点 │
+│ (internal/entrypoints/gspl.py) │
+│ 命令: fit, validate, test, predict, render │
+└───────────────────────┬─────────────────────────────────────┘
+ │
+ ┌───────────────┼───────────────┐
+ │ │ │
+ ▼ ▼ ▼
+┌──────────────┐ ┌────────────┐ ┌──────────────┐
+│ 数据集 │ │ 高斯模型 │ │ 渲染器 │
+│ 模块 │ │ (models/) │ │ (renderers/) │
+│ (dataset.py) │ │ │ │ │
+└──────┬───────┘ └─────┬──────┘ └──────┬───────┘
+ │ │ │
+ │ ┌─────────┴──────┐ │
+ │ │ │ │
+ ▼ ▼ ▼ ▼
+ ┌─────────────┐ ┌──────────────────┐
+ │ 数据解析器 │ │ 密度控制器 │
+ │ (15+类型) │ │ │
+ └─────────────┘ └──────────────────┘
+```
+
+### 核心组件
+
+| 组件 | 位置 | 职责 |
+|-----------|----------|----------------|
+| **GaussianSplatting** | `internal/gaussian_splatting.py` | PyTorch Lightning模块,协调训练/验证 |
+| **高斯模型** | `internal/models/` | 3D场景表示(10+种变体) |
+| **渲染器** | `internal/renderers/` | 点云渲染算法(30+种专用渲染器) |
+| **密度控制器** | `internal/density_controllers/` | 高斯点生命周期管理(分割/克隆/修剪) |
+| **数据解析器** | `internal/dataparsers/` | 数据集格式解析器(15+种类型) |
+| **数据集模块** | `dataset.py` | 数据加载、预处理、缓存 |
+| **指标** | `internal/metrics/` | 损失函数和评估指标 |
+| **回调** | `internal/callbacks.py` | 训练回调(日志记录、检查点) |
+| **优化器** | `internal/optimizers.py` | 自定义优化器(Sparse Adam、Selective Adam) |
+
+---
+
+## 🔧 关键特性
+
+### 1. 多模型支持
+
+| 模型类型 | 文件 | 描述 |
+|------------|------|-------------|
+| VanillaGaussian | `vanilla_gaussian.py` | 标准3DGS实现 |
+| DeformModel | `deform_model.py` | 时变可变形高斯点 |
+| AppearanceMipGaussian | `appearance_mip_gaussian.py` | 多尺度外观感知 |
+| Gaussian2DModel | `gaussian_2d.py` | 用于网格提取的2D高斯点 |
+| SparseAdamGaussian | `sparse_adam_gaussian.py` | 内存高效变体 |
+
+### 2. 渲染引擎(30+种变体)
+
+**核心渲染器:**
+- **GSplatRenderer**: 通过gsplat库GPU加速
+- **VanillaRenderer**: 原始3DGS实现
+- **MipSplattingRenderer**: 抗锯齿渲染
+- **PartitionLoDRenderer**: 大场景的细节层次
+- **DistributedRenderer**: 多GPU渲染
+
+**专用渲染器:**
+- 外观感知(处理光照变化)
+- 深度渲染器(深度图生成)
+- 特征渲染器(语义特征)
+- 变形渲染器(动态场景)
+
+### 3. 密度控制策略
+
+**操作:**
+- **密集化**: 在重建不足的区域添加高斯点
+- **分割**: 分割大型高斯点
+- **克隆**: 复制高梯度高斯点
+- **修剪**: 移除不重要的高斯点
+
+**策略:**
+- Vanilla(标准3DGS方法)
+- LightGaussian(激进修剪)
+- 基于MCMC(概率控制)
+- 尺度正则化
+
+### 4. 数据集解析器(15+种类型)
+
+| 解析器 | 数据集格式 | 特性 |
+|--------|----------------|----------|
+| Colmap | COLMAP重建 | SfM相机位姿、稀疏点 |
+| Blender | 合成NeRF | 完美ground truth |
+| MatrixCity | 大型城市场景 | 基于块的分区 |
+| NSVF | Neural Volumes | 有界场景 |
+| Nerfies | 动态场景 | 时变捕获 |
+| PhotoTourism | 游客照片 | 外观变化 |
+| MegaNeRF | 大规模场景 | 多块支持 |
+
+### 5. 训练管道
+
+**初始化:**
+1. 使用DataParser加载数据集
+2. 从点云初始化高斯点位置
+3. 设置相机参数(可选去畸变)
+4. 配置模型、渲染器和密度控制器
+
+**训练循环:**
+```
+对于每次迭代:
+ 1. 采样图像批次
+ 2. 从高斯模型渲染
+ 3. 计算损失(L1 + SSIM + 辅助损失)
+ 4. 反向传播
+ 5. 通过优化器更新高斯点
+ 6. 密度控制(每N次迭代):
+ - 评估高斯点统计
+ - 根据需要分割/克隆/修剪
+ 7. 记录指标和可视化
+```
+
+**高级功能:**
+- 梯度归一化
+- 学习率调度
+- 外观嵌入优化
+- 联合位姿优化
+- 多GPU同步
+
+### 6. 评估指标
+
+**渲染质量:**
+- PSNR(峰值信噪比)
+- SSIM(结构相似性)
+- LPIPS(学习感知图像块相似性)
+
+**几何质量:**
+- 精确度(重建表面的准确性)
+- 召回率(重建的完整性)
+- F1分数(精确度和召回率的调和平均值)
+- 深度误差指标
+
+---
+
+## 📊 性能特征
+
+### 基准测试结果(CityGaussian V2)
+
+| 场景 | SSIM↑ | PSNR↑ | LPIPS↓ | 精确度↑ | 召回率↑ | F1↑ | 高斯点数 |
+|-------|------|------|--------|-----------|---------|-----|-----------|
+| LFLS | 0.744 | 23.44 | 0.246 | 0.556 | 0.400 | 0.466 | 8.19M |
+| SMBU | 0.794 | 24.00 | 0.185 | 0.559 | 0.523 | 0.541 | 5.33M |
+| Upper Campus | 0.779 | 25.78 | 0.186 | 0.654 | 0.394 | 0.491 | 7.87M |
+| MatrixCity Aerial | 0.859 | 27.26 | 0.175 | 0.432 | 0.790 | 0.559 | 8.57M |
+| MatrixCity Street | 0.791 | 22.32 | 0.344 | 0.325 | 0.797 | 0.461 | 7.40M |
+
+### 可扩展性
+- **场景大小**: 处理跨度500米+的场景
+- **图像数量**: 处理包含5000+张图像的数据集
+- **高斯点数量**: 管理每个场景5-1000万个高斯点
+- **GPU内存**: 可配置缓存(50-1024张图像)
+- **多GPU**: 通过DDP支持无限数量的GPU
+
+---
+
+## 🐛 已识别的Bug和问题
+
+### 🔴 关键Bug
+
+#### 1. 梯度归一化中的除零错误
+**文件:** `internal/gaussian_splatting.py:404`
+
+**代码:**
+```python
+outputs["viewspace_points"].grad = org_grad * max(
+ self.hparams["density"].densify_grad_scaler * grad_norm_avg_final / grad_norm_avg, 1.0
+)
+```
+
+**问题:**
+当可见性过滤器中没有可见的高斯点时,`grad_norm_avg`可能为零或极小,导致除零或数值不稳定(`inf`/`nan`梯度)。
+
+**影响:**
+- 训练因梯度爆炸而崩溃
+- `nan`损失传播到整个模型
+- 最有可能在训练早期或稀疏可见性情况下发生
+
+**建议修复:**
+```python
+# 添加epsilon以保证数值稳定性
+grad_norm_avg_safe = torch.clamp(grad_norm_avg, min=1e-10)
+outputs["viewspace_points"].grad = org_grad * max(
+ self.hparams["density"].densify_grad_scaler * grad_norm_avg_final / grad_norm_avg_safe, 1.0
+)
+```
+
+---
+
+#### 2. 密度控制器中的索引边界不匹配
+**文件:** `internal/density_controllers/vanilla_density_controller.py:198-199`
+
+**代码:**
+```python
+padded_grad = torch.zeros((n_init_points,), device=device)
+padded_grad[:grads.shape[0]] = grads.squeeze()
+```
+
+**问题:**
+在高斯点克隆操作后,`grads.shape[0]`可能超过`n_init_points`,导致索引越界。此外,如果grads具有意外维度,`squeeze()`可能失败。
+
+**影响:**
+- `RuntimeError: index [X] is out of bounds for dimension 0 with size [Y]`
+- 在密集化过程中高斯点被克隆时发生
+- 训练过程中崩溃
+
+**建议修复:**
+```python
+padded_grad = torch.zeros((n_init_points,), device=device)
+# 确保不超出边界
+valid_size = min(grads.shape[0], n_init_points)
+padded_grad[:valid_size] = grads.squeeze()[:valid_size]
+```
+
+---
+
+#### 3. 球谐通道分配中的形状不匹配
+**文件:** `internal/models/vanilla_gaussian.py:115-116`
+
+**代码:**
+```python
+shs[:, :3, 0] = fused_color
+shs[:, 3:, 1:] = 0.0
+```
+
+**问题:**
+第二行尝试赋值给`shs[:, 3:, 1:]`,但球谐函数只有3个颜色通道(RGB)。索引`shs[:, 3:, ...]`会选择超出可用通道的部分。这似乎是一个错别字——应该是`shs[:, :, 1:]`(所有颜色通道,除DC分量外的所有球谐度数)。
+
+**影响:**
+- 如果广播不捕获则静默失败
+- 不正确的球谐初始化
+- 训练期间潜在的形状不匹配错误
+
+**建议修复:**
+```python
+shs[:, :3, 0] = fused_color
+shs[:, :, 1:] = 0.0 # 将所有通道的高阶球谐系数清零
+```
+
+---
+
+### 🟠 高优先级问题
+
+#### 4. 张量大小计算中的类型错误
+**文件:** `internal/density_controllers/vanilla_density_controller.py:222`
+
+**代码:**
+```python
+torch.zeros(
+ N * selected_pts_mask.sum(),
+ device=device,
+ dtype=torch.bool,
+)
+```
+
+**问题:**
+`selected_pts_mask.sum()`返回一个张量,而不是Python整数。表达式`N * tensor`产生一个张量,不能用作`torch.zeros()`的大小参数。
+
+**影响:**
+- `TypeError: 'Tensor' object cannot be interpreted as an integer`
+- 在高斯点分割操作期间失败
+- 阻止密度控制功能运行
+
+**建议修复:**
+```python
+torch.zeros(
+ N * int(selected_pts_mask.sum()), # 转换为Python整数
+ device=device,
+ dtype=torch.bool,
+)
+```
+
+---
+
+#### 5. uint8模式下的RGBA图像处理
+**文件:** `dataset.py:104-114`
+
+**代码:**
+```python
+if self.image_uint8:
+ image = torch.from_numpy(numpy_image)
+ assert image.dtype == torch.uint8
+ assert image.shape[2] == 3 # ← RGBA时失败
+else:
+ image = torch.from_numpy(numpy_image.astype(np.float64) / 255.0)
+ if image.shape[2] == 4: # RGBA处理仅在else分支中
+ # ... alpha混合 ...
+```
+
+**问题:**
+当`image_uint8=True`时,代码断言图像必须恰好有3个通道。然而,许多数据集使用具有4个通道的RGBA图像。alpha通道处理仅存在于浮点路径中。
+
+**影响:**
+- 当使用`image_uint8=True`加载RGBA图像时,训练立即失败
+- `AssertionError: image.shape[2] == 3`
+- 限制数据集兼容性
+
+**建议修复:**
+```python
+if self.image_uint8:
+ image = torch.from_numpy(numpy_image)
+ assert image.dtype == torch.uint8
+ # 处理RGBA
+ if image.shape[2] == 4:
+ # 通过alpha混合转换为RGB(背景假设为黑色)
+ alpha = image[:, :, 3:4].float() / 255.0
+ image = image[:, :, :3].float() * alpha + 0.0 * (1 - alpha)
+ image = image.to(torch.uint8)
+ assert image.shape[2] == 3
+```
+
+---
+
+#### 6. 分布式数据分割逻辑错误
+**文件:** `dataset.py:166-171`
+
+**代码:**
+```python
+image_num_to_use = math.ceil(len(self.indices) / world_size)
+start = global_rank * image_num_to_use
+end = start + image_num_to_use
+indices = self.indices[start:end]
+indices += self.indices[:image_num_to_use - len(indices)] # 填充
+```
+
+**问题:**
+当最后一个rank的图像较少时,填充逻辑会回绕到数据集的开头。这导致:
+- 某些图像被多个rank看到(重复的训练数据)
+- 训练数据分布不均匀
+- 前几张图像获得不成比例的权重
+
+**影响:**
+- 多GPU设置中的训练偏差
+- 某些数据点训练次数超过其他数据点
+- 分布式训练中模型质量下降
+
+**建议修复:**
+```python
+# 更均匀地分配图像
+indices_per_rank = np.array_split(self.indices, world_size)
+indices = indices_per_rank[global_rank].tolist()
+```
+
+---
+
+### 🟡 中等优先级问题
+
+#### 7. 过于宽泛的异常处理
+**文件:** `dataset.py:287-290`
+
+**代码:**
+```python
+try:
+ del cached
+except:
+ pass
+```
+
+**问题:**
+裸`except:`子句捕获所有异常,包括`MemoryError`、`KeyboardInterrupt`和`SystemExit`。这会掩盖真实错误并可能导致静默失败。
+
+**影响:**
+- 资源泄漏可能不会被注意到
+- 调试变得更困难(错误被静默吞噬)
+- 潜在的内存问题未能及早捕获
+
+**建议修复:**
+```python
+try:
+ del cached
+except NameError: # 仅捕获"变量不存在"
+ pass
+```
+
+---
+
+#### 8. 异步缓存中的线程安全
+**文件:** `dataset.py:202-220`(异步缓存实现)
+
+**潜在问题:**
+`_async_cache`方法在单独的线程中运行并访问共享状态(`self.indices`、`self.generator`)。虽然Python的GIL提供了一些保护,但如果这些在迭代期间被修改,仍有潜在的竞态条件。
+
+**影响:**
+- 多线程缓存中的罕见竞态条件
+- 潜在的数据损坏或崩溃
+- 难以重现的bug
+
+**建议:**
+添加适当的同步或在线程启动时复制共享数据。
+
+---
+
+## 📈 代码质量评估
+
+### 优势
+✅ **模块化架构**: 关注点分离良好(模型、渲染器、控制器)
+✅ **广泛的配置**: 灵活的基于YAML的配置系统
+✅ **良好的文档**: 包含示例的全面README
+✅ **类型提示**: 许多函数包含类型注释
+✅ **错误消息**: 信息丰富的断言和错误消息
+✅ **测试基础设施**: 有测试目录和测试用例
+
+### 改进领域
+⚠️ **错误处理**: 几个裸except子句和缺少边缘情况处理
+⚠️ **类型安全**: 一些张量操作假设形状而不进行验证
+⚠️ **数值稳定性**: 除法中缺少epsilon值
+⚠️ **线程安全**: 异步缓存可以受益于更好的同步
+⚠️ **输入验证**: 一些函数不验证输入范围/类型
+
+---
+
+## 🔍 测试建议
+
+为了验证和防止已识别的bug:
+
+### 1. 需要的单元测试
+```python
+# 测试零可见性的梯度归一化
+def test_zero_visibility_gradient_normalization():
+ # 创建visibility_filter全为False的场景
+ # 验证不发生除零
+
+# 测试uint8模式下的RGBA图像加载
+def test_rgba_image_uint8_loading():
+ # 使用image_uint8=True加载RGBA图像
+ # 验证正确的alpha混合
+
+# 测试分布式数据分割
+def test_distributed_indices_no_overlap():
+ # 验证没有图像出现在多个rank中
+ # 检查均匀分布
+```
+
+### 2. 集成测试
+- 使用边缘情况测试完整训练管道(单张图像、单个高斯点)
+- 使用各种world_size测试多GPU训练
+- 使用最小数据集测试所有数据集解析器
+
+### 3. 压力测试
+- 大规模训练(1000万+高斯点)
+- 内存压力场景(有限的GPU VRAM)
+- 长时间训练运行(检查内存泄漏)
+
+---
+
+## 📝 总结
+
+**CityGaussian**是一个复杂、工程完善的大规模3D重建框架。它成功地将前沿研究实现为生产级代码组织。
+
+**关键优势:**
+- 涵盖多个研究方向的全面功能集
+- 模块化、可扩展的架构
+- 在具有挑战性的大规模场景上表现出色
+- 优秀的文档和示例
+
+**发现的关键Bug:** 总共8个
+- 🔴 **3个关键**: 可能导致训练崩溃
+- 🟠 **3个高优先级**: 影响功能或正确性
+- 🟡 **2个中等优先级**: 代码质量和错误处理
+
+**建议:**
+在生产使用前立即解决关键bug。应修复高优先级问题以确保健壮的多GPU训练和广泛的数据集兼容性。中等优先级问题可以在时间允许的情况下解决,以提高可维护性。
+
+---
+
+## 🔗 参考资料
+
+- **CityGaussian V1**: [ECCV 2024论文](https://arxiv.org/pdf/2404.01133)
+- **CityGaussian V2**: [ICLR 2025论文](https://arxiv.org/pdf/2411.00771)
+- **项目页面**:
+ - [V1](https://dekuliutesla.github.io/citygs/)
+ - [V2](https://dekuliutesla.github.io/CityGaussianV2/)
+- **基础框架**: [Gaussian Lightning](https://github.com/yzslab/gaussian-splatting-lightning)
+
+---
+
+**分析完成者:** GitHub Copilot AI Agent
+**日期:** 2026年2月7日
diff --git a/SUMMARY.md b/SUMMARY.md
new file mode 100644
index 0000000..26571ad
--- /dev/null
+++ b/SUMMARY.md
@@ -0,0 +1,184 @@
+# CityGaussian 仓库分析 - 快速摘要 / Quick Summary
+
+[English](#english) | [中文](#中文)
+
+---
+
+
+## 🇨🇳 中文摘要
+
+### 仓库功能
+**CityGaussian** 是用于**大规模3D场景重建**的高斯点云(Gaussian Splatting)框架,实现了ECCV 2024和ICLR 2025两篇论文。主要功能包括:
+
+- 🏙️ **大规模城市场景重建**:处理跨度数百米的场景,支持数千张图像
+- 🚀 **实时渲染**:可交互的高质量渲染,每场景500-1000万高斯点
+- 🎮 **多GPU训练**:支持无限GPU数量的分布式训练
+- 📊 **15+数据集支持**:COLMAP、Blender、MatrixCity、NeRF等
+- 🎨 **30+渲染器**:标准渲染、2D高斯、MipSplatting、外观感知等
+- 📐 **几何评估**:网格提取、精确度/召回率/F1分数评估
+
+### 核心架构
+```
+数据集解析器 → 高斯模型初始化 → 训练循环(渲染+损失+优化+密度控制) → 评估/导出
+```
+
+**关键组件:**
+- **模型**: 10+种高斯表示(标准、可变形、2D、外观感知等)
+- **渲染器**: 30+种专用渲染算法
+- **密度控制**: 自适应分割/克隆/修剪策略
+- **数据处理**: 自动相机去畸变、图像缓存、多线程加载
+
+---
+
+### 🐛 发现的Bug(共8个)
+
+#### 🔴 关键Bug (3个)
+
+**1. 梯度归一化除零错误**
+- **位置**: `internal/gaussian_splatting.py:404`
+- **问题**: 当没有可见高斯点时,`grad_norm_avg`为0导致除零
+- **影响**: 训练崩溃,`nan`梯度
+- **修复**: 添加`torch.clamp(grad_norm_avg, min=1e-10)`
+
+**2. 密度控制器索引越界**
+- **位置**: `internal/density_controllers/vanilla_density_controller.py:198-199`
+- **问题**: 克隆后`grads.shape[0]`可能超过`n_init_points`
+- **影响**: `RuntimeError: index out of bounds`
+- **修复**: 添加边界检查`min(grads.shape[0], n_init_points)`
+
+**3. 球谐通道索引错误**
+- **位置**: `internal/models/vanilla_gaussian.py:116`
+- **问题**: `shs[:, 3:, 1:]`索引超出RGB通道(应为`shs[:, :, 1:]`)
+- **影响**: 球谐初始化错误
+- **修复**: 修改为`shs[:, :, 1:] = 0.0`
+
+#### 🟠 高优先级 (3个)
+
+**4. 张量转整数类型错误**
+- **位置**: `vanilla_density_controller.py:222`
+- **修复**: `int(selected_pts_mask.sum())`
+
+**5. RGBA图像uint8模式失败**
+- **位置**: `dataset.py:104-114`
+- **修复**: 在uint8分支添加RGBA alpha混合处理
+
+**6. 分布式数据分配不均**
+- **位置**: `dataset.py:166-171`
+- **修复**: 使用`np.array_split(self.indices, world_size)`
+
+#### 🟡 中等优先级 (2个)
+
+**7. 裸except捕获所有异常** (`dataset.py:287-290`)
+**8. 异步缓存线程安全** (`dataset.py:202-220`)
+
+---
+
+### 📊 性能基准
+
+| 场景 | SSIM | PSNR | 高斯点数 |
+|------|------|------|----------|
+| MatrixCity Aerial | 0.859 | 27.26 | 8.57M |
+| Upper Campus | 0.779 | 25.78 | 7.87M |
+| SMBU | 0.794 | 24.00 | 5.33M |
+
+### 建议
+✅ **立即修复**: 3个关键bug(可能导致训练崩溃)
+⚠️ **优先修复**: 3个高优先级bug(影响多GPU训练和数据集兼容性)
+💡 **改进建议**: 2个中等优先级问题(提高代码健壮性)
+
+---
+
+
+## 🇬🇧 English Summary
+
+### Repository Functionality
+**CityGaussian** is a Gaussian Splatting framework for **large-scale 3D scene reconstruction**, implementing ECCV 2024 and ICLR 2025 papers. Key features:
+
+- 🏙️ **Large-Scale Urban Reconstruction**: Handle scenes spanning 500m+, thousands of images
+- 🚀 **Real-Time Rendering**: Interactive high-quality rendering with 5-10M Gaussians per scene
+- 🎮 **Multi-GPU Training**: Distributed training supporting unlimited GPUs
+- 📊 **15+ Dataset Parsers**: COLMAP, Blender, MatrixCity, NeRF, etc.
+- 🎨 **30+ Renderers**: Standard, 2D Gaussian, MipSplatting, appearance-aware, etc.
+- 📐 **Geometric Evaluation**: Mesh extraction, precision/recall/F1-score metrics
+
+### Core Architecture
+```
+Dataset Parser → Gaussian Initialization → Training Loop (Render+Loss+Optimize+Density) → Eval/Export
+```
+
+**Key Components:**
+- **Models**: 10+ Gaussian representations (vanilla, deformable, 2D, appearance-aware, etc.)
+- **Renderers**: 30+ specialized rendering algorithms
+- **Density Control**: Adaptive split/clone/prune strategies
+- **Data Processing**: Auto camera undistortion, image caching, multi-threaded loading
+
+---
+
+### 🐛 Bugs Found (8 Total)
+
+#### 🔴 Critical Bugs (3)
+
+**1. Division by Zero in Gradient Normalization**
+- **Location**: `internal/gaussian_splatting.py:404`
+- **Issue**: `grad_norm_avg` can be 0 when no Gaussians visible
+- **Impact**: Training crash, `nan` gradients
+- **Fix**: Add `torch.clamp(grad_norm_avg, min=1e-10)`
+
+**2. Index Out of Bounds in Density Controller**
+- **Location**: `internal/density_controllers/vanilla_density_controller.py:198-199`
+- **Issue**: `grads.shape[0]` may exceed `n_init_points` after cloning
+- **Impact**: `RuntimeError: index out of bounds`
+- **Fix**: Add bounds check `min(grads.shape[0], n_init_points)`
+
+**3. Spherical Harmonics Channel Index Error**
+- **Location**: `internal/models/vanilla_gaussian.py:116`
+- **Issue**: `shs[:, 3:, 1:]` indexes beyond RGB channels (should be `shs[:, :, 1:]`)
+- **Impact**: Incorrect SH initialization
+- **Fix**: Change to `shs[:, :, 1:] = 0.0`
+
+#### 🟠 High Priority (3)
+
+**4. Tensor to Integer Type Error**
+- **Location**: `vanilla_density_controller.py:222`
+- **Fix**: `int(selected_pts_mask.sum())`
+
+**5. RGBA Image uint8 Mode Failure**
+- **Location**: `dataset.py:104-114`
+- **Fix**: Add RGBA alpha blending in uint8 branch
+
+**6. Uneven Distributed Data Splitting**
+- **Location**: `dataset.py:166-171`
+- **Fix**: Use `np.array_split(self.indices, world_size)`
+
+#### 🟡 Medium Priority (2)
+
+**7. Bare except Catches All Exceptions** (`dataset.py:287-290`)
+**8. Async Caching Thread Safety** (`dataset.py:202-220`)
+
+---
+
+### 📊 Performance Benchmarks
+
+| Scene | SSIM | PSNR | Gaussians |
+|-------|------|------|-----------|
+| MatrixCity Aerial | 0.859 | 27.26 | 8.57M |
+| Upper Campus | 0.779 | 25.78 | 7.87M |
+| SMBU | 0.794 | 24.00 | 5.33M |
+
+### Recommendations
+✅ **Fix Immediately**: 3 critical bugs (can crash training)
+⚠️ **Priority Fix**: 3 high-priority bugs (affect multi-GPU & dataset compatibility)
+💡 **Improvement**: 2 medium-priority issues (enhance code robustness)
+
+---
+
+## 📄 Full Reports
+
+For detailed analysis with code examples and fixes:
+- 📘 **English**: See `REPOSITORY_ANALYSIS.md`
+- 📗 **中文**: 查看 `REPOSITORY_ANALYSIS_CN.md`
+
+---
+
+**Analysis Date**: February 7, 2026
+**Analyzer**: GitHub Copilot AI Agent