From c2f1e43656ce14521cd586cfb72cba381453ac49 Mon Sep 17 00:00:00 2001 From: jitsuCM Date: Thu, 22 Oct 2020 09:17:48 +0200 Subject: [PATCH] Quick fix for special case no-upscale 1.0 upscale --- src/upscaler.py | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/src/upscaler.py b/src/upscaler.py index 1122361..cbb1bbb 100755 --- a/src/upscaler.py +++ b/src/upscaler.py @@ -624,30 +624,34 @@ class Upscaler: remaining_scaling_ratio = math.ceil(output_scale) self.scaling_jobs = [] - - while remaining_scaling_ratio > 1: - for ratio in supported_scaling_ratios: - if ratio >= remaining_scaling_ratio: - self.scaling_jobs.append(ratio) - remaining_scaling_ratio /= ratio - break - - else: - - found = False - for i in supported_scaling_ratios: - for j in supported_scaling_ratios: - if i * j >= remaining_scaling_ratio: - self.scaling_jobs.extend([i, j]) - remaining_scaling_ratio /= i * j - found = True - break - if found is True: + + # special case for 1.0 upscale ratio + if remaining_scaling_ratio == 1: + self.scaling_jobs.append(1) + else: + while remaining_scaling_ratio > 1: + for ratio in supported_scaling_ratios: + if ratio >= remaining_scaling_ratio: + self.scaling_jobs.append(ratio) + remaining_scaling_ratio /= ratio break - if found is False: - self.scaling_jobs.append(supported_scaling_ratios[-1]) - remaining_scaling_ratio /= supported_scaling_ratios[-1] + else: + + found = False + for i in supported_scaling_ratios: + for j in supported_scaling_ratios: + if i * j >= remaining_scaling_ratio: + self.scaling_jobs.extend([i, j]) + remaining_scaling_ratio /= i * j + found = True + break + if found is True: + break + + if found is False: + self.scaling_jobs.append(supported_scaling_ratios[-1]) + remaining_scaling_ratio /= supported_scaling_ratios[-1] else: self.scaling_jobs = [output_scale]