Skip to content

A Julia implementation of Deep Image Structure and Texture Similarity (DISTS) metric

License

Notifications You must be signed in to change notification settings

gsahonero/DISTS.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DISTS.jl

Build Status

A Julia implementation of Deep Image Structure and Texture Similarity (DISTS) metric. This implementation follows the logic implemented in DISTS. Please, check comments before using.

Setup

For now:

using Pkg;
Pkg.add(url="https://github.com/gsahonero/DISTS.jl")
Pkg.dev("DISTS")

Usage

The classic example:

using DISTS
using Images

# Read images
ref = Images.load("../images/r0.png")
dist = Images.load("../images/r1.png")

# Load the pretrained network parameters and perceptual weights
net_params, weights = load_weights("../DISTS/weights/net_param.mat", "../DISTS/weights/alpha_beta.mat")

# Define resize image flag and use_gpu flag
resize_img = false   # If required. Its usage is not trivial.
use_gpu = false     # GPU acceleration is not implemented yet

# Calculate the perceptual quality score (DISTS)
score = DISTS_score(ref, dist, net_params, weights, resize_img, use_gpu; pretraining = "DISTS")

# Output the score
println("Perceptual quality score: ", score)

Parameters of DISTS_score

  • ref:Image - reference image
  • dist:Image - distorted image
  • net_params: Dict - holds the weights from net_params.mat available at the original repository.
  • weights: Dict - holds the alpha-beta weights from alpha_beta.mat.
  • resize_img: Boolean - to enable the use of imresize when applies
  • use_gpu: Boolean - to enable GPU acceleration (not implemented yet)
  • pretraining:String - defines which pretraining setup will be used. By default set to "DISTS". It supports "Flux" an "Mixed". "Flux" loads the 16 layers of VGG without modification. "Mixed" loads the convolutional layers of VGG without modification, but the pooling layers weights use the weights from net_params.mat

Comments

  • (AFAIK) Julia does not have an implementation of the DISTS metric, this "package" should do the trick.
  • Flux implementation seems to produce different results with respect to PyTorch and MATLAB despite having the same weights. The results are similar and consistent, though.
  • The DISTS score between two equal images is near to zero.
  • Pooling layers from DISTS are implemented as DepthwiseConvolutions.

About

A Julia implementation of Deep Image Structure and Texture Similarity (DISTS) metric

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages