ashen-sensored / sd_webui_SAG

MIT License
234 stars 29 forks source link

TypeError: xattn_forward_log() got an unexpected keyword argument 'additional_tokens #20

Open AugmentedRealityCat opened 1 year ago

AugmentedRealityCat commented 1 year ago

Anytime I try to use SAG with a SDXL model I get this TypeError: xattn_forward_log() got an unexpected keyword argument 'additional_tokens' error message, and after that I cannot use SDXL models anymore, unless I restart the whole A1111-WebUI engine.


    Traceback (most recent call last):
      File "C:\stable-diffusion-webui\modules\call_queue.py", line 57, in f
        res = list(func(*args, **kwargs))
      File "C:\stable-diffusion-webui\modules\call_queue.py", line 36, in f
        res = func(*args, **kwargs)
      File "C:\stable-diffusion-webui\modules\txt2img.py", line 55, in txt2img
        processed = processing.process_images(p)
      File "C:\stable-diffusion-webui\modules\processing.py", line 732, in process_images
        res = process_images_inner(p)
      File "C:\stable-diffusion-webui\extensions\sd-webui-controlnet\scripts\batch_hijack.py", line 42, in processing_process_images_hijack
        return getattr(processing, '__controlnet_original_process_images_inner')(p, *args, **kwargs)
      File "C:\stable-diffusion-webui\modules\processing.py", line 867, 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 "C:\stable-diffusion-webui\modules\processing.py", line 1140, in sample
        samples = self.sampler.sample(self, x, conditioning, unconditional_conditioning, image_conditioning=self.txt2img_image_conditioning(x))
      File "C:\stable-diffusion-webui\modules\sd_samplers_kdiffusion.py", line 235, 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 "C:\stable-diffusion-webui\modules\sd_samplers_common.py", line 261, in launch_sampling
        return func()
      File "C:\stable-diffusion-webui\modules\sd_samplers_kdiffusion.py", line 235, 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 "C:\stable-diffusion-webui\venvxformers\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
        return func(*args, **kwargs)
      File "C:\stable-diffusion-webui\repositories\k-diffusion\k_diffusion\sampling.py", line 626, in sample_dpmpp_2m_sde
        denoised = model(x, sigmas[i] * s_in, **extra_args)
      File "C:\stable-diffusion-webui\venvxformers\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
        return forward_call(*args, **kwargs)
      File "C:\stable-diffusion-webui\modules\sd_samplers_cfg_denoiser.py", line 169, in forward
        x_out = self.inner_model(x_in, sigma_in, cond=make_condition_dict(cond_in, image_cond_in))
      File "C:\stable-diffusion-webui\venvxformers\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
        return forward_call(*args, **kwargs)
      File "C:\stable-diffusion-webui\repositories\k-diffusion\k_diffusion\external.py", line 112, in forward
        eps = self.get_eps(input * c_in, self.sigma_to_t(sigma), **kwargs)
      File "C:\stable-diffusion-webui\repositories\k-diffusion\k_diffusion\external.py", line 138, in get_eps
        return self.inner_model.apply_model(*args, **kwargs)
      File "C:\stable-diffusion-webui\modules\sd_models_xl.py", line 37, in apply_model
        return self.model(x, t, cond)
      File "C:\stable-diffusion-webui\venvxformers\lib\site-packages\torch\nn\modules\module.py", line 1538, in _call_impl
        result = forward_call(*args, **kwargs)
      File "C:\stable-diffusion-webui\modules\sd_hijack_utils.py", line 17, in <lambda>
        setattr(resolved_obj, func_path[-1], lambda *args, **kwargs: self(*args, **kwargs))
      File "C:\stable-diffusion-webui\modules\sd_hijack_utils.py", line 28, in __call__
        return self.__orig_func(*args, **kwargs)
      File "C:\stable-diffusion-webui\repositories\generative-models\sgm\modules\diffusionmodules\wrappers.py", line 28, in forward
        return self.diffusion_model(
      File "C:\stable-diffusion-webui\venvxformers\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
        return forward_call(*args, **kwargs)
      File "C:\stable-diffusion-webui\repositories\generative-models\sgm\modules\diffusionmodules\openaimodel.py", line 995, in forward
        h = self.middle_block(h, emb, context)
      File "C:\stable-diffusion-webui\venvxformers\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
        return forward_call(*args, **kwargs)
      File "C:\stable-diffusion-webui\repositories\generative-models\sgm\modules\diffusionmodules\openaimodel.py", line 100, in forward
        x = layer(x, context)
      File "C:\stable-diffusion-webui\venvxformers\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
        return forward_call(*args, **kwargs)
      File "C:\stable-diffusion-webui\repositories\generative-models\sgm\modules\attention.py", line 627, in forward
        x = block(x, context=context[i])
      File "C:\stable-diffusion-webui\venvxformers\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
        return forward_call(*args, **kwargs)
      File "C:\stable-diffusion-webui\repositories\generative-models\sgm\modules\attention.py", line 459, in forward
        return checkpoint(
      File "C:\stable-diffusion-webui\repositories\generative-models\sgm\modules\diffusionmodules\util.py", line 165, in checkpoint
        return CheckpointFunction.apply(func, len(inputs), *args)
      File "C:\stable-diffusion-webui\venvxformers\lib\site-packages\torch\autograd\function.py", line 506, in apply
        return super().apply(*args, **kwargs)  # type: ignore[misc]
      File "C:\stable-diffusion-webui\repositories\generative-models\sgm\modules\diffusionmodules\util.py", line 182, in forward
        output_tensors = ctx.run_function(*ctx.input_tensors)
      File "C:\stable-diffusion-webui\repositories\generative-models\sgm\modules\attention.py", line 467, in _forward
        self.attn1(
      File "C:\stable-diffusion-webui\venvxformers\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
        return forward_call(*args, **kwargs)
    TypeError: xattn_forward_log() got an unexpected keyword argument 'additional_tokens'
captainzero93 commented 1 year ago

+1

AG-w commented 1 year ago

I managed to make it run on SDXL but I don't know if it works correctly https://github.com/AG-w/sd_webui_SAG

also it's using very dumb way to check if it's running SDXL, someone can come up a better way to detect it

Ren4issance commented 11 months ago

@AG-w , I'm trying to make your fix work, WebUI says it is installed in the extension tab, but nothing is displayed on the txt2img tab. Even after applying and restarting UI, and my runpod :/

Do you know of a fix ?

ThereforeGames commented 10 months ago

I managed to make it run on SDXL but I don't know if it works correctly https://github.com/AG-w/sd_webui_SAG

Thanks for this! A small issue - there seems to be an indentation error here:

https://github.com/AG-w/sd_webui_SAG/blob/82a73105ca15e4462de945b81fc62996cc6a96be/scripts/SAG.py#L50

solitaryTian commented 10 months ago

Thanks for this! A small issue - there seems to be an indentation error here:

+1. Have you solved it?

ThereforeGames commented 10 months ago

+1. Have you solved it?

Yes, simply remove the extra space at the start of line 50.

AG-w commented 9 months ago

I managed to make it run on SDXL but I don't know if it works correctly https://github.com/AG-w/sd_webui_SAG

Thanks for this! A small issue - there seems to be an indentation error here:

oh thanks, I don't really know how to git I edited script with notepad++ then made change using github's editor

Adahm83 commented 7 months ago

extension does not work in A1111 v. 1.9.0, same error

AG-w commented 7 months ago

extension does not work in A1111 v. 1.9.0, same error

my fork still works on 1.9.x

linklight2 commented 4 months ago

extension does not work in A1111 v. 1.9.0, same error

my fork still works on 1.9.x

It only works if you have not previously used the patch provided in base SAG, deleting the extension won't fix the issue. You have to reinstall Auto1111 with the new SAG fork provided by AG-w to stop getting this error.