# DnCNN and NAFNet Pre-trained Denoising Nodes - Quick Start Guide # DnCNN and NAFNet Pre-trained Denoising Nodes ## โœ… Installation Complete! You now have **two state-of-the-art pre-trained denoising nodes** that work immediately without any training! --- ## ๐Ÿ“ฆ What Was Installed ### Files Created: - `models/dncnn_architecture.py` - DnCNN model and processor - `models/nafnet_architecture.py` - NAFNet model and processor - `nodes/dncnn_node.py` - DnCNN ComfyUI node - `nodes/nafnet_node.py` - NAFNet ComfyUI node - Both `__init__.py` files updated for registration --- ## ๐Ÿš€ Quick Start ### Step 1: Restart ComfyUI Completely close and restart ComfyUI to load the new nodes. ### Step 2: Find the Nodes Look under: **Eric's Image Processing โ†’ Pre-trained Denoisers** - **DnCNN Denoise (Pre-trained)** - **NAFNet Denoise (Pre-trained)** ### Step 3: Use Them! Just connect an image and run - they work immediately! **First use**: Weights will download automatically (~2-10MB per model). This happens once, then they're cached. --- ## ๐ŸŽฏ DnCNN Denoise Node ### Overview Classic deep learning denoiser from 2017 that still performs excellently. ### Available Models: 1. **dncnn_25** (Default, Recommended) - Noise level: ฯƒ=25 - Best for moderate noise - Grayscale processing 2. **dncnn_15** - Noise level: ฯƒ=15 - Best for light noise - Grayscale processing 3. **dncnn_50** - Noise level: ฯƒ=50 - Best for heavy noise - Grayscale processing 4. **dncnn3** - Blind denoising (any noise level) - Grayscale processing - More flexible but slightly less accurate 5. **dncnn_color_blind** - Blind denoising for RGB images - Color processing - Most versatile ### When to Use DnCNN: - โœ… Fast processing needed - โœ… Film grain or moderate noise - โœ… You know the approximate noise level - โœ… Smaller file sizes preferred ### Model Size: ~2-3 MB per model ### Speed: โšกโšกโšก Very Fast --- ## ๐Ÿš€ NAFNet Denoise Node ### Overview State-of-the-art 2022 architecture with no activation functions - more efficient! ### Available Models: 1. **nafnet-width32** (Default, Recommended) - Lighter, faster model - ~2M parameters - Best for speed 2. **nafnet-width64** - Balanced quality/speed - ~8M parameters - Best all-around 3. **nafnet-sidd** - Trained on real-world noise (SIDD dataset) - Best for camera noise, ISO noise - Handles complex real-world scenarios ### When to Use NAFNet: - โœ… Best quality needed - โœ… Real-world camera noise - โœ… Complex noise patterns - โœ… Latest technology preferred ### Model Size: ~8-30 MB per model ### Speed: โšกโšก Fast --- ## ๐Ÿ“Š Comparison: DnCNN vs NAFNet | Feature | DnCNN | NAFNet | |---------|-------|--------| | **Year** | 2017 | 2022 | | **Speed** | Faster โšกโšกโšก | Fast โšกโšก | | **Quality** | Excellent โญโญโญโญ | State-of-Art โญโญโญโญโญ | | **Size** | Smaller (2-3MB) | Larger (8-30MB) | | **Best For** | Known noise levels | Real-world noise | | **Film Grain** | Very Good | Excellent | | **Color** | Limited | Full RGB | --- ## ๐Ÿ’ก Usage Tips ### For Film Grain: ``` 1. Try DnCNN-25 first (fast, good results) 2. If not enough โ†’ Try NAFNet-width32 3. For best quality โ†’ Use NAFNet-sidd ``` ### For Camera Noise: ``` 1. Start with NAFNet-sidd (trained for real-world) 2. Alternative: NAFNet-width64 (more general) 3. Fast option: DnCNN-color-blind ``` ### For Synthetic Noise: ``` 1. Know noise level? โ†’ Use matching DnCNN model 2. Unknown noise? โ†’ Use NAFNet-width32 3. Very noisy? โ†’ Try DnCNN-50 ``` ### Batch Processing: Both nodes support batch processing automatically: - Connect multiple images - All processed with same settings - Faster than processing one-by-one --- ## ๐Ÿ”ง Technical Details ### DnCNN Architecture: - 17-layer CNN with residual learning - Predicts noise, not clean image - Batch normalization for stability - ~670K parameters ### NAFNet Architecture: - No activation functions (unique!) - Simple gating mechanisms instead - U-Net style encoder-decoder - Layer normalization - 2M-8M parameters ### Automatic Weight Management: - Weights download automatically on first use - Cached in: `models/pretrained_weights/` - Shared across all uses - No manual downloading needed --- ## ๐ŸŽจ Example Workflows ### Simple Denoising: ``` Load Image โ†’ DnCNN/NAFNet โ†’ Save Image ``` ### Compare Models: ``` Load Image โ†’ DnCNN-25 โ†’ Preview โ†˜ NAFNet-32 โ†’ Preview ``` ### Denoise + Enhance: ``` Load Image โ†’ NAFNet โ†’ BM3D โ†’ Sharpen โ†’ Save ``` --- ## ๐Ÿ› Troubleshooting ### "Weights not downloading" - Check internet connection - Check firewall settings - Weights come from GitHub - ensure access - Manual download possible from GitHub releases ### "Out of memory" - Use DnCNN (smaller memory footprint) - Use NAFNet-width32 instead of width64 - Process images at lower resolution - Enable CPU mode if GPU insufficient ### "Slow processing" - Normal on first use (downloading weights) - Subsequent uses are much faster - Consider DnCNN for speed priority - GPU highly recommended --- ## ๐Ÿ“š References ### DnCNN: **Paper**: "Beyond a Gaussian Denoiser: Residual Learning of Deep CNN for Image Denoising" **Authors**: Zhang et al. **Published**: IEEE TIP 2017 **Weights Source**: https://github.com/cszn/KAIR ### NAFNet: **Paper**: "Simple Baselines for Image Restoration" **Authors**: Chen et al. **Published**: ECCV 2022 **Weights Source**: https://github.com/megvii-research/NAFNet --- ## โœจ Summary You now have **professional-grade denoising** that: - โœ… Works immediately - no training required - โœ… Automatically downloads weights - โœ… Handles multiple noise types - โœ… Processes batches efficiently - โœ… Offers speed/quality options **Quick Recommendation**: Start with **DnCNN-25** for most images. If you need better quality or have real camera noise, upgrade to **NAFNet-width32** or **NAFNet-sidd**. --- Enjoy your new denoising superpowers! ๐ŸŽ‰