Upload LumiTrace model
Browse files- .gitattributes +5 -0
- README.md +134 -0
- config.yml +84 -0
- model.pth +3 -0
- requirements.txt +47 -0
- samples/compare_1.png +3 -0
- samples/compare_111.png +3 -0
- samples/compare_22.png +3 -0
- samples/compare_23.png +3 -0
- samples/compare_55.png +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,8 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
samples/compare_1.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
samples/compare_111.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
samples/compare_22.png filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
samples/compare_23.png filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
samples/compare_55.png filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- low-light-enhancement
|
| 5 |
+
- video-processing
|
| 6 |
+
- temporal-consistency
|
| 7 |
+
- computer-vision
|
| 8 |
+
- image-enhancement
|
| 9 |
+
library_name: pytorch
|
| 10 |
+
pipeline_tag: image-to-image
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# LumiTrace: Temporal Low-Light Video Enhancement
|
| 14 |
+
|
| 15 |
+
**LumiTrace** is a state-of-the-art temporal video enhancement model designed to brighten low-light videos while maintaining temporal consistency and preserving fine details.
|
| 16 |
+
|
| 17 |
+
## Model Description
|
| 18 |
+
|
| 19 |
+
LumiTrace combines the power of **RetinexFormer** (a Retinex-based image enhancement architecture) with custom **temporal modules** to process video sequences. It uses a 2-stage training strategy to achieve exceptional performance on challenging low-light scenarios.
|
| 20 |
+
|
| 21 |
+
### Key Features
|
| 22 |
+
|
| 23 |
+
- 🎬 **Temporal Consistency**: Processes 3-frame sequences to eliminate flickering
|
| 24 |
+
- 🌟 **High Quality**: Achieves 22+ dB PSNR and 0.83+ SSIM on LOL benchmarks
|
| 25 |
+
- ⚡ **Memory Efficient**: Supports high-resolution inference via tiled processing
|
| 26 |
+
- 🔧 **Production Ready**: Includes video processing pipeline with automatic resolution standardization
|
| 27 |
+
|
| 28 |
+
### Architecture
|
| 29 |
+
|
| 30 |
+
- **Base**: RetinexFormer (2.2M parameters)
|
| 31 |
+
- **Temporal Modules**: Custom 3D convolution + attention (0.8M parameters)
|
| 32 |
+
- **Total Parameters**: ~3M
|
| 33 |
+
- **Input**: 3-frame sequences (RGB, [0,1] normalized)
|
| 34 |
+
- **Output**: Enhanced center frame
|
| 35 |
+
|
| 36 |
+
## Training Data
|
| 37 |
+
|
| 38 |
+
The model was trained on:
|
| 39 |
+
- **LOL-v1**: 485 training pairs, 15 test pairs
|
| 40 |
+
- **LOL-v2-Real**: 689 training pairs, 100 test pairs
|
| 41 |
+
|
| 42 |
+
Training used synthetic temporal sequences generated from static image pairs with brightness/spatial augmentation.
|
| 43 |
+
|
| 44 |
+
## Training Procedure
|
| 45 |
+
|
| 46 |
+
### Two-Stage Training Strategy
|
| 47 |
+
|
| 48 |
+
**Stage 1** (50 epochs):
|
| 49 |
+
- Freeze RetinexFormer backbone
|
| 50 |
+
- Train only temporal modules
|
| 51 |
+
- Learning rate: 1e-4
|
| 52 |
+
- Loss: L2 reconstruction + temporal consistency
|
| 53 |
+
|
| 54 |
+
**Stage 2** (60 epochs):
|
| 55 |
+
- Unfreeze all parameters
|
| 56 |
+
- Discriminative learning rates:
|
| 57 |
+
- RetinexFormer: 1e-6
|
| 58 |
+
- Temporal modules: 1e-4
|
| 59 |
+
- Loss: L2 + Temporal + Perceptual (VGG)
|
| 60 |
+
|
| 61 |
+
### Performance
|
| 62 |
+
|
| 63 |
+
| Dataset | PSNR | SSIM |
|
| 64 |
+
|---------|------|------|
|
| 65 |
+
| LOL-v1 | 22.70 dB | 0.8389 |
|
| 66 |
+
| LOL-v2-Real | 21.72 dB | 0.8199 |
|
| 67 |
+
|
| 68 |
+
## Usage
|
| 69 |
+
|
| 70 |
+
### Installation
|
| 71 |
+
|
| 72 |
+
```bash
|
| 73 |
+
git clone https://github.com/yourusername/LumiTrace
|
| 74 |
+
cd LumiTrace
|
| 75 |
+
pip install -r requirements.txt
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
### Inference (Python)
|
| 79 |
+
|
| 80 |
+
```python
|
| 81 |
+
from lumitrace.inference import VideoEnhancer
|
| 82 |
+
import yaml
|
| 83 |
+
|
| 84 |
+
# Load config
|
| 85 |
+
with open('configs/lol_v1_temporal.yml', 'r') as f:
|
| 86 |
+
config = yaml.safe_load(f)
|
| 87 |
+
|
| 88 |
+
# Initialize enhancer
|
| 89 |
+
enhancer = VideoEnhancer(
|
| 90 |
+
model_path='checkpoints/lol_v1/stage2/best.pth',
|
| 91 |
+
config=config
|
| 92 |
+
)
|
| 93 |
+
|
| 94 |
+
# Process video
|
| 95 |
+
enhancer.enhance_video(
|
| 96 |
+
input_path='input.mp4',
|
| 97 |
+
output_path='enhanced.mp4'
|
| 98 |
+
)
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
### Inference (CLI)
|
| 102 |
+
|
| 103 |
+
```bash
|
| 104 |
+
./scripts/enhance_video.sh input.mp4 output.mp4
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
## Limitations
|
| 108 |
+
|
| 109 |
+
- Trained primarily on indoor/static scenes (LOL dataset)
|
| 110 |
+
- May struggle with extreme motion or outdoor dynamic lighting
|
| 111 |
+
- Best performance on videos with resolution ≤720p
|
| 112 |
+
- Requires GPU for real-time processing
|
| 113 |
+
|
| 114 |
+
## Citation
|
| 115 |
+
|
| 116 |
+
If you use this model, please cite:
|
| 117 |
+
|
| 118 |
+
```bibtex
|
| 119 |
+
@software{lumitrace2024,
|
| 120 |
+
title={LumiTrace: Temporal Low-Light Video Enhancement},
|
| 121 |
+
author={Your Name},
|
| 122 |
+
year={2024},
|
| 123 |
+
url={https://github.com/yourusername/LumiTrace}
|
| 124 |
+
}
|
| 125 |
+
```
|
| 126 |
+
|
| 127 |
+
## Acknowledgments
|
| 128 |
+
|
| 129 |
+
- Based on [RetinexFormer](https://github.com/caiyuanhao1998/Retinexformer)
|
| 130 |
+
- Trained on [LOL datasets](https://daooshee.github.io/BMVC2018website/)
|
| 131 |
+
|
| 132 |
+
## License
|
| 133 |
+
|
| 134 |
+
Apache 2.0
|
config.yml
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Training configuration for LOL-v1 dataset with temporal consistency
|
| 2 |
+
|
| 3 |
+
# Dataset settings
|
| 4 |
+
dataset:
|
| 5 |
+
name: "LOL-v1"
|
| 6 |
+
root_dir: "data/LOLv1"
|
| 7 |
+
num_frames: 3
|
| 8 |
+
patch_size: 128 # Reduced from 256 for GPU memory
|
| 9 |
+
|
| 10 |
+
# Model settings
|
| 11 |
+
model:
|
| 12 |
+
name: "TemporalRetinexFormer"
|
| 13 |
+
# Retinexformer parameters
|
| 14 |
+
in_channels: 3
|
| 15 |
+
out_channels: 3
|
| 16 |
+
n_feat: 40
|
| 17 |
+
stage: 2
|
| 18 |
+
num_blocks: [1, 1, 1]
|
| 19 |
+
# Temporal parameters
|
| 20 |
+
temporal_feat_channels: 64
|
| 21 |
+
# Training control
|
| 22 |
+
freeze_retinex: false # Set true for Stage 1
|
| 23 |
+
|
| 24 |
+
# Training settings
|
| 25 |
+
training:
|
| 26 |
+
# Stage 1: Frozen Retinexformer
|
| 27 |
+
stage1:
|
| 28 |
+
epochs: 50
|
| 29 |
+
batch_size: 4 # Reduced from 8 for GPU memory
|
| 30 |
+
learning_rate: 1.0e-4
|
| 31 |
+
freeze_retinex: true
|
| 32 |
+
use_perceptual_loss: false
|
| 33 |
+
|
| 34 |
+
# Stage 2: Joint fine-tuning
|
| 35 |
+
stage2:
|
| 36 |
+
epochs: 60
|
| 37 |
+
batch_size: 4 # Reduced from 8 for GPU memory
|
| 38 |
+
# Discriminative learning rates
|
| 39 |
+
retinex_lr: 1.0e-6 # Very low for Retinexformer
|
| 40 |
+
temporal_lr: 1.0e-4 # Normal for temporal modules
|
| 41 |
+
freeze_retinex: false
|
| 42 |
+
use_perceptual_loss: true
|
| 43 |
+
|
| 44 |
+
# Loss settings
|
| 45 |
+
loss:
|
| 46 |
+
reconstruction_weight: 1.0
|
| 47 |
+
temporal_weight: 0.3
|
| 48 |
+
perceptual_weight: 0.1
|
| 49 |
+
reconstruction_type: "l2" # "l1" or "l2"
|
| 50 |
+
|
| 51 |
+
# Optimizer settings
|
| 52 |
+
optimizer:
|
| 53 |
+
type: "AdamW"
|
| 54 |
+
weight_decay: 1.0e-4
|
| 55 |
+
betas: [0.9, 0.999]
|
| 56 |
+
|
| 57 |
+
# Scheduler settings
|
| 58 |
+
scheduler:
|
| 59 |
+
type: "CosineAnnealingLR"
|
| 60 |
+
T_max: 50 # Matches stage1 epochs or stage2 epochs
|
| 61 |
+
eta_min: 1.0e-6
|
| 62 |
+
|
| 63 |
+
# Logging and checkpoints
|
| 64 |
+
logging:
|
| 65 |
+
wandb: true # Use Weights & Biases (fallback to TensorBoard if false)
|
| 66 |
+
log_interval: 10 # Print every N batches
|
| 67 |
+
checkpoint_interval: 5 # Save every N epochs
|
| 68 |
+
save_dir: "checkpoints/lol_v1"
|
| 69 |
+
|
| 70 |
+
# Hardware
|
| 71 |
+
hardware:
|
| 72 |
+
num_workers: 4
|
| 73 |
+
pin_memory: true
|
| 74 |
+
mixed_precision: true # Use automatic mixed precision
|
| 75 |
+
|
| 76 |
+
# Pretrained weights
|
| 77 |
+
pretrained:
|
| 78 |
+
retinexformer: "pretrained_weights/LOL_v1.pth"
|
| 79 |
+
|
| 80 |
+
# Evaluation
|
| 81 |
+
evaluation:
|
| 82 |
+
metrics: ["psnr", "ssim", "temporal_consistency"]
|
| 83 |
+
save_images: true
|
| 84 |
+
num_vis_samples: 5
|
model.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9cf977bd3f2d5fc8d6a10013d2f59db6f3e154cd57efe77a703563424b728bd9
|
| 3 |
+
size 36600526
|
requirements.txt
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
torch>=2.0.0
|
| 2 |
+
torchvision>=0.15.0
|
| 3 |
+
torchaudio>=2.0.0
|
| 4 |
+
|
| 5 |
+
# BasicSR dependencies
|
| 6 |
+
matplotlib>=3.3.0
|
| 7 |
+
scikit-learn>=0.24.0
|
| 8 |
+
scikit-image>=0.18.0
|
| 9 |
+
opencv-python>=4.5.0
|
| 10 |
+
yacs>=0.1.8
|
| 11 |
+
joblib>=1.0.0
|
| 12 |
+
natsort>=7.1.0
|
| 13 |
+
h5py>=3.1.0
|
| 14 |
+
tqdm>=4.60.0
|
| 15 |
+
tensorboard>=2.5.0
|
| 16 |
+
|
| 17 |
+
# Transformer & DL utilities
|
| 18 |
+
einops>=0.4.0
|
| 19 |
+
timm>=0.6.0
|
| 20 |
+
addict>=2.4.0
|
| 21 |
+
future>=0.18.0
|
| 22 |
+
lmdb>=1.2.0
|
| 23 |
+
numpy>=1.21.0
|
| 24 |
+
pyyaml>=5.4.0
|
| 25 |
+
requests>=2.25.0
|
| 26 |
+
scipy>=1.7.0
|
| 27 |
+
yapf>=0.31.0
|
| 28 |
+
|
| 29 |
+
# Perceptual losses
|
| 30 |
+
lpips>=0.1.4
|
| 31 |
+
|
| 32 |
+
# Video processing
|
| 33 |
+
imageio>=2.9.0
|
| 34 |
+
imageio-ffmpeg>=0.4.5
|
| 35 |
+
|
| 36 |
+
# Logging and experiment tracking
|
| 37 |
+
wandb>=0.12.0
|
| 38 |
+
tensorboard>=2.11.0
|
| 39 |
+
torchmetrics>=1.0.0
|
| 40 |
+
|
| 41 |
+
# Utilities
|
| 42 |
+
tqdm>=4.64.0
|
| 43 |
+
python-dotenv>=0.19.0
|
| 44 |
+
Pillow>=8.0.0
|
| 45 |
+
|
| 46 |
+
# HuggingFace Hub (for model upload)
|
| 47 |
+
huggingface_hub>=0.16.0
|
samples/compare_1.png
ADDED
|
Git LFS Details
|
samples/compare_111.png
ADDED
|
Git LFS Details
|
samples/compare_22.png
ADDED
|
Git LFS Details
|
samples/compare_23.png
ADDED
|
Git LFS Details
|
samples/compare_55.png
ADDED
|
Git LFS Details
|