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.
For now:
using Pkg;
Pkg.add(url="https://github.com/gsahonero/DISTS.jl")
Pkg.dev("DISTS")
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)
ref
:Image
- reference imagedist
:Image
- distorted imagenet_params
:Dict
- holds the weights fromnet_params.mat
available at the original repository.weights
:Dict
- holds the alpha-beta weights fromalpha_beta.mat
.resize_img
:Boolean
- to enable the use ofimresize
when appliesuse_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 fromnet_params.mat
- (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.