mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-04-30 03:01:15 +00:00
i
This commit is contained in:
@@ -10,4 +10,40 @@ from modules_forge.shared import Preprocessor, PreprocessorParameter, preprocess
|
|||||||
from legacy_preprocessors.preprocessor_compiled import legacy_preprocessors
|
from legacy_preprocessors.preprocessor_compiled import legacy_preprocessors
|
||||||
|
|
||||||
|
|
||||||
a = 0
|
class LegacyPreprocessor(Preprocessor):
|
||||||
|
def __init__(self, legacy_dict):
|
||||||
|
super().__init__()
|
||||||
|
self.name = legacy_dict['name']
|
||||||
|
self.call_function = legacy_dict['call_function']
|
||||||
|
self.unload_function = legacy_dict['unload_function']
|
||||||
|
self.managed_model = legacy_dict['managed_model']
|
||||||
|
self.do_not_need_model = legacy_dict['model_free']
|
||||||
|
self.show_control_mode = not legacy_dict['no_control_mode']
|
||||||
|
self.sorting_priority = legacy_dict['priority']
|
||||||
|
self.tags = legacy_dict['tags']
|
||||||
|
|
||||||
|
if legacy_dict['resolution'] is None:
|
||||||
|
self.resolution = PreprocessorParameter(visible=False)
|
||||||
|
else:
|
||||||
|
self.resolution = PreprocessorParameter(**legacy_dict['resolution'])
|
||||||
|
|
||||||
|
if legacy_dict['slider_1'] is None:
|
||||||
|
self.slider_1 = PreprocessorParameter(visible=False)
|
||||||
|
else:
|
||||||
|
self.slider_1 = PreprocessorParameter(**legacy_dict['slider_1'])
|
||||||
|
|
||||||
|
if legacy_dict['slider_2'] is None:
|
||||||
|
self.slider_2 = PreprocessorParameter(visible=False)
|
||||||
|
else:
|
||||||
|
self.slider_2 = PreprocessorParameter(**legacy_dict['slider_2'])
|
||||||
|
|
||||||
|
if legacy_dict['slider_3'] is None:
|
||||||
|
self.slider_3 = PreprocessorParameter(visible=False)
|
||||||
|
else:
|
||||||
|
self.slider_3 = PreprocessorParameter(**legacy_dict['slider_3'])
|
||||||
|
|
||||||
|
|
||||||
|
for k, v in legacy_preprocessors.items():
|
||||||
|
p = LegacyPreprocessor(v)
|
||||||
|
p.name = k
|
||||||
|
add_preprocessor(p)
|
||||||
|
|||||||
@@ -71,4 +71,4 @@ class PreprocessorNormalBae(Preprocessor):
|
|||||||
return remove_pad(normal_image)
|
return remove_pad(normal_image)
|
||||||
|
|
||||||
|
|
||||||
add_preprocessor(PreprocessorNormalBae)
|
add_preprocessor(PreprocessorNormalBae())
|
||||||
|
|||||||
@@ -78,6 +78,9 @@ class ControlNetExampleForge(scripts.Script):
|
|||||||
input_image = cv2.resize(input_image, (width, height))
|
input_image = cv2.resize(input_image, (width, height))
|
||||||
canny_image = cv2.cvtColor(cv2.Canny(input_image, 100, 200), cv2.COLOR_GRAY2RGB)
|
canny_image = cv2.cvtColor(cv2.Canny(input_image, 100, 200), cv2.COLOR_GRAY2RGB)
|
||||||
|
|
||||||
|
from modules_forge.shared import shared_preprocessors
|
||||||
|
a = 0
|
||||||
|
|
||||||
# # Or you can get a list of preprocessors in this way
|
# # Or you can get a list of preprocessors in this way
|
||||||
# from modules_forge.shared import shared_preprocessors
|
# from modules_forge.shared import shared_preprocessors
|
||||||
# canny_preprocessor = shared_preprocessors['canny']
|
# canny_preprocessor = shared_preprocessors['canny']
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ shared_preprocessors = {}
|
|||||||
|
|
||||||
def add_preprocessor(preprocessor):
|
def add_preprocessor(preprocessor):
|
||||||
global shared_preprocessors
|
global shared_preprocessors
|
||||||
p = preprocessor()
|
p = preprocessor
|
||||||
shared_preprocessors[p.name] = p
|
shared_preprocessors[p.name] = p
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -104,5 +104,5 @@ class PreprocessorCanny(Preprocessor):
|
|||||||
return remove_pad(canny_image)
|
return remove_pad(canny_image)
|
||||||
|
|
||||||
|
|
||||||
add_preprocessor(PreprocessorNone)
|
add_preprocessor(PreprocessorNone())
|
||||||
add_preprocessor(PreprocessorCanny)
|
add_preprocessor(PreprocessorCanny())
|
||||||
|
|||||||
Reference in New Issue
Block a user