hako-mikan / sd-webui-regional-prompter

set prompt to divided region
GNU Affero General Public License v3.0
1.48k stars 120 forks source link

Compatibility with webui-forge #299

Open Razunter opened 5 months ago

Razunter commented 5 months ago

Currently, Regional Prompter doesn't work with Forge fork of WebUI, would be great to support it.

Attention mode:

*** Error completing request
*** Arguments: ('task(15o5d7rfdph0l3q)', <gradio.routes.Request object at 0x0000028817C625F0>, '1 BREAK\n2', '', [], 40, 'Restart', 4, 1, 7, 1080, 1920, False, 0.45, 1.5, 'ESRGAN-NMKD-Superscale-4x', 0, 0, 0, 'Use same checkpoint', 'Use same sampler', '', '', [], 0, False, '', 0.8, -1, False, -1, 0, 0, 0, UiControlNetUnit(input_mode=<InputMode.SIMPLE: 'simple'>, use_preview_as_input=False, batch_image_dir='', batch_mask_dir='', batch_input_gallery=[], batch_mask_gallery=[], generated_image=None, mask_image=None, enabled=False, module='None', model='None', weight=1, image=None, resize_mode='Crop and Resize', processor_res=-1, threshold_a=-1, threshold_b=-1, guidance_start=0, guidance_end=1, pixel_perfect=False, control_mode='Balanced'), UiControlNetUnit(input_mode=<InputMode.SIMPLE: 'simple'>, use_preview_as_input=False, batch_image_dir='', batch_mask_dir='', batch_input_gallery=[], batch_mask_gallery=[], generated_image=None, mask_image=None, enabled=False, module='None', model='None', weight=1, image=None, resize_mode='Crop and Resize', processor_res=-1, threshold_a=-1, threshold_b=-1, guidance_start=0, guidance_end=1, pixel_perfect=False, control_mode='Balanced'), UiControlNetUnit(input_mode=<InputMode.SIMPLE: 'simple'>, use_preview_as_input=False, batch_image_dir='', batch_mask_dir='', batch_input_gallery=[], batch_mask_gallery=[], generated_image=None, mask_image=None, enabled=False, module='None', model='None', weight=1, image=None, resize_mode='Crop and Resize', processor_res=-1, threshold_a=-1, threshold_b=-1, guidance_start=0, guidance_end=1, pixel_perfect=False, control_mode='Balanced'), True, 1.3, 1.2, 0.9, 0.2, True, 512, 3, 3, False, True, 3, 2, 0, 0.35, True, 'bicubic', 'bicubic', True, 0.5, 2, False, False, False, {'ad_model': 'face_yolov8n.pt', 'ad_prompt': '', 'ad_negative_prompt': '', 'ad_confidence': 0.3, 'ad_mask_k_largest': 0, 'ad_mask_min_ratio': 0, 'ad_mask_max_ratio': 1, 'ad_x_offset': 0, 'ad_y_offset': 0, 'ad_dilate_erode': 4, 'ad_mask_merge_invert': 'None', 'ad_mask_blur': 4, 'ad_denoising_strength': 0.4, 'ad_inpaint_only_masked': True, 'ad_inpaint_only_masked_padding': 32, 'ad_use_inpaint_width_height': False, 'ad_inpaint_width': 512, 'ad_inpaint_height': 512, 'ad_use_steps': False, 'ad_steps': 28, 'ad_use_cfg_scale': False, 'ad_cfg_scale': 7, 'ad_use_checkpoint': False, 'ad_checkpoint': 'Use same checkpoint', 'ad_use_vae': False, 'ad_vae': 'Use same VAE', 'ad_use_sampler': False, 'ad_sampler': 'DPM++ 2M Karras', 'ad_use_noise_multiplier': False, 'ad_noise_multiplier': 1, 'ad_use_clip_skip': False, 'ad_clip_skip': 1, 'ad_restore_face': False, 'ad_controlnet_model': 'None', 'ad_controlnet_module': 'None', 'ad_controlnet_weight': 1, 'ad_controlnet_guidance_start': 0, 'ad_controlnet_guidance_end': 1, 'is_api': ()}, {'ad_model': 'None', 'ad_prompt': '', 'ad_negative_prompt': '', 'ad_confidence': 0.3, 'ad_mask_k_largest': 0, 'ad_mask_min_ratio': 0, 'ad_mask_max_ratio': 1, 'ad_x_offset': 0, 'ad_y_offset': 0, 'ad_dilate_erode': 4, 'ad_mask_merge_invert': 'None', 'ad_mask_blur': 4, 'ad_denoising_strength': 0.4, 'ad_inpaint_only_masked': True, 'ad_inpaint_only_masked_padding': 32, 'ad_use_inpaint_width_height': False, 'ad_inpaint_width': 512, 'ad_inpaint_height': 512, 'ad_use_steps': False, 'ad_steps': 28, 'ad_use_cfg_scale': False, 'ad_cfg_scale': 7, 'ad_use_checkpoint': False, 'ad_checkpoint': 'Use same checkpoint', 'ad_use_vae': False, 'ad_vae': 'Use same VAE', 'ad_use_sampler': False, 'ad_sampler': 'DPM++ 2M Karras', 'ad_use_noise_multiplier': False, 'ad_noise_multiplier': 1, 'ad_use_clip_skip': False, 'ad_clip_skip': 1, 'ad_restore_face': False, 'ad_controlnet_model': 'None', 'ad_controlnet_module': 'None', 'ad_controlnet_weight': 1, 'ad_controlnet_guidance_start': 0, 'ad_controlnet_guidance_end': 1, 'is_api': ()}, True, False, 1, False, False, False, 1.1, 1.5, 100, 0.7, False, False, True, False, False, 0, 'Gustavosta/MagicPrompt-Stable-Diffusion', '', False, 0.6, 0.9, 0.25, 1, True, False, None, False, '0', '0', 'inswapper_128.onnx', 'CodeFormer', 1, True, 'None', 1, 1, False, True, 1, 0, 0, False, 0.5, True, False, 'CUDA', False, 0, 'None', '', None, False, False, True, False, 'Matrix', 'Columns', 'Mask', 'Prompt', '1,1', '0.2', False, False, False, 'Attention', [False], '0', '0', '0.4', None, '0', '0', False, False, False, 'positive', 'comma', 0, False, False, 'start', '', 1, '', [], 0, '', [], 0, '', [], True, False, False, False, False, False, False, 0, False, [], 30, '', 4, [], 1, '', '', '', '', 10.0, 30.0, True, 0.0, 'Lanczos', 1, 0, 0, 75, 0.0001, 0.0, False, True, False, False) {}
    Traceback (most recent call last):
      File "D:\Soft\StableDiffusion-webui-forge\modules\call_queue.py", line 57, in f
        res = list(func(*args, **kwargs))
      File "D:\Soft\StableDiffusion-webui-forge\modules\call_queue.py", line 36, in f
        res = func(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\modules\txt2img.py", line 110, in txt2img
        processed = processing.process_images(p)
      File "D:\Soft\StableDiffusion-webui-forge\modules\processing.py", line 749, in process_images
        res = process_images_inner(p)
      File "D:\Soft\StableDiffusion-webui-forge\modules\processing.py", line 920, in process_images_inner
        samples_ddim = p.sample(conditioning=p.c, unconditional_conditioning=p.uc, seeds=p.seeds, subseeds=p.subseeds, subseed_strength=p.subseed_strength, prompts=p.prompts)
      File "D:\Soft\StableDiffusion-webui-forge\modules\processing.py", line 1275, in sample
        samples = self.sampler.sample(self, x, conditioning, unconditional_conditioning, image_conditioning=self.txt2img_image_conditioning(x))
      File "D:\Soft\StableDiffusion-webui-forge\modules\sd_samplers_kdiffusion.py", line 251, in sample
        samples = self.launch_sampling(steps, lambda: self.func(self.model_wrap_cfg, x, extra_args=self.sampler_extra_args, disable=False, callback=self.callback_state, **extra_params_kwargs))
      File "D:\Soft\StableDiffusion-webui-forge\modules\sd_samplers_common.py", line 260, in launch_sampling
        return func()
      File "D:\Soft\StableDiffusion-webui-forge\modules\sd_samplers_kdiffusion.py", line 251, in <lambda>
        samples = self.launch_sampling(steps, lambda: self.func(self.model_wrap_cfg, x, extra_args=self.sampler_extra_args, disable=False, callback=self.callback_state, **extra_params_kwargs))
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
        return func(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\modules\sd_samplers_extra.py", line 71, in restart_sampler
        x = heun_step(x, old_sigma, new_sigma)
      File "D:\Soft\StableDiffusion-webui-forge\modules\sd_samplers_extra.py", line 19, in heun_step
        denoised = model(x, old_sigma * s_in, **extra_args)
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
        return self._call_impl(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
        return forward_call(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\modules\sd_samplers_cfg_denoiser.py", line 182, in forward
        denoised = forge_sampler.forge_sample(self, denoiser_params=denoiser_params,
      File "D:\Soft\StableDiffusion-webui-forge\modules_forge\forge_sampler.py", line 82, in forge_sample
        denoised = sampling_function(model, x, timestep, uncond, cond, cond_scale, model_options, seed)
      File "D:\Soft\StableDiffusion-webui-forge\ldm_patched\modules\samplers.py", line 282, in sampling_function
        cond_pred, uncond_pred = calc_cond_uncond_batch(model, cond, uncond_, x, timestep, model_options)
      File "D:\Soft\StableDiffusion-webui-forge\ldm_patched\modules\samplers.py", line 253, in calc_cond_uncond_batch
        output = model.apply_model(input_x, timestep_, **c).chunk(batch_chunks)
      File "D:\Soft\StableDiffusion-webui-forge\ldm_patched\modules\model_base.py", line 85, in apply_model
        model_output = self.diffusion_model(xc, t, context=context, control=control, transformer_options=transformer_options, **extra_conds).float()
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
        return self._call_impl(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
        return forward_call(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\ldm_patched\ldm\modules\diffusionmodules\openaimodel.py", line 860, in forward
        h = forward_timestep_embed(module, h, emb, context, transformer_options, time_context=time_context, num_video_frames=num_video_frames, image_only_indicator=image_only_indicator)
      File "D:\Soft\StableDiffusion-webui-forge\ldm_patched\ldm\modules\diffusionmodules\openaimodel.py", line 48, in forward_timestep_embed
        x = layer(x, context, transformer_options)
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
        return self._call_impl(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
        return forward_call(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\ldm_patched\ldm\modules\attention.py", line 613, in forward
        x = block(x, context=context[i], transformer_options=transformer_options)
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
        return self._call_impl(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
        return forward_call(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\ldm_patched\ldm\modules\attention.py", line 440, in forward
        return checkpoint(self._forward, (x, context, transformer_options), self.parameters(), self.checkpoint)
      File "D:\Soft\StableDiffusion-webui-forge\ldm_patched\ldm\modules\diffusionmodules\util.py", line 189, in checkpoint
        return func(*inputs)
      File "D:\Soft\StableDiffusion-webui-forge\ldm_patched\ldm\modules\attention.py", line 540, in _forward
        n = self.attn2(n, context=context_attn2, value=value_attn2)
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
        return self._call_impl(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
        return forward_call(*args, **kwargs)
    TypeError: hook_forward.<locals>.forward() got an unexpected keyword argument 'value'
---

Latent mode:

*** Error completing request
*** Arguments: ('task(yf3x12g0q3x8j19)', <gradio.routes.Request object at 0x00000287C7568C70>, '1 BREAK\n2', '', [], 40, 'Restart', 4, 1, 7, 1080, 1920, False, 0.45, 1.5, 'ESRGAN-NMKD-Superscale-4x', 0, 0, 0, 'Use same checkpoint', 'Use same sampler', '', '', [], 0, False, '', 0.8, -1, False, -1, 0, 0, 0, UiControlNetUnit(input_mode=<InputMode.SIMPLE: 'simple'>, use_preview_as_input=False, batch_image_dir='', batch_mask_dir='', batch_input_gallery=[], batch_mask_gallery=[], generated_image=None, mask_image=None, enabled=False, module='None', model='None', weight=1, image=None, resize_mode='Crop and Resize', processor_res=-1, threshold_a=-1, threshold_b=-1, guidance_start=0, guidance_end=1, pixel_perfect=False, control_mode='Balanced'), UiControlNetUnit(input_mode=<InputMode.SIMPLE: 'simple'>, use_preview_as_input=False, batch_image_dir='', batch_mask_dir='', batch_input_gallery=[], batch_mask_gallery=[], generated_image=None, mask_image=None, enabled=False, module='None', model='None', weight=1, image=None, resize_mode='Crop and Resize', processor_res=-1, threshold_a=-1, threshold_b=-1, guidance_start=0, guidance_end=1, pixel_perfect=False, control_mode='Balanced'), UiControlNetUnit(input_mode=<InputMode.SIMPLE: 'simple'>, use_preview_as_input=False, batch_image_dir='', batch_mask_dir='', batch_input_gallery=[], batch_mask_gallery=[], generated_image=None, mask_image=None, enabled=False, module='None', model='None', weight=1, image=None, resize_mode='Crop and Resize', processor_res=-1, threshold_a=-1, threshold_b=-1, guidance_start=0, guidance_end=1, pixel_perfect=False, control_mode='Balanced'), True, 1.3, 1.2, 0.9, 0.2, True, 512, 3, 3, False, True, 3, 2, 0, 0.35, True, 'bicubic', 'bicubic', True, 0.5, 2, False, False, False, {'ad_model': 'face_yolov8n.pt', 'ad_prompt': '', 'ad_negative_prompt': '', 'ad_confidence': 0.3, 'ad_mask_k_largest': 0, 'ad_mask_min_ratio': 0, 'ad_mask_max_ratio': 1, 'ad_x_offset': 0, 'ad_y_offset': 0, 'ad_dilate_erode': 4, 'ad_mask_merge_invert': 'None', 'ad_mask_blur': 4, 'ad_denoising_strength': 0.4, 'ad_inpaint_only_masked': True, 'ad_inpaint_only_masked_padding': 32, 'ad_use_inpaint_width_height': False, 'ad_inpaint_width': 512, 'ad_inpaint_height': 512, 'ad_use_steps': False, 'ad_steps': 28, 'ad_use_cfg_scale': False, 'ad_cfg_scale': 7, 'ad_use_checkpoint': False, 'ad_checkpoint': 'Use same checkpoint', 'ad_use_vae': False, 'ad_vae': 'Use same VAE', 'ad_use_sampler': False, 'ad_sampler': 'DPM++ 2M Karras', 'ad_use_noise_multiplier': False, 'ad_noise_multiplier': 1, 'ad_use_clip_skip': False, 'ad_clip_skip': 1, 'ad_restore_face': False, 'ad_controlnet_model': 'None', 'ad_controlnet_module': 'None', 'ad_controlnet_weight': 1, 'ad_controlnet_guidance_start': 0, 'ad_controlnet_guidance_end': 1, 'is_api': ()}, {'ad_model': 'None', 'ad_prompt': '', 'ad_negative_prompt': '', 'ad_confidence': 0.3, 'ad_mask_k_largest': 0, 'ad_mask_min_ratio': 0, 'ad_mask_max_ratio': 1, 'ad_x_offset': 0, 'ad_y_offset': 0, 'ad_dilate_erode': 4, 'ad_mask_merge_invert': 'None', 'ad_mask_blur': 4, 'ad_denoising_strength': 0.4, 'ad_inpaint_only_masked': True, 'ad_inpaint_only_masked_padding': 32, 'ad_use_inpaint_width_height': False, 'ad_inpaint_width': 512, 'ad_inpaint_height': 512, 'ad_use_steps': False, 'ad_steps': 28, 'ad_use_cfg_scale': False, 'ad_cfg_scale': 7, 'ad_use_checkpoint': False, 'ad_checkpoint': 'Use same checkpoint', 'ad_use_vae': False, 'ad_vae': 'Use same VAE', 'ad_use_sampler': False, 'ad_sampler': 'DPM++ 2M Karras', 'ad_use_noise_multiplier': False, 'ad_noise_multiplier': 1, 'ad_use_clip_skip': False, 'ad_clip_skip': 1, 'ad_restore_face': False, 'ad_controlnet_model': 'None', 'ad_controlnet_module': 'None', 'ad_controlnet_weight': 1, 'ad_controlnet_guidance_start': 0, 'ad_controlnet_guidance_end': 1, 'is_api': ()}, True, False, 1, False, False, False, 1.1, 1.5, 100, 0.7, False, False, True, False, False, 0, 'Gustavosta/MagicPrompt-Stable-Diffusion', '', False, 0.6, 0.9, 0.25, 1, True, False, None, False, '0', '0', 'inswapper_128.onnx', 'CodeFormer', 1, True, 'None', 1, 1, False, True, 1, 0, 0, False, 0.5, True, False, 'CUDA', False, 0, 'None', '', None, False, False, True, False, 'Matrix', 'Columns', 'Mask', 'Prompt', '1,1', '0.2', False, False, False, 'Latent', [False], '0', '0', '0.4', None, '0', '0', False, False, False, 'positive', 'comma', 0, False, False, 'start', '', 1, '', [], 0, '', [], 0, '', [], True, False, False, False, False, False, False, 0, False, [], 30, '', 4, [], 1, '', '', '', '', 10.0, 30.0, True, 0.0, 'Lanczos', 1, 0, 0, 75, 0.0001, 0.0, False, True, False, False) {}
    Traceback (most recent call last):
      File "D:\Soft\StableDiffusion-webui-forge\modules\call_queue.py", line 57, in f
        res = list(func(*args, **kwargs))
      File "D:\Soft\StableDiffusion-webui-forge\modules\call_queue.py", line 36, in f
        res = func(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\modules\txt2img.py", line 110, in txt2img
        processed = processing.process_images(p)
      File "D:\Soft\StableDiffusion-webui-forge\modules\processing.py", line 749, in process_images
        res = process_images_inner(p)
      File "D:\Soft\StableDiffusion-webui-forge\modules\processing.py", line 920, in process_images_inner
        samples_ddim = p.sample(conditioning=p.c, unconditional_conditioning=p.uc, seeds=p.seeds, subseeds=p.subseeds, subseed_strength=p.subseed_strength, prompts=p.prompts)
      File "D:\Soft\StableDiffusion-webui-forge\modules\processing.py", line 1275, in sample
        samples = self.sampler.sample(self, x, conditioning, unconditional_conditioning, image_conditioning=self.txt2img_image_conditioning(x))
      File "D:\Soft\StableDiffusion-webui-forge\modules\sd_samplers_kdiffusion.py", line 251, in sample
        samples = self.launch_sampling(steps, lambda: self.func(self.model_wrap_cfg, x, extra_args=self.sampler_extra_args, disable=False, callback=self.callback_state, **extra_params_kwargs))
      File "D:\Soft\StableDiffusion-webui-forge\modules\sd_samplers_common.py", line 260, in launch_sampling
        return func()
      File "D:\Soft\StableDiffusion-webui-forge\modules\sd_samplers_kdiffusion.py", line 251, in <lambda>
        samples = self.launch_sampling(steps, lambda: self.func(self.model_wrap_cfg, x, extra_args=self.sampler_extra_args, disable=False, callback=self.callback_state, **extra_params_kwargs))
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
        return func(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\modules\sd_samplers_extra.py", line 71, in restart_sampler
        x = heun_step(x, old_sigma, new_sigma)
      File "D:\Soft\StableDiffusion-webui-forge\modules\sd_samplers_extra.py", line 19, in heun_step
        denoised = model(x, old_sigma * s_in, **extra_args)
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
        return self._call_impl(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
        return forward_call(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\modules\sd_samplers_cfg_denoiser.py", line 182, in forward
        denoised = forge_sampler.forge_sample(self, denoiser_params=denoiser_params,
      File "D:\Soft\StableDiffusion-webui-forge\modules_forge\forge_sampler.py", line 82, in forge_sample
        denoised = sampling_function(model, x, timestep, uncond, cond, cond_scale, model_options, seed)
      File "D:\Soft\StableDiffusion-webui-forge\ldm_patched\modules\samplers.py", line 282, in sampling_function
        cond_pred, uncond_pred = calc_cond_uncond_batch(model, cond, uncond_, x, timestep, model_options)
      File "D:\Soft\StableDiffusion-webui-forge\ldm_patched\modules\samplers.py", line 253, in calc_cond_uncond_batch
        output = model.apply_model(input_x, timestep_, **c).chunk(batch_chunks)
      File "D:\Soft\StableDiffusion-webui-forge\ldm_patched\modules\model_base.py", line 85, in apply_model
        model_output = self.diffusion_model(xc, t, context=context, control=control, transformer_options=transformer_options, **extra_conds).float()
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
        return self._call_impl(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
        return forward_call(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\ldm_patched\ldm\modules\diffusionmodules\openaimodel.py", line 847, in forward
        emb = self.time_embed(t_emb)
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
        return self._call_impl(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
        return forward_call(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\container.py", line 215, in forward
        input = module(input)
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
        return self._call_impl(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
        return forward_call(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\ldm_patched\modules\ops.py", line 46, in forward
        return super().forward(*args, **kwargs)
      File "D:\Soft\StableDiffusion-webui-forge\extensions\sd-webui-regional-prompter\scripts\latent.py", line 490, in h_Linear_forward
        return networks.network_forward(self, input, networks.originals.Linear_forward)
    AttributeError: 'LoraPatches' object has no attribute 'Linear_forward'
---
hako-mikan commented 5 months ago

I have addressed the Attention mode. However, it cannot support the Latent mode because Forge does not support the AND syntax that serves as the foundation for Latent mode.

Razunter commented 5 months ago

@hako-mikan Maybe make a feature request to Forge? I can make one, but without technical details it would be pointless.

lllyasviel commented 5 months ago

@hako-mikan

sorry for suddenly showing up here, but someone sent me a twitter PM and linked me to here.

because Forge does not support the AND

note that forge does supports AND

https://github.com/lllyasviel/stable-diffusion-webui-forge/discussions/169#discussioncomment-8426825

Note that the software that does not support AND is comfyui and we are not comfyui.

Please let us know if there is anything missing in Forge's UNet Patcher system

hako-mikan commented 5 months ago

Ah, it seems I was mistaken. Indeed, the AND syntax can be used. What I meant to discuss was the Batch_cond_uncond option used when processing with the AND syntax. Furthermore, there are issues with the LoRA processing. When executing the Regional Prompter's process, the code in Forge makes the steps to achieve the desired outcome by the user through the Regional Prompter very complicated.

The Regional Prompter has two modes. The Attention mode divides the region in the Attention layer and applies separate prompts. This is done within Unet and is achievable as of now. The problem lies in the Latent mode, which processes after exiting Unet. In Latent mode, using the AND syntax, it divides and attaches the cond created from the prompts divided by AND, region by region, after passing through Unet. This operation involves several complex processes.

The reason for doing this is to select whether to apply LoRA to each region for multiple characters. For example, apply LoRA1 when denoising the left side and LoRA2 when denoising the right side. For instance, when inferring with a prompt set of dog AND cat and a negative prompt of worst quality, two cond and one uncond computations are performed. Normally, these calculations are done in batch, so it's not possible to apply different LoRAs. The Web-UI has a batch_cond_uncond option, which allows all calculations to be done separately. This is originally used to reduce VRAM but is being used to apply different LoRAs. That is, calculations are done in the order of cond1, cond2, and uncond. After this processing, the denoising calculation is performed. This is processed by the cfg code in the web-ui.

Additionally, processing with a batch size greater than two is complicated, as it involves shifting the position of the cond to apply the same LoRA to the same region. Furthermore, there are difficulties in applying LoRA. In the current code, LoRA is integrated into the model beforehand. This makes it difficult to choose later whether to apply or not apply LoRA for each. As mentioned earlier, it's necessary to apply different LoRAs for cond1, cond2, and uncond. The Web-UI offers two ways to apply LoRA, similar to diffusers, where you can choose to add LoRA's weight at inference time. If the LoRA's weight is added in this manner, it's possible to choose whether to apply it for each cond calculation. In the current code, it's necessary to reset the lora's weight for each cond switch and apply a different LoRA, which takes a considerable amount of time. image For these reasons, I have decided to forego the latent mode in Forge. Currently, I'm busy with my main job, so I don't have time to thoroughly address these issues. If you wish to maintain compatibility with the Web-UI, I would appreciate it if you could make the following changes:

Implement an option to perform separate calculations for each cond. Here, when the batch size increases, it would be helpful if you could bundle the batch for each cond. That is, if the batch size is three, then batch 1, 2, 3 of cond1 would be included, and three calculations of cond1, cond2, and uncond would be performed.

Change the application method of LoRA to calculate on the fly, similar to diffusers. For this, it would be beneficial if you could set the strength value of LoRA and change all strengths in a single calculation.

this is the code for each lora modules

    def forward(self, x, scale = None):
        return (
            self.org_forward(x)
            + self.lora_up(self.lora_down(x)) * self.multiplier * self.scale
        )

this is the code for LoRAnetwork

    def set_multiplier(self, num):
        for lora in self.unet_loras + self.te_loras:
            lora.multiplier = num

Additionally, it is necessary to make it possible to select whether or not to apply LoRA for each cond calculation in the TextEncoder. Moreover, there are various types of LoRA, and accommodating all of them is very challenging.

Due to the significant changes required, it might be better to focus on other elements at this time. The development of Forge is still in its early stages, and there seem to be many other priorities.

Since I'm getting this translated by ChatGPT, there might be parts where the intent doesn't come across clearly. If you have any questions, please feel free to ask.

lllyasviel commented 5 months ago

thanks! i will take a look soon and try to give more hacks to lora compute

rafstahelin commented 5 months ago

Seems like everyone is moving to forge but Lora features are still severely hampered in the current state. Pity

Manchovies commented 4 months ago

Seems like everyone is moving to forge but Lora features are still severely hampered in the current state. Pity

They'll only be there temporarily. Looks like the goal of Forge is to keep making improvements until they run out of ways to make it better than vanilla Automatic1111 AND all of their optimizations are implemented in vanilla automatic. I'm probably messing that up somewhat, but here's more: https://github.com/lllyasviel/stable-diffusion-webui-forge/discussions/166

AG-w commented 3 months ago

Seems like everyone is moving to forge but Lora features are still severely hampered in the current state. Pity

not really, forge changed too much that not all a1111 extensions works on them so I still use A1111 (forge extensions don't always work on a1111 too, since they use comfyUI model patcher)

If i'm gonna break extension for the sake of performance I'll just use comfyUI instead, maximum speed and maximum customization

Heather95 commented 3 months ago

Seems like everyone is moving to forge but Lora features are still severely hampered in the current state. Pity

This is my current workaround with Forge.

  1. Use this Regional Prompter fork in Attention mode. Do not include LoRA.
  2. Also use ADetailer with the [SEP] token and include each LoRA you need. Sort bounding boxes if necessary.
  3. Generate image. Done.