This repository contains implementations of the NAFNet (Nonlinear Activation Free Network) for image restoration tasks such as deblurring and denoising. The core of the project includes a modular framework for easy processing of images using pre-trained models.
- Image Restoration: The core functionality includes deblurring and denoising using state-of-the-art models.
- Modular Design: Separate processors for different tasks, with a base class for common functionality.
- Model Management: Automatically downloads and manages model files for easy usage.
Via PyPI
You can easily install the nafnetlib package from PyPI:
pip install nafnetlib
- Python 3.x
- PyTorch
- PIL (Pillow)
- Other dependencies listed in requirements.txt
You can install the dependencies using pip:
pip install -r requirements.txt
These dependencies will be automatically installed when you install nafnetlib
via pip.
Initialization and Image Processing To use the deblurring or denoising functionality, you can initialize the corresponding processor class (DeblurProcessor or DenoiseProcessor), and then use the process() method to process images.
Here’s an example of how to use the DeblurProcessor
and DenoiseProcessor
:
from PIL import Image
from nafnetlib import DeblurProcessor, DenoiseProcessor
# Initialize the deblurring processor
db_processor = DeblurProcessor(
model_id="reds_width64",
model_dir="/absolute/path/to/model/directory",
device="cuda"
)
# Print available models
print(db_processor.available_models())
# Initialize the denoising processor
db_processor = DenoiseProcessor(
model_id="sidd_width64",
model_dir="/absolute/path/to/model/directory",
device="cuda"
)
# Load image for processing
img_path = "path/to/image/file"
image = Image.open(img_path)
# Process the image (e.g., deblur or denoise)
db_processor.process(image).show()
The following models are available for different image restoration tasks:
Models: gopro_width64
, gopro_width32
Models: sidd_width64
, sidd_width32
Models: reds_width64
These models are derived from the megvii-research/nafnet
GitHub repository.
Baseline-GoPro-*
, Baseline-SIDD-*
and NAFSSR-L_*
When initializing the processors, models are automatically downloaded if they are not found in the specified directory.
Supported models come from megvii-research/nafnet
.
Feel free to fork the repository and submit issues or pull requests. Contributions are welcome!
This project is licensed under the MIT License - see the LICENSE file for details.
If NAFNet helps your research or work, please consider citing NAFNet.
@article{chen2022simple,
title={Simple Baselines for Image Restoration},
author={Chen, Liangyu and Chu, Xiaojie and Zhang, Xiangyu and Sun, Jian},
journal={arXiv preprint arXiv:2204.04676},
year={2022}
}
If NAFSSR helps your research or work, please consider citing NAFSSR.
@InProceedings{chu2022nafssr,
author = {Chu, Xiaojie and Chen, Liangyu and Yu, Wenqing},
title = {NAFSSR: Stereo Image Super-Resolution Using NAFNet},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops},
month = {June},
year = {2022},
pages = {1239-1248}
}