英文

多尺度深度超分辨率系统(MDSR)

MDSR模型是在DIV2K上预训练的(800张图像进行训练,扩增为4000张图像,100张验证图像),用于2x、3x和4x图像超分辨率。该模型在Lim等人(2017年)的论文中首次提出,并于 this repository 首次发布。

图像超分辨率的目标是从单个低分辨率(LR)图像恢复高分辨率(HR)图像。下面的图像显示了真实图像(HR)、双三次插值图像和模型放大图像。

模型描述

MDSR是一个使用更深和更宽的架构(32个ResBlocks和256个通道)来提高性能的模型。它使用全局和局部跳跃连接,并且缩放操作在网络的末尾进行。它不使用批归一化层(输入和输出具有类似的分布,归一化中间特征可能不可取),而是使用常量缩放层来确保稳定的训练。作者经验证明L1损失函数(绝对误差)在性能和计算方面都更好。

使用范围和限制

您可以使用预训练模型将图像放大2x、3x和4x。您还可以使用训练器在自己的数据集上训练模型。

如何使用

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

pip install super-image

以下是使用预训练模型放大图像的方法:

from super_image import MdsrModel, 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 = MdsrModel.from_pretrained('eugenesiow/mdsr', 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, MdsrModel, MdsrConfig

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

config = MdsrConfig(
    scale=4,                                # train a model to upscale 4x
)
model = MdsrModel(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。它们与双三次基准进行比较。

|数据集|缩放|双三次|mdsr||---|---|---|---||Set5|2x|33.64/0.9292|38.04/0.9608||Set5|3x|30.39/0.8678|35.11/0.9406||Set5|4x|28.42/0.8101|32.26/0.8953||Set14|2x|30.22/0.8683|33.71/0.9184||Set14|3x|27.53/0.7737|31.06/0.8593||Set14|4x|25.99/0.7023|28.77/0.7856||BSD100|2x|29.55/0.8425|33.79/0.9256||BSD100|3x|27.20/0.7382|29.66/0.8196||BSD100|4x|25.96/0.6672|28.53/0.7653||Urban100|2x|26.66/0.8408|32.14/0.9283||Urban100|3x| |29.29/0.8738||Urban100|4x|23.14/0.6573|26.07/0.7851|

您可以在预训练模型上轻松运行评估的笔记本如下:

BibTeX条目和引用信息

@article{ahn2018fast,
  title={Fast, Accurate, and Lightweight Super-Resolution with Cascading Residual Network},
  author={Ahn, Namhyuk and Kang, Byungkon and Sohn, Kyung-Ah},
  journal={arXiv preprint arXiv:1803.08664},
  year={2018}
}