pamparamm / sd-perturbed-attention

Perturbed-Attention Guidance and Smoothed Energy Guidance for ComfyUI and SD Forge
MIT License
219 stars 14 forks source link

enabling adaptive scale on latest version of forge gives error #26

Closed Hugs288 closed 2 weeks ago

Hugs288 commented 1 month ago

AttributeError: 'KModel' object has no attribute 'model_sampling'

Hugs288 commented 1 month ago

here is the full error: Traceback (most recent call last): File "J:\aistuff\stable-diffusion-webui-forge\modules_forge\main_thread.py", line 30, in work self.result = self.func(*self.args, self.kwargs) File "J:\aistuff\stable-diffusion-webui-forge\modules\txt2img.py", line 125, in txt2img_function processed = processing.process_images(p) File "J:\aistuff\stable-diffusion-webui-forge\modules\processing.py", line 840, in process_images res = process_images_inner(p) File "J:\aistuff\stable-diffusion-webui-forge\modules\processing.py", line 986, 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 "J:\aistuff\stable-diffusion-webui-forge\modules\processing.py", line 1381, in sample samples = self.sampler.sample(self, x, conditioning, unconditional_conditioning, image_conditioning=self.txt2img_image_conditioning(x)) File "J:\aistuff\stable-diffusion-webui-forge\modules\sd_samplers_kdiffusion.py", line 238, 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 "J:\aistuff\stable-diffusion-webui-forge\modules\sd_samplers_common.py", line 272, in launch_sampling return func() File "J:\aistuff\stable-diffusion-webui-forge\modules\sd_samplers_kdiffusion.py", line 238, in 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 "J:\aistuff\stable-diffusion-webui-forge\venv\lib\site-packages\torch\utils_contextlib.py", line 116, in decorate_context return func(*args, *kwargs) File "J:\aistuff\stable-diffusion-webui-forge\k_diffusion\sampling.py", line 146, in sample_euler_ancestral denoised = model(x, sigmas[i] s_in, extra_args) File "J:\aistuff\stable-diffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1553, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "J:\aistuff\stable-diffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1562, in _call_impl return forward_call(args, **kwargs) File "J:\aistuff\stable-diffusion-webui-forge\modules\sd_samplers_cfg_denoiser.py", line 199, in forward denoised, cond_pred, uncond_pred = sampling_function(self, denoiser_params=denoiser_params, cond_scale=cond_scale, cond_composition=cond_composition) File "J:\aistuff\stable-diffusion-webui-forge\backend\sampling\sampling_function.py", line 362, in sampling_function denoised, cond_pred, uncond_pred = sampling_function_inner(model, x, timestep, uncond, cond, cond_scale, model_options, seed, return_full=True) File "J:\aistuff\stable-diffusion-webui-forge\backend\sampling\sampling_function.py", line 317, in sampling_function_inner cfg_result = fn(args) File "J:\aistuff\stable-diffusion-webui-forge\extensions\sd-perturbed-attention\pag_nodes.py", line 104, in post_cfg_function t = model.model_sampling.timestep(sigma)[0].item() File "J:\aistuff\stable-diffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\module.py", line 1729, in getattr raise AttributeError(f"'{type(self).name}' object has no attribute '{name}'") AttributeError: 'KModel' object has no attribute 'model_sampling' 'KModel' object has no attribute 'model_sampling'

waomodder commented 1 month ago

@pamparamm I got the same error. When I set the ‘Adaptive Scale’ to 0.1 or higher, I got the following error.

AttributeError: 'KModel' object has no attribute 'model_sampling' 'KModel' object has no attribute 'model_sampling'

pamparamm commented 1 month ago

Thanks for the report! I'll look into that problem

kyleengan commented 2 weeks ago

Opened a pull request with an attempted fix at this. :)

pamparamm commented 2 weeks ago

Should be fixed now - thanks to @kyleengan, good job!

waomodder commented 2 weeks ago

Thank you so much for fixing it! It was very difficult to produce a high quality picture without this extension! image image image