其他分享
首页 > 其他分享> > SRCNN-图像超分辨的学习

SRCNN-图像超分辨的学习

作者:互联网

《Learning a Deep Convolutional Network for Image Super-Resolution》的学习

(Learning a Deep Convolutional Network for Image Super-Resolution,ECCV2014)

文章摘要

本文利用深度学习的方法实现单张图的超分辨。该方法是直接学习从低分辨到高分辨端到端的映射。该映射是利用深度卷积神经网络(Convolutional Neural Network,CNN)所实现的。该深度卷积神经网络是轻量级的,但是依旧效果比经典超分辨方法要好,不仅复原质量高,而且速度快。

算法模型

模型结构和稀疏编码在卷积中的应用
在这里插入图片描述
在这里插入图片描述

Patch extraction and representation
F1(Y)=max(0,W1Y+B1) F_{1}(\mathbf{Y})=\max \left(0, W_{1} * \mathbf{Y}+B_{1}\right) F1​(Y)=max(0,W1​∗Y+B1​)

Non-linear mapping
F2(Y)=max(0,W2F1(Y)+B2) F_{2}(\mathbf{Y})=\max \left(0, W_{2} * F_{1}(\mathbf{Y})+B_{2}\right) F2​(Y)=max(0,W2​∗F1​(Y)+B2​)

Reconstruction
F(Y)=W3F2(Y)+B3 F(\mathbf{Y})=W_{3} * F_{2}(\mathbf{Y})+B_{3} F(Y)=W3​∗F2​(Y)+B3​

在该论文中,利用Relu作为收敛函数,利用最小均方差函数为Loss函数。
Loss函数
L(Θ)=1ni=1nF(Yi;Θ)Xi2 L(\Theta)=\frac{1}{n} \sum_{i=1}^{n}\left\|F\left(\mathbf{Y}_{i} ; \Theta\right)-\mathbf{X}_{i}\right\|^{2} L(Θ)=n1​i=1∑n​∥F(Yi​;Θ)−Xi​∥2

TensorFlow代码

// 主函数
from model import SRCNN
from utils import input_setup

import numpy as np
import tensorflow as tf

import pprint
import os

flags = tf.app.flags
flags.DEFINE_integer("epoch", 15000, "Number of epoch [15000]")
flags.DEFINE_integer("batch_size", 128, "The size of batch images [128]")
flags.DEFINE_integer("image_size", 33, "The size of image to use [33]")
flags.DEFINE_integer("label_size", 21, "The size of label to produce [21]")
flags.DEFINE_float("learning_rate", 1e-4, "The learning rate of gradient descent algorithm [1e-4]")
flags.DEFINE_integer("c_dim", 1, "Dimension of image color. [1]")
flags.DEFINE_integer("scale", 3, "The size of scale factor for preprocessing input image [3]")
flags.DEFINE_integer("stride", 14, "The size of stride to apply input image [14]")
flags.DEFINE_string("checkpoint_dir", "checkpoint", "Name of checkpoint directory [checkpoint]")
flags.DEFINE_string("sample_dir", "sample", "Name of sample directory [sample]")
flags.DEFINE_boolean("is_train", True, "True for training, False for testing [True]")
FLAGS = flags.FLAGS

pp = pprint.PrettyPrinter()

def main(_):
  pp.pprint(flags.FLAGS.__flags)

  if not os.path.exists(FLAGS.checkpoint_dir):
    os.makedirs(FLAGS.checkpoint_dir)
  if not os.path.exists(FLAGS.sample_dir):
    os.makedirs(FLAGS.sample_dir)

  with tf.Session() as sess:
    srcnn = SRCNN(sess, 
                  image_size=FLAGS.image_size, 
                  label_size=FLAGS.label_size, 
                  batch_size=FLAGS.batch_size,
                  c_dim=FLAGS.c_dim, 
                  checkpoint_dir=FLAGS.checkpoint_dir,
                  sample_dir=FLAGS.sample_dir)

    srcnn.train(FLAGS)
    
if __name__ == '__main__':
  tf.app.run()

Tensorflow完整代码:Tensorflow
MATLAB代码: MATLAB.
Caffe代码:Caffe

结果

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
双三次差值的 : PSNR=26.633759 dB
SRCNN的: PSNR=29.290147 dB
相比两种算法的PSNR,SRCNN有着明显的提升。

SRCNN的不足

  1. 利用Relu作为收敛函数虽然速度快,但是训练的时候很”脆弱”,很容易就”die”;
  2. SRCNN需要先通过bicubic方法放大尺寸。

标签:SRCNN,FLAGS,图像,分辨,flags,DEFINE,dir,size
来源: https://blog.csdn.net/z1282429194/article/details/94357267