This commit is contained in:
lllyasviel
2024-01-29 08:03:03 -08:00
parent 18254a0984
commit c071e4494f
4 changed files with 44 additions and 5 deletions

View File

@@ -10,4 +10,40 @@ from modules_forge.shared import Preprocessor, PreprocessorParameter, preprocess
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)

View File

@@ -71,4 +71,4 @@ class PreprocessorNormalBae(Preprocessor):
return remove_pad(normal_image)
add_preprocessor(PreprocessorNormalBae)
add_preprocessor(PreprocessorNormalBae())

View File

@@ -78,6 +78,9 @@ class ControlNetExampleForge(scripts.Script):
input_image = cv2.resize(input_image, (width, height))
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
# from modules_forge.shared import shared_preprocessors
# canny_preprocessor = shared_preprocessors['canny']

View File

@@ -19,7 +19,7 @@ shared_preprocessors = {}
def add_preprocessor(preprocessor):
global shared_preprocessors
p = preprocessor()
p = preprocessor
shared_preprocessors[p.name] = p
return
@@ -104,5 +104,5 @@ class PreprocessorCanny(Preprocessor):
return remove_pad(canny_image)
add_preprocessor(PreprocessorNone)
add_preprocessor(PreprocessorCanny)
add_preprocessor(PreprocessorNone())
add_preprocessor(PreprocessorCanny())