Git Product home page Git Product logo

gradient-variance-loss's Introduction

Gradient Variance Loss

report

[ICASSP 2022] Official implementation of the Gradient Variance loss presented in the paper paper "Gradient Variance Loss for Structure-Enhanced Image Super-Resolution".

Requirements

for installing required packages run pip install -r requirements.txt

Usage

To train the VDSR model with the gradient variance loss run the following command

python train.py --dataroot [path to DIV2K dataset] --cuda

Introduction

"Gradient Variance Loss for Structure-Enhanced Image Super-Resolution"

By Lusine Abrahamyan, Anh Minh Truong, Wilfried Philips and Nikos Deligiannis.

Approach

We observe that gradient maps of images generated by the models trained with the L1/L2 losses have significantly lower variance than the gradient maps of the original high-resolution images.

In this work, we introduce a structure-enhancing loss function, coined Gradient Variance (GV) loss, to minimize the difference between the variances of predicted and original gradient maps and generate textures with perceptual-pleasant details.

Performance

Public benchmark test results and DIV2K validation results (PSNR(dB) / SSIM).

Citation

If you find the code useful for your research, please consider citing our works

@article{abrahamyangvloss,
  title={Gradient Variance Loss for Structure-Enhanced Image Super-Resolution},
  author={Lusine, Abrahamyan and  Anh Minh, Truong and  Wilfried, Philips and Nikos, Deligiannis},
  journal={Proceedings of the International Conference on Acoustics, Speech, and Signal Processing (ICASSP)},
  publisher = {IEEE},
  year={2022}
}

Acknowledgement

Codes for the VDSR model are from pytorch-vdsr.

gradient-variance-loss's People

Contributors

lusinlu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

gradient-variance-loss's Issues

How to set "--gradloss_weight"

The "--gradloss_weight" was set to 0.01 in the MSE+GV Loss mode. How to set it when using other loss functions, such as L1?

tensorflow 1.x implementation

Was able to get this to work in tf 1.x, tested to work on 1.15.4 with NumPy 1.18.0

def gradientvariance(target, output, size = 128):
    kernel_x = tf.constant([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]], tf.float32)
    kernel_x = tf.expand_dims(tf.expand_dims(kernel_x, 2), 3)
    kernel_y = tf.constant([[1, 2, 1], [0, 0, 0], [-1, -2, -1]], tf.float32)
    kernel_y = tf.expand_dims(tf.expand_dims(kernel_y, 2), 3)
    
    grayoutput = grayoutput = tf.expand_dims(tf.reduce_mean(output, axis = -1), 3)
    grayoutput = tf.placeholder_with_default(grayoutput,[None,size,size,1])
    graytarget =  tf.expand_dims(tf.reduce_mean(target, axis = -1), 3)
    graytarget = tf.placeholder_with_default(graytarget,[None,size,size,1])
    
    gxtarget = tf.nn.conv2d(graytarget, kernel_x, padding = 'SAME')
    gytarget = tf.nn.conv2d(graytarget, kernel_y,  padding = 'SAME')
    gxoutput = tf.nn.conv2d(grayoutput, kernel_x, padding = 'SAME')
    gyoutput = tf.nn.conv2d(grayoutput, kernel_y, padding = 'SAME')
    
    gx_target_patches = tf.image.extract_image_patches(gxtarget, ksizes = [1, 8, 8, 1],
                                                       strides = [1, 8, 8, 1],
                                                       rates = [1, 1, 1, 1], padding = 'VALID')
    gy_target_patches = tf.image.extract_image_patches(gytarget, ksizes = [1, 8, 8, 1],
                                                       strides = [1, 8, 8, 1],
                                                       rates = [1, 1, 1, 1], padding = 'VALID')
    gx_output_patches = tf.image.extract_image_patches(gxoutput, ksizes = [1, 8, 8, 1],
                                                       strides = [1, 8, 8, 1],
                                                       rates = [1, 1, 1, 1], padding = 'VALID')
    gy_output_patches = tf.image.extract_image_patches(gyoutput, ksizes = [1, 8, 8, 1],
                                                       strides = [1, 8, 8, 1],
                                                       rates = [1, 1, 1, 1], padding = 'VALID')
    var_target_x = tf.math.reduce_variance(gx_target_patches, axis=(1, 2))
    var_output_x = tf.math.reduce_variance(gx_output_patches, axis=(1, 2))
    var_target_y = tf.math.reduce_variance(gy_target_patches, axis=(1, 2))
    var_output_y = tf.math.reduce_variance(gy_output_patches, axis=(1, 2))
    
    return (tf.reduce_mean(tf.abs(var_target_x - var_output_x)) + 
            tf.reduce_mean(tf.abs(var_target_y + var_output_y)))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.