mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 17:24:32 +02:00
multi controlnet-union
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
@@ -611,6 +611,8 @@ def control_run(state: str = '',
|
||||
elif input_type == 1: # Init image same as control
|
||||
if 'control_image' in possible:
|
||||
p.task_args['control_image'] = p.init_images # switch image and control_image
|
||||
if 'control_mode' in possible:
|
||||
p.task_args['control_mode'] = getattr(p, 'control_mode', None)
|
||||
if 'strength' in possible:
|
||||
p.task_args['strength'] = p.denoising_strength
|
||||
p.init_images = [p.override or input_image] * len(active_model)
|
||||
@@ -620,9 +622,14 @@ def control_run(state: str = '',
|
||||
init_image = input_image
|
||||
if 'control_image' in possible:
|
||||
p.task_args['control_image'] = p.init_images # switch image and control_image
|
||||
if 'control_mode' in possible:
|
||||
p.task_args['control_mode'] = getattr(p, 'control_mode', None)
|
||||
if 'strength' in possible:
|
||||
p.task_args['strength'] = p.denoising_strength
|
||||
p.init_images = [init_image] * len(active_model)
|
||||
if hasattr(shared.sd_model, 'controlnet') and len(p.task_args['control_image']) > 1 and (shared.sd_model.__class__.__name__ == 'StableDiffusionXLControlNetUnionPipeline'): # special case for controlnet-union
|
||||
p.task_args['control_image'] = [[x] for x in p.task_args['control_image']]
|
||||
p.task_args['control_mode'] = [[x] for x in p.task_args['control_mode']]
|
||||
|
||||
if is_generator:
|
||||
image_txt = f'{blended_image.width}x{blended_image.height}' if blended_image is not None else 'None'
|
||||
@@ -664,8 +671,6 @@ def control_run(state: str = '',
|
||||
if unit_type == 'lite':
|
||||
p.init_image = [input_image]
|
||||
instance.apply(selected_models, processed_image, control_conditioning)
|
||||
if getattr(p, 'control_mode', None) is not None:
|
||||
p.task_args['control_mode'] = getattr(p, 'control_mode', None)
|
||||
if hasattr(p, 'init_images') and p.init_images is None: # delete empty
|
||||
del p.init_images
|
||||
|
||||
|
||||
@@ -338,14 +338,11 @@ class ControlNetPipeline():
|
||||
classes = [c.__class__.__name__ for c in controlnets]
|
||||
if any(c == 'ControlNetUnionModel' for c in classes):
|
||||
if not all(c == 'ControlNetUnionModel' for c in classes):
|
||||
log.warning(f'Control {what}: units={classes} mixed type')
|
||||
log.warning(f'Control {what}: units={classes} mixed type is not supported')
|
||||
return
|
||||
if isinstance(controlnets, list) and len(controlnets) == 1:
|
||||
controlnets = controlnets[0]
|
||||
cls = StableDiffusionXLControlNetUnionPipeline
|
||||
if len(controlnets) > 1:
|
||||
# TODO controlnet-union multi-unit
|
||||
controlnets = controlnets[0]
|
||||
log.warning(f'Control {what}: units={classes} supports single unit only')
|
||||
else:
|
||||
controlnets = controlnets[0]
|
||||
else:
|
||||
cls = StableDiffusionXLControlNetPipeline
|
||||
self.pipeline = cls(
|
||||
|
||||
Reference in New Issue
Block a user