ONNX 模型库
返回模型

说明文档

图像修复模型

概述

本仓库提供高性能的图像修复模型,包括用于各种图像增强任务的 NAFNetSCUNet 实现。这些模型旨在通过去除噪声、伪影和其他瑕疵来修复退化图像,同时保留重要的视觉细节。这些深度学习模型采用先进的神经网络架构,针对计算效率和修复质量进行了优化。

该仓库包含在多个数据集上训练的不同模型变体:用于通用图像修复的 NAFNet-REDS、用于去模糊任务的 NAFNet-GoPro,以及用于降噪的 NAFNet-SIDD。此外,SCUNet 提供了基于 GAN 和 PSNR 优化的两种方法,以实现全面的图像增强。所有模型均以 ONNX 格式导出,以实现高效推理和跨平台兼容性。

这些修复模型支持分块处理,通过内存优化的批处理和可配置的分块大小与重叠区域,高效处理高分辨率图像。该实现支持带有 Alpha 通道的图像(RGBA 格式),并为不同用例提供灵活的参数调节。这些模型在基准测试评估中达到了最先进的性能,同时保持了适合生产环境的实用推理速度。

使用方法

安装

pip install dghs-imgutils

基本用法

from imgutils.restore import restore_with_nafnet, restore_with_scunet
from PIL import Image

# 加载您的退化图像
image = Image.open('degraded_image.jpg')

# 使用 NAFNet 进行修复(推荐用于通用修复)
restored_nafnet = restore_with_nafnet(image, model='REDS')

# 使用 SCUNet 进行修复(替代方案)
restored_scunet = restore_with_scunet(image, model='GAN')

# 保存修复后的图像
restored_nafnet.save('restored_nafnet.jpg')
restored_scunet.save('restored_scunet.jpg')

使用自定义参数的高级用法

from imgutils.restore import restore_with_nafnet

# 针对高分辨率图像的自定义处理参数
restored_image = restore_with_nafnet(
    image, 
    model='SIDD',  # 可选 'REDS', 'GoPro', 'SIDD'
    tile_size=512,  # 更大的分块以获得更好的性能
    tile_overlap=32,  # 更多重叠以获得无缝结果
    batch_size=8,  # 更大的批次大小以加快处理速度
    silent=False  # 显示进度条
)

可用模型

NAFNet 模型

  • NAFNet-REDS:在 REDS 数据集上训练的通用图像修复模型
  • NAFNet-GoPro:专门用于去模糊任务
  • NAFNet-SIDD:针对降噪进行了优化

SCUNet 模型

  • SCUNet-GAN:基于 GAN 的修复,追求感知质量
  • SCUNet-PSNR:PSNR 优化的修复,追求客观指标

模型基准测试

这些模型已针对各种修复任务进行了广泛的基准测试:

  • NAFNet 在去模糊和通用修复方面展现出卓越的性能
  • SCUNet 在降噪和伪影去除方面表现出色
  • 两种模型都通过分块推理支持高分辨率处理

重要说明

  • Alpha 通道支持:所有模型都支持 RGBA 图像(带有 Alpha 通道)
  • 高斯噪声警告:NAFNet 在处理高斯噪声时可能存在问题 — 如有需要,可考虑先用 SCUNet 进行预处理
  • 内存优化:请根据您的硬件配置适当的 tile_size 和 batch_size 参数

原始内容

模型实现细节

该实现使用 dghs-imgutils 库,提供以下功能:

  • 高效的 ONNX 模型加载和推理
  • 用于内存高效处理高分辨率图像的分块处理
  • 用于提升性能的批处理优化
  • 支持多种图像格式和色彩空间

技术架构

这些模型采用:

  • NAFNet:非线性无激活网络,用于高效图像修复
  • SCUNet:Swin-Conv-UNet 架构,用于全面的图像增强
  • ONNX Runtime:跨平台推理引擎,实现最佳性能

引用

@misc{deepghs_image_restoration,
  title        = {{Image Restoration Models: NAFNet and SCUNet Implementations}},
  author       = {deepghs},
  howpublished = {\url{https://huggingface.co/deepghs/image_restoration}},
  year         = {2023},
  note         = {High-performance image restoration models including NAFNet and SCUNet implementations for noise reduction, deblurring, and general image enhancement},
  abstract     = {This repository provides high-performance image restoration models including NAFNet and SCUNet implementations for various image enhancement tasks. The models are designed to restore degraded images by removing noise, artifacts, and other imperfections while preserving important visual details. These deep learning models leverage advanced neural network architectures optimized for computational efficiency and restoration quality. The repository contains multiple model variants trained on different datasets: NAFNet-REDS for general image restoration, NAFNet-GoPro for deblurring tasks, and NAFNet-SIDD for noise reduction. Additionally, SCUNet provides both GAN-based and PSNR-optimized approaches for comprehensive image enhancement.},
  keywords     = {image-restoration, image-enhancement, computer-vision, nafnet, scunet}
}

deepghs/image_restoration

作者 deepghs

image-to-image dghs-imgutils
↓ 0 ♥ 13

创建时间: 2023-10-10 13:24:34+00:00

更新时间: 2025-11-17 13:24:03+00:00

在 Hugging Face 上查看

文件 (10)

.gitattributes
NAFNet-GoPro-width64.onnx ONNX
NAFNet-GoPro-width64_v1.onnx ONNX
NAFNet-REDS-width64.onnx ONNX
NAFNet-REDS-width64_v1.onnx ONNX
NAFNet-SIDD-width64.onnx ONNX
NAFNet-SIDD-width64_v1.onnx ONNX
README.md
SCUNet-GAN.onnx ONNX
SCUNet-PSNR.onnx ONNX