/pytorch-smooth

Primary LanguagePythonMIT LicenseMIT

Pytorch Smooth

The model has three main components

  • sobel to create horizontal sobel kernels
  • Hessian to calculate the hessian matrix per channel
  • Smoothness to calculate a smoothness value per channel

The smoothness value is the negative mean, of the sums, of the squared elements, of the per pixel hessian matrices.

Usage

The smoothness module can be applied to neural network outputs and the resulting value can be substracted from the loss to train networks to give smooth outputs.

loss = loss - smoothness

Example

The example generates a non-smooth random image and uses gradient decent to smooth it out. example

Installation

pip install git+https://github.com/tasptz/pytorch-smooth