From f643a631552a11e78f1e791f01faadb3490079ee Mon Sep 17 00:00:00 2001 From: lvmin Date: Sun, 8 Oct 2023 17:42:42 -0700 Subject: [PATCH] fix incorrect cpds --- fooocus_extras/preprocessors.py | 20 +++++++++++++++++--- fooocus_version.py | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/fooocus_extras/preprocessors.py b/fooocus_extras/preprocessors.py index ce31a7a..b19a7cb 100644 --- a/fooocus_extras/preprocessors.py +++ b/fooocus_extras/preprocessors.py @@ -37,6 +37,20 @@ def cpds(x): # See http://www.cse.cuhk.edu.hk/leojia/projects/color2gray/index.html # See https://docs.opencv.org/3.0-beta/modules/photo/doc/decolor.html - y = np.ascontiguousarray(x[:, :, ::-1].copy()) - y = cv2.decolor(y)[0] - return y + raw = cv2.GaussianBlur(x, (0, 0), 1.0) + density, boost = cv2.decolor(raw) + + raw = raw.astype(np.float32) + density = density.astype(np.float32) + boost = boost.astype(np.float32) + + offset = np.sum((raw - boost) ** 2.0, axis=2) ** 0.5 + + result = density + offset + + result -= np.min(result) + result /= np.max(result) + + result *= 255.0 + + return result.clip(0, 255).astype(np.uint8) diff --git a/fooocus_version.py b/fooocus_version.py index e76c565..07fbeef 100644 --- a/fooocus_version.py +++ b/fooocus_version.py @@ -1 +1 @@ -version = '2.1.21' +version = '2.1.22'