From 403fdb2d2d31265f631060f6ea79c5c515090a29 Mon Sep 17 00:00:00 2001 From: "Alex \"mcmonkey\" Goodwin" Date: Wed, 21 Jun 2023 18:34:41 -0700 Subject: [PATCH] Sawtooth mode --- dynthres_core.py | 4 ++-- scripts/dynamic_thresholding.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dynthres_core.py b/dynthres_core.py index fa453f1..fa696fe 100644 --- a/dynthres_core.py +++ b/dynthres_core.py @@ -37,8 +37,6 @@ class DynThresh: scale *= 1.0 - math.pow(self.step / max, self.sched_val) elif mode == "Linear Repeating": portion = ((self.step / max) * self.sched_val) % 1.0 - start = math.floor(portion) - portion -= start scale *= (0.5 - portion) * 2 if portion < 0.5 else (portion - 0.5) * 2 elif mode == "Cosine Repeating": curved = 1.0 - (math.cos((self.step / max) * 3.14159 * self.sched_val) * 0.5 + 0.5) @@ -46,6 +44,8 @@ class DynThresh: start = math.floor(portion) portion -= start scale *= (0.5 - portion) * 2 if portion < 0.5 else (portion - 0.5) * 2 + elif mode == "Sawtooth": + scale *= ((self.step / max) * self.sched_val) % 1.0 scale += min return scale diff --git a/scripts/dynamic_thresholding.py b/scripts/dynamic_thresholding.py index 48ebbd5..e6b6bdb 100644 --- a/scripts/dynamic_thresholding.py +++ b/scripts/dynamic_thresholding.py @@ -20,8 +20,8 @@ except Exception as e: print(f"\n\n======\nError! UniPC sampler support failed to load! Is your WebUI up to date?\n(Error: {e})\n======") ######################### Data values ######################### -VALID_MODES = ["Constant", "Linear Down", "Cosine Down", "Half Cosine Down", "Linear Up", "Cosine Up", "Half Cosine Up", "Power Up", "Power Down", "Linear Repeating", "Cosine Repeating"] -MODES_WITH_VALUE = ["Power Up", "Power Down", "Linear Repeating", "Cosine Repeating"] +VALID_MODES = ["Constant", "Linear Down", "Cosine Down", "Half Cosine Down", "Linear Up", "Cosine Up", "Half Cosine Up", "Power Up", "Power Down", "Linear Repeating", "Cosine Repeating", "Sawtooth"] +MODES_WITH_VALUE = ["Power Up", "Power Down", "Linear Repeating", "Cosine Repeating", "Sawtooth"] ######################### Script class entrypoint ######################### class Script(scripts.Script):