β οΈ Work in Progress: This project is actively being developed. Current models work but we're training improved versions for better quality!
A universal neural network latent upscaler that supports SD1.5, SDXL, Flux, and Wan2.2 models. Uses trained neural networks instead of simple interpolation for higher quality latent upscaling.
Built upon the excellent foundation of Ttl's ComfyUi_NNLatentUpscale - this project extends the original work with universal model support and improved architectures.
- π― Universal Support: Works with SD1.5, SDXL, Flux, and Wan2.2 models
- π§ Neural Network Upscaling: Significantly better quality than bilinear interpolation
- βοΈ Configurable Scale Factor: 1.0x to 2.0x upscaling with smooth interpolation
- π Automatic Model Loading: Automatically detects and loads the correct model for each architecture
- πΎ Memory Efficient: Smart model loading/unloading to save VRAM
- π¨ Custom Wan2.2 Model: Includes our own trained Wan2.2 upscaler (more models coming!)
- π§ Easy Integration: Drop-in replacement for standard latent upscaling
cd ComfyUI/custom_nodes
git clone https://github.com/DenRakEiw/WAN_NN_Latent_Upscale- Download the repository as ZIP
- Extract to
ComfyUI/custom_nodes/wan_nn_latent/ - Restart ComfyUI
- ComfyUI (latest version recommended)
- PyTorch with CUDA support (for GPU acceleration)
- Python 3.8+
- Add the node:
Add Node -> latent -> Universal NN Latent Upscale - Connect your latent: Connect any latent tensor as input
- Select model type: Choose SD 1.5, SDXL, Flux, or Wan2.2
- Set upscale factor: 1.0x to 2.0x (1.5x recommended)
- Connect output: Use the upscaled latent in your workflow
[VAE Encode] -> [Universal NN Latent Upscale] -> [Your Model] -> [VAE Decode]
- MSE: 0.1038 (vs 0.1054 bilinear) - β 1.5% improvement
- PSNR: 9.84 dB (vs 9.77 dB bilinear) - β 0.7 dB improvement
- SSIM: 0.3247 (vs 0.2690 bilinear) - β 20.7% improvement
π¬ In Development: Training new models with 2,852 real photo samples for significantly better quality!
The following model files are included:
| Model | File | Size | Status | Quality |
|---|---|---|---|---|
| SD1.5 | sd15_resizer.pt |
12.6MB | β Stable | Good |
| SDXL | sdxl_resizer.pt |
12.6MB | β Stable | Good |
| Flux | flux_resizer.pt |
25.3MB | β Stable | Good |
| Wan2.2 | wan2.2_resizer_best.pt |
3.9MB | Improving |
π Note: Models are automatically downloaded on first use if not present.
- SD1.5/SDXL: 0.13025 (4-channel latents)
- Flux: 0.3611 (16-channel latents)
- Wan2.2: 0.3604 (16-channel latents, empirically determined)
- SD1.5/SDXL: 4 channels β 128 hidden β 4 channels
- Flux/Wan2.2: 16 channels β 256 hidden β 16 channels
- π§ Encoder: 3-layer CNN feature extractor with ReLU activation
- π Upsampler: Transpose convolution + refinement layers
- β Skip Connections: Residual learning for detail preservation
- π Adaptive Scaling: Supports any scale factor between 1.0-2.0x
[VAE Encode] -> [Universal NN Latent Upscale] -> [Model] -> [VAE Decode]
[Load Image] -> [VAE Encode] -> [Universal NN Latent Upscale] ->
[ControlNet/LoRA] -> [Model] -> [VAE Decode] -> [Save Image]
- β Basic functionality working
- β All model types supported
- β Stable performance
β οΈ Wan2.2 model needs improvement
- π Training improved Wan2.2 model with 2,852 real photos
- π 20,000 training steps with advanced loss functions
- π Better detail preservation and artifact reduction
- π Performance benchmarking against other methods
- π Support for custom model training
- π Additional model architectures
- π Batch processing optimization
- π Advanced configuration options
# Generate dataset
python create_real_dataset.py
# Train model (example for Wan2.2)
python slow_long_training_20k.py
# Test model
python test_model_performance.py- Add configuration to
MODEL_CONFIGSinlatent_resizer.py - Create specialized resizer class if needed
- Add model file path to
weight_pathsinnn_upscale.py - Update the dropdown in
INPUT_TYPES
- π Bug reports and feature requests welcome
- π§ Pull requests for improvements appreciated
- π Share your training results and model improvements
- π Documentation improvements always helpful
| Issue | Solution |
|---|---|
| Model not found | Models auto-download on first use. Check internet connection. |
| CUDA out of memory | Reduce batch size in workflow or use CPU mode |
| Wrong model selected | Ensure latent type matches selected model (check channels) |
| Slow performance | Enable GPU acceleration, check CUDA installation |
| Quality issues | Try different scale factors, ensure correct model type |
# In nn_upscale.py, set:
force_reload = True # Reloads model on every execution- π Check this README and troubleshooting section
- π Open an issue on GitHub
- π¬ Join the ComfyUI Discord community
- π§ Contact: [your-email@example.com]
| Method | SSIM β | PSNR β | MSE β | Speed |
|---|---|---|---|---|
| Bilinear | 0.2690 | 9.77 dB | 0.1054 | β‘β‘β‘ |
| Our NN (v1.0) | 0.3247 | 9.84 dB | 0.1038 | β‘β‘ |
| Our NN (v2.0) | Training... | Training... | Training... | β‘β‘ |
π Higher SSIM and PSNR = better quality, Lower MSE = better accuracy
This project is licensed under the MIT License - see the LICENSE file for details.
- π― Primary Foundation: Ttl's ComfyUi_NNLatentUpscale - This project builds directly upon Ttl's excellent work and neural network architecture. The core upscaling approach, model structure, and ComfyUI integration patterns are based on their pioneering implementation.
- π€ Additional Inspiration: naripok's contributions to the NN latent upscaling community
- πΌοΈ ComfyUI Team: For the amazing framework that makes this possible
- π€ Model Teams: Wan2.2, Flux, Stability AI for their incredible models
- π Community: ComfyUI Discord community for feedback and support
- π Datasets: DIV2K, COCO2017 for training data
This project would not exist without Ttl's groundbreaking work on neural network latent upscaling. Their original implementation provided:
- The core neural network architecture for latent upscaling
- ComfyUI node integration patterns
- Training methodologies and loss functions
- Proof of concept that NN upscaling significantly outperforms bilinear interpolation
Our contribution extends this foundation with universal model support, improved training data, and enhanced architectures while maintaining compatibility with the original approach.
- π ComfyUI
- π Documentation
- π Issues
- π¬ Discussions