英文

增强型深度残差网络用于单幅图像超分辨率(EDSR)

EDSR模型在DIV2K上进行了预训练(800张图像进行训练,增强为4000张图像,100张验证图像),用于2x,3x和4x图像超分辨率。它是由Lim等人在2017年的 Enhanced Deep Residual Networks for Single Image Super-Resolution 论文中提出的,并在 this repository 中首次发布。

图像超分辨率的目标是从单个低分辨率(LR)图像恢复高分辨率(HR)图像。下图显示了真实图像(HR),双三次上采样x2和EDSR上采样x2。

模型描述

EDSR是一个使用更深更宽的架构(32个ResBlock和256通道)来提高性能的模型。它使用全局和局部跳过连接,并且上采样是在网络末尾完成的。它不使用批归一化层(输入和输出具有类似的分布,归一化中间特征可能不可取),而是使用常量缩放层来确保稳定的训练。作者使用L1损失函数(绝对误差)而不是L2(均方误差),经验证表现更好且需要更少的计算。

这是一个基本模型(约5MB对比约100MB),仅包含16个ResBlock和64个通道。

预期用途和限制

您可以使用预训练的模型将图像提高2倍,3倍和4倍。您还可以使用训练器在自己的数据集上训练模型。

如何使用

模型可以与 super_image 库一起使用:

pip install super-image

以下是使用预训练模型提高图像分辨率的方法:

from super_image import EdsrModel, ImageLoader
from PIL import Image
import requests

url = 'https://paperswithcode.com/media/datasets/Set5-0000002728-07a9793f_zA3bDjj.jpg'
image = Image.open(requests.get(url, stream=True).raw)

model = EdsrModel.from_pretrained('eugenesiow/edsr', scale=2)      # scale 2, 3 and 4 models available
inputs = ImageLoader.load_image(image)
preds = model(inputs)

ImageLoader.save_image(preds, './scaled_2x.png')                        # save the output 2x scaled image to `./scaled_2x.png`
ImageLoader.save_compare(inputs, preds, './scaled_2x_compare.png')      # save an output comparing the super-image with a bicubic scaling

培训数据

用于2x,3x和4x图像超分辨率的模型在 DIV2K 上进行了预训练。此数据集包含800个高质量(2K分辨率)图像进行训练,增强为4000个图像,并使用100个验证图像作为开发集(图像编号为801到900)。

培训程序

预处理

我们遵循 Wang et al. 的预处理和训练方法。通过使用双三次插值作为调整大小方法,将高分辨率(HR)图像的大小减小2倍,3倍和4倍来创建低分辨率(LR)图像。在训练过程中,使用从LR输入中大小为64×64的RGB补丁,以及其对应的HR补丁。在预处理阶段对训练集进行数据增强,从原始图像的四个角和中心创建五个图像。

我们需要huggingface datasets 库来下载数据:

pip install datasets

以下代码获取数据并对数据进行预处理/增强。

from datasets import load_dataset
from super_image.data import EvalDataset, TrainDataset, augment_five_crop

augmented_dataset = load_dataset('eugenesiow/Div2k', 'bicubic_x4', split='train')\
    .map(augment_five_crop, batched=True, desc="Augmenting Dataset")                                # download and augment the data with the five_crop method
train_dataset = TrainDataset(augmented_dataset)                                                     # prepare the train dataset for loading PyTorch DataLoader
eval_dataset = EvalDataset(load_dataset('eugenesiow/Div2k', 'bicubic_x4', split='validation'))      # prepare the eval dataset for the PyTorch DataLoader

预训练

该模型在GPU上进行了训练。以下是训练代码:

from super_image import Trainer, TrainingArguments, EdsrModel, EdsrConfig

training_args = TrainingArguments(
    output_dir='./results',                 # output directory
    num_train_epochs=1000,                  # total number of training epochs
)

config = EdsrConfig(
    scale=4,                                # train a model to upscale 4x
)
model = EdsrModel(config)

trainer = Trainer(
    model=model,                         # the instantiated model to be trained
    args=training_args,                  # training arguments, defined above
    train_dataset=train_dataset,         # training dataset
    eval_dataset=eval_dataset            # evaluation dataset
)

trainer.train()

评估结果

评估指标包括 PSNR SSIM

评估数据集包括:

下面的结果列被表示为PSNR/SSIM。它们与基于双三次插值的基线进行比较。

|数据集 |比例 |双三次插值|EDSR ||--- |--- |--- |--- ||Set5 |2x |33.64/0.9292 | 38.19/0.9612 ||Set5 |3x |30.39/0.8678 | 35.31/0.9421 ||Set5 |4x |28.42/0.8101 | 32.5/0.8986 ||Set14 |2x |30.22/0.8683 | 33.99/0.9215 ||Set14 |3x |27.53/0.7737 | 31.18/0.862 ||Set14 |4x |25.99/0.7023 | 28.92/0.7899 ||BSD100 |2x |29.55/0.8425 | 33.89/0.9266 ||BSD100 |3x |27.20/0.7382 | 29.77/0.8224 ||BSD100 |4x |25.96/0.6672 | 28.62/0.7689 ||Urban100 |2x |26.66/0.8408 | 32.68/0.9331 ||Urban100 |3x | | 29.75/0.8825 ||Urban100 |4x |23.14/0.6573 | 26.53/0.7995 |

您可以找到一个笔记本来方便地对预训练模型进行评估:

BibTeX条目和引用信息

@InProceedings{Lim_2017_CVPR_Workshops,
  author = {Lim, Bee and Son, Sanghyun and Kim, Heewon and Nah, Seungjun and Lee, Kyoung Mu},
  title = {Enhanced Deep Residual Networks for Single Image Super-Resolution},
  booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR) Workshops},
  month = {July},
  year = {2017}
}