diff --git a/modules/control/run.py b/modules/control/run.py index 26e02a108..fc24d932f 100644 --- a/modules/control/run.py +++ b/modules/control/run.py @@ -369,6 +369,7 @@ def control_run(state: str = '', # pylint: disable=keyword-arg-before-vararg ) p.state = state p.is_tile = False + p.orig_init_images = inputs # TODO modernui: monkey-patch for missing tabs.select event if p.selected_scale_tab_before == 0 and p.resize_name_before != 'None' and p.scale_by_before != 1 and inputs is not None and len(inputs) > 0: diff --git a/scripts/xyz/xyz_grid_shared.py b/scripts/xyz/xyz_grid_shared.py index a4347a948..8635eb802 100644 --- a/scripts/xyz/xyz_grid_shared.py +++ b/scripts/xyz/xyz_grid_shared.py @@ -289,11 +289,8 @@ def apply_detailer(p, opt, x): def apply_control(field): def fun(p, x, xs): - if getattr(p, 'xyz_init_images', None) is not None and len(getattr(p, 'xyz_init_images', [])) > 0: # backup init images since they get modified - p.init_images = getattr(p, 'xyz_init_images', None) - else: - p.xyz_init_images = getattr(p, 'init_images', None) - if getattr(p, 'init_images', None) is None or len(getattr(p, 'init_images', [])) == 0: + init_images = getattr(p, 'orig_init_images', None) or getattr(p, 'init_images', None) or getattr(p, 'orig_init_images', None) or [] + if init_images is None or len(init_images) == 0: shared.log.error('XYZ grid apply control: init image is required') return if field in ['controlnet', 't2i adapter', 'processor']: @@ -331,7 +328,7 @@ def apply_control(field): active_process, active_model, active_strength, active_start, active_end = run.check_active(p, unit.type, run.unit.current) has_models, selected_models, control_conditioning, control_guidance_start, control_guidance_end = run.check_enabled(p, unit.type, run.unit.current, active_model, active_strength, active_start, active_end) pipe = run.set_pipe(p, has_models, unit.type, selected_models, active_model, active_strength, control_conditioning, control_guidance_start, control_guidance_end) - _processed_image = processor.preprocess_image(p, pipe, input_image=p.init_images[0], unit_type=unit.type, active_process=active_process, active_model=active_model, selected_models=selected_models, has_models=has_models) + _processed_image = processor.preprocess_image(p, pipe, input_image=init_images[0], unit_type=unit.type, active_process=active_process, active_model=active_model, selected_models=selected_models, has_models=has_models) if pipe is not None: shared.sd_model = pipe elif field == 'control_start':