-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
92 additions
and
4 deletions.
There are no files selected for viewing
Binary file added
BIN
+858 KB
blog/images/mpv_upscaling/upsampling/Fractional/Gamma/ArtCNN_C4F16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+862 KB
blog/images/mpv_upscaling/upsampling/Fractional/Gamma/ArtCNN_C4F16_LL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
blog/images/mpv_upscaling/upsampling/Fractional/Gamma/benchmark_result.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.\ArtCNN_C4F16.png, 0.005601357197683343, 35.7403993580635, 0.9904909031229484, 0.9989654356979804 | ||
.\ArtCNN_C4F16_LL.png, 0.006343756541762611, 34.50056758931284, 0.9897800006133683, 0.9985779114639624 | ||
.\ravu-zoom-ar-r3.png, 0.006091159025887937, 34.6927139254382, 0.9884723573169553, 0.9987004637110991 |
51 changes: 51 additions & 0 deletions
51
blog/images/mpv_upscaling/upsampling/Fractional/Gamma/benchmarker.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from scipy.ndimage import convolve | ||
import numpy as np | ||
import cv2 | ||
import glob | ||
import skimage | ||
|
||
def msssim(im1, im2, data_range = 255, channel_axis = None): | ||
level = 5 | ||
weights = np.array([0.0448, 0.2856, 0.3001, 0.2363, 0.1333]) | ||
downsample_filter = np.ones((2, 2))/4.0 | ||
msssim = [] | ||
for _ in range(level): | ||
ssim_res = skimage.metrics.structural_similarity(im1 = im1, im2 = im2, data_range = data_range, channel_axis = channel_axis) | ||
msssim.append(ssim_res) | ||
if channel_axis: | ||
filtered_im1 = np.zeros_like(im1) | ||
filtered_im2 = np.zeros_like(im2) | ||
for channel in range(channel_axis): | ||
filtered_im1[:, :, channel] = convolve(im1[:, :, channel], downsample_filter, mode='reflect') | ||
filtered_im2[:, :, channel] = convolve(im2[:, :, channel], downsample_filter, mode='reflect') | ||
im1 = filtered_im1[::2, ::2, :] | ||
im2 = filtered_im2[::2, ::2, :] | ||
else: | ||
filtered_im1 = convolve(im1, downsample_filter, mode='reflect') | ||
filtered_im2 = convolve(im2, downsample_filter, mode='reflect') | ||
im1 = filtered_im1[::2, ::2] | ||
im2 = filtered_im2[::2, ::2] | ||
return np.average(np.array(msssim), weights=weights) | ||
|
||
output_file = open("benchmark_result.txt", "w") | ||
|
||
print("Starting benchmarks") | ||
|
||
reference = cv2.imread('./reference.png', cv2.IMREAD_COLOR) | ||
reference = cv2.cvtColor(reference, cv2.COLOR_BGR2GRAY, 0).astype(float) / 255.0 | ||
|
||
filelist = sorted(glob.glob('./*.png')) | ||
for myFile in filelist: | ||
if not "downscaled" in myFile: | ||
image = cv2.imread(myFile, cv2.IMREAD_COLOR) | ||
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY, 0).astype(float) / 255.0 | ||
|
||
mae_score = np.mean(np.absolute(reference - image)) | ||
psnr_score = skimage.metrics.peak_signal_noise_ratio(reference, image) | ||
ssim_score = skimage.metrics.structural_similarity(reference, image, data_range = 1, channel_axis = None) | ||
msssim_score = msssim(reference, image, data_range = 1, channel_axis = None) | ||
|
||
print(f"{myFile} - MAE: {mae_score}, PSNR: {psnr_score}, SSIM: {ssim_score}, MS-SSIM: {msssim_score}\n") | ||
output_file.write(f"{myFile}, {mae_score}, {psnr_score}, {ssim_score}, {msssim_score}\n") | ||
|
||
output_file.close() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+865 KB
blog/images/mpv_upscaling/upsampling/Fractional/Gamma/ravu-zoom-ar-r3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters