mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-02-10 18:09:58 +00:00
ini inpaint
This commit is contained in:
@@ -313,54 +313,54 @@ legacy_preprocessors = {
|
||||
"OpenPose"
|
||||
]
|
||||
},
|
||||
"inpaint_global_harmonious": {
|
||||
"label": "inpaint_global_harmonious",
|
||||
"call_function": identity,
|
||||
"unload_function": None,
|
||||
"managed_model": None,
|
||||
"model_free": False,
|
||||
"no_control_mode": False,
|
||||
"resolution": None,
|
||||
"slider_1": None,
|
||||
"slider_2": None,
|
||||
"slider_3": None,
|
||||
"priority": 0,
|
||||
"tags": [
|
||||
"Inpaint"
|
||||
]
|
||||
},
|
||||
"inpaint_only": {
|
||||
"label": "inpaint_only",
|
||||
"call_function": identity,
|
||||
"unload_function": None,
|
||||
"managed_model": None,
|
||||
"model_free": False,
|
||||
"no_control_mode": False,
|
||||
"resolution": None,
|
||||
"slider_1": None,
|
||||
"slider_2": None,
|
||||
"slider_3": None,
|
||||
"priority": 100,
|
||||
"tags": [
|
||||
"Inpaint"
|
||||
]
|
||||
},
|
||||
"inpaint_only+lama": {
|
||||
"label": "inpaint_only+lama",
|
||||
"call_function": lama_inpaint,
|
||||
"unload_function": unload_lama_inpaint,
|
||||
"managed_model": "model_lama",
|
||||
"model_free": False,
|
||||
"no_control_mode": False,
|
||||
"resolution": None,
|
||||
"slider_1": None,
|
||||
"slider_2": None,
|
||||
"slider_3": None,
|
||||
"priority": 0,
|
||||
"tags": [
|
||||
"Inpaint"
|
||||
]
|
||||
},
|
||||
# "inpaint_global_harmonious": {
|
||||
# "label": "inpaint_global_harmonious",
|
||||
# "call_function": identity,
|
||||
# "unload_function": None,
|
||||
# "managed_model": None,
|
||||
# "model_free": False,
|
||||
# "no_control_mode": False,
|
||||
# "resolution": None,
|
||||
# "slider_1": None,
|
||||
# "slider_2": None,
|
||||
# "slider_3": None,
|
||||
# "priority": 0,
|
||||
# "tags": [
|
||||
# "Inpaint"
|
||||
# ]
|
||||
# },
|
||||
# "inpaint_only": {
|
||||
# "label": "inpaint_only",
|
||||
# "call_function": identity,
|
||||
# "unload_function": None,
|
||||
# "managed_model": None,
|
||||
# "model_free": False,
|
||||
# "no_control_mode": False,
|
||||
# "resolution": None,
|
||||
# "slider_1": None,
|
||||
# "slider_2": None,
|
||||
# "slider_3": None,
|
||||
# "priority": 100,
|
||||
# "tags": [
|
||||
# "Inpaint"
|
||||
# ]
|
||||
# },
|
||||
# "inpaint_only+lama": {
|
||||
# "label": "inpaint_only+lama",
|
||||
# "call_function": lama_inpaint,
|
||||
# "unload_function": unload_lama_inpaint,
|
||||
# "managed_model": "model_lama",
|
||||
# "model_free": False,
|
||||
# "no_control_mode": False,
|
||||
# "resolution": None,
|
||||
# "slider_1": None,
|
||||
# "slider_2": None,
|
||||
# "slider_3": None,
|
||||
# "priority": 0,
|
||||
# "tags": [
|
||||
# "Inpaint"
|
||||
# ]
|
||||
# },
|
||||
"instant_id_face_embedding": {
|
||||
"label": "instant_id_face_embedding",
|
||||
"call_function": functools.partial(g_insight_face_instant_id_model.run_model_instant_id, return_keypoints=False),
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
from modules_forge.supported_preprocessor import Preprocessor, PreprocessorParameter
|
||||
from modules_forge.shared import add_supported_preprocessor
|
||||
from modules_forge.forge_util import numpy_to_pytorch
|
||||
|
||||
|
||||
class PreprocessorInpaint(Preprocessor):
|
||||
def __init__(self, name, use_inpaint_sampler=False, use_lama=False):
|
||||
super().__init__()
|
||||
self.name = name
|
||||
self.use_inpaint_sampler = use_inpaint_sampler
|
||||
self.use_lama = use_lama
|
||||
self.tags = ['Inpaint']
|
||||
self.model_filename_filters = ['inpaint']
|
||||
self.slider_resolution = PreprocessorParameter(visible=False)
|
||||
|
||||
def process_before_every_sampling(self, process, cond, *args, **kwargs):
|
||||
return
|
||||
|
||||
def process_after_every_sampling(self, process, params, *args, **kwargs):
|
||||
return
|
||||
|
||||
|
||||
add_supported_preprocessor(PreprocessorInpaint(
|
||||
name='inpaint_global_harmonious',
|
||||
use_inpaint_sampler=False,
|
||||
use_lama=False
|
||||
))
|
||||
|
||||
add_supported_preprocessor(PreprocessorInpaint(
|
||||
name='inpaint_only',
|
||||
use_inpaint_sampler=False,
|
||||
use_lama=False
|
||||
))
|
||||
|
||||
add_supported_preprocessor(PreprocessorInpaint(
|
||||
name='inpaint_only+lama',
|
||||
use_inpaint_sampler=False,
|
||||
use_lama=False
|
||||
))
|
||||
@@ -535,6 +535,18 @@ class ControlNetForForgeOfficial(scripts.Script):
|
||||
logger.info(f"ControlNet Method {params.preprocessor.name} patched.")
|
||||
return
|
||||
|
||||
@torch.no_grad()
|
||||
@torch.inference_mode()
|
||||
def process_unit_after_every_sampling(self,
|
||||
p: StableDiffusionProcessing,
|
||||
unit: external_code.ControlNetUnit,
|
||||
params: ControlNetCachedParameters,
|
||||
*args, **kwargs):
|
||||
|
||||
params.preprocessor.process_after_every_sampling(process=p, params=params, **kwargs)
|
||||
params.model.process_after_every_sampling(process=p, params=params, **kwargs)
|
||||
return
|
||||
|
||||
def process(self, p, *args, **kwargs):
|
||||
self.current_params = {}
|
||||
for i, unit in enumerate(self.get_enabled_units(p)):
|
||||
@@ -549,7 +561,9 @@ class ControlNetForForgeOfficial(scripts.Script):
|
||||
self.process_unit_before_every_sampling(p, unit, self.current_params[i], *args, **kwargs)
|
||||
return
|
||||
|
||||
def postprocess(self, p, processed, *args):
|
||||
def postprocess_batch(self, p, *args, **kwargs):
|
||||
for i, unit in enumerate(self.get_enabled_units(p)):
|
||||
self.process_unit_after_every_sampling(p, unit, self.current_params[i], *args, **kwargs)
|
||||
self.current_params = {}
|
||||
return
|
||||
|
||||
|
||||
@@ -29,6 +29,9 @@ class ControlModelPatcher:
|
||||
def process_before_every_sampling(self, process, cond, *args, **kwargs):
|
||||
return
|
||||
|
||||
def process_after_every_sampling(self, process, params, *args, **kwargs):
|
||||
return
|
||||
|
||||
|
||||
class ControlNetPatcher(ControlModelPatcher):
|
||||
@staticmethod
|
||||
|
||||
@@ -62,6 +62,9 @@ class Preprocessor:
|
||||
def process_before_every_sampling(self, process, cond, *args, **kwargs):
|
||||
return
|
||||
|
||||
def process_after_every_sampling(self, process, params, *args, **kwargs):
|
||||
return
|
||||
|
||||
def __call__(self, input_image, resolution, slider_1=None, slider_2=None, slider_3=None, **kwargs):
|
||||
return input_image
|
||||
|
||||
|
||||
Reference in New Issue
Block a user