This commit is contained in:
lllyasviel
2024-01-28 07:28:56 -08:00
parent 878c7ecfad
commit c3159c0e0e
2 changed files with 6 additions and 14 deletions

View File

@@ -428,15 +428,11 @@ class ControlNetExampleForge(scripts.Script):
# Below are two methods to preprocess images.
# Method 1: do it in your own way
canny_image_1 = cv2.cvtColor(cv2.Canny(input_image, 100, 200), cv2.COLOR_GRAY2RGB)
canny_image = cv2.cvtColor(cv2.Canny(input_image, 100, 200), cv2.COLOR_GRAY2RGB)
# Method 2: use built-in preprocessor
from modules_forge.shared import shared_preprocessors
canny_image_2 = shared_preprocessors['canny'](input_image, 100, 200)
# The two methods will give your same result
assert np.allclose(canny_image_1, canny_image_2)
canny_image = canny_image_1
# from modules_forge.shared import shared_preprocessors
# canny_image = shared_preprocessors['canny'](input_image, 100, 200)
# Output preprocessor result. Now called every sampling. Cache in your own way.
p.extra_result_images.append(canny_image)

View File

@@ -80,15 +80,11 @@ class ControlNetExampleForge(scripts.Script):
# Below are two methods to preprocess images.
# Method 1: do it in your own way
canny_image_1 = cv2.cvtColor(cv2.Canny(input_image, 100, 200), cv2.COLOR_GRAY2RGB)
canny_image = cv2.cvtColor(cv2.Canny(input_image, 100, 200), cv2.COLOR_GRAY2RGB)
# Method 2: use built-in preprocessor
from modules_forge.shared import shared_preprocessors
canny_image_2 = shared_preprocessors['canny'](input_image, 100, 200)
# The two methods will give your same result
assert np.allclose(canny_image_1, canny_image_2)
canny_image = canny_image_1
# from modules_forge.shared import shared_preprocessors
# canny_image = shared_preprocessors['canny'](input_image, 100, 200)
# Output preprocessor result. Now called every sampling. Cache in your own way.
p.extra_result_images.append(canny_image)