Closed Panchovix closed 3 months ago
Is it specifically the dev_upstream
branch?
Yes, should be only on dev_upstream branch, since on ldm_patched.modules.ops, conv2D implementation is like on comfy upstream, which differs vs OG forge/main branch.
I added some new parameters into the VAE clone, else it would fail about missing some parameters (which ldm_patched.modules.sd added with updates)
I updated conv2d a little again to comfy upstream, error persists but at least now is just 8 channels instead of 12
Traceback (most recent call last):
File "G:\Stable difussion\stable-diffusion-webui-reForge\modules_forge\main_thread.py", line 37, in loop
task.work()
File "G:\Stable difussion\stable-diffusion-webui-reForge\modules_forge\main_thread.py", line 26, in work
self.result = self.func(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui-reForge\modules\txt2img.py", line 110, in txt2img_function
processed = processing.process_images(p)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui-reForge\modules\processing.py", line 820, in process_images
res = process_images_inner(p)
^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui-reForge\modules\processing.py", line 969, 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 "G:\Stable difussion\stable-diffusion-webui-reForge\modules\processing.py", line 1340, in sample
samples = self.sampler.sample(self, x, conditioning, unconditional_conditioning, image_conditioning=self.txt2img_image_conditioning(x))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui-reForge\modules\sd_samplers_kdiffusion.py", line 261, 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 "G:\Stable difussion\stable-diffusion-webui-reForge\modules\sd_samplers_common.py", line 274, in launch_sampling
return func()
^^^^^^
File "G:\Stable difussion\stable-diffusion-webui-reForge\modules\sd_samplers_kdiffusion.py", line 261, 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 "G:\Stable difussion\stable-diffusion-webui\venv\Lib\site-packages\torch\utils\_contextlib.py", line 116, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui-reForge\repositories\k-diffusion\k_diffusion\sampling.py", line 594, in sample_dpmpp_2m
denoised = model(x, sigmas[i] * s_in, **extra_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui\venv\Lib\site-packages\torch\nn\modules\module.py", line 1716, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui\venv\Lib\site-packages\torch\nn\modules\module.py", line 1727, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui-reForge\modules\sd_samplers_cfg_denoiser.py", line 797, in forward
denoised = sampling_function(model, x, sigma, uncond_patched, cond_patched, cond_scale, model_options, seed)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui-reForge\ldm_patched\modules\samplers.py", line 280, in sampling_function
cond_pred, uncond_pred = calc_cond_uncond_batch(model, cond, uncond_, x, timestep, model_options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui-reForge\ldm_patched\modules\samplers.py", line 259, in calc_cond_uncond_batch
return tuple(calc_cond_batch(model, [cond, uncond], x_in, timestep, model_options))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui-reForge\ldm_patched\modules\samplers.py", line 232, in calc_cond_batch
output = model_options['model_function_wrapper'](model.apply_model, {"input": input_x, "timestep": timestep_, "c": c, "cond_or_uncond": cond_or_uncond}).chunk(batch_chunks)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui-reForge\extensions\sd-forge-ic-light\libiclight\ic_light_nodes.py", line 61, in wrapper_func
return existing_wrapper(unet_apply, params=apply_c_concat(params))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui-reForge\extensions\sd-forge-ic-light\libiclight\ic_light_nodes.py", line 53, in unet_dummy_apply
return unet_apply(x=params["input"], t=params["timestep"], **params["c"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui-reForge\ldm_patched\modules\model_base.py", line 118, in apply_model
model_output = self.diffusion_model(xc, t, context=context, control=control, transformer_options=transformer_options, **extra_conds).float()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui\venv\Lib\site-packages\torch\nn\modules\module.py", line 1716, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui\venv\Lib\site-packages\torch\nn\modules\module.py", line 1727, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui-reForge\ldm_patched\ldm\modules\diffusionmodules\openaimodel.py", line 861, 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 "G:\Stable difussion\stable-diffusion-webui-reForge\ldm_patched\ldm\modules\diffusionmodules\openaimodel.py", line 57, in forward_timestep_embed
x = layer(x)
^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui\venv\Lib\site-packages\torch\nn\modules\module.py", line 1716, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui\venv\Lib\site-packages\torch\nn\modules\module.py", line 1727, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui-reForge\ldm_patched\modules\ops.py", line 145, in forward
return super().forward(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui\venv\Lib\site-packages\torch\nn\modules\conv.py", line 549, in forward
return self._conv_forward(input, self.weight, self.bias)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Stable difussion\stable-diffusion-webui\venv\Lib\site-packages\torch\nn\modules\conv.py", line 544, in _conv_forward
return F.conv2d(
^^^^^^^^^
RuntimeError: Given groups=1, weight of size [320, 4, 3, 3], expected input[2, 8, 136, 112] to have 4 channels, but got 8 channels instead
what are those channels and weights actually, ic light tries to encode/decode the image somehow, I'm not familiar.
I went ahead to check huchenlei's implementation for ComfyUI, and saw that people also have the same issues over there.
But apparently, according to this comment, installing LayerDiffuse fixes the issue.
So, I ported the patching from that Extension over here as well. And now, it seems to work properly without any errors.
Though, feels like the effect is somehow stronger...?
WARNING:root:WARNING SHAPE MISMATCH diffusion_model.input_blocks.0.0.weight WEIGHT NOT MERGED torch.Size([320, 8, 3, 3]) != torch.Size([320, 4, 3, 3])
Moving model(s) has taken 0.62 seconds
0%| | 0/8 [00:00<?, ?it/s]
Traceback (most recent call last):
File "S:\reForge\modules_forge\main_thread.py", line 37, in loop
task.work()
File "S:\reForge\modules_forge\main_thread.py", line 26, in work
self.result = self.func(*self.args, self.kwargs)
File "S:\reForge\modules\img2img.py", line 235, in img2img_function
processed = process_images(p)
File "S:\reForge\modules\processing.py", line 856, in process_images
res = process_images_inner(p)
File "S:\reForge\modules\processing.py", line 1007, 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 "S:\reForge\modules\processing.py", line 1828, in sample
samples = self.sampler.sample_img2img(self, self.init_latent, x, conditioning, unconditional_conditioning, image_conditioning=self.image_conditioning)
File "S:\reForge\modules\sd_samplers_kdiffusion.py", line 207, in sample_img2img
samples = self.launch_sampling(t_enc + 1, lambda: self.func(self.model_wrap_cfg, xi, extra_args=self.sampler_extra_args, disable=False, callback=self.callback_state, extra_params_kwargs))
File "S:\reForge\modules\sd_samplers_common.py", line 274, in launch_sampling
return func()
File "S:\reForge\modules\sd_samplers_kdiffusion.py", line 207, in
[[ 0, 0, 0, 255], [ 0, 0, 0, 255], [ 0, 0, 0, 255], ..., [254, 254, 254, 255], [254, 254, 254, 255], *** [255, 255, 255, 255]],
[[ 0, 0, 0, 255], [ 0, 0, 0, 255], [ 0, 0, 0, 255], ..., [254, 254, 254, 255], [254, 254, 254, 255], *** [255, 255, 255, 255]],
*** ...,
[[ 0, 0, 0, 255], [ 0, 0, 0, 255], [ 0, 0, 0, 255], ..., [254, 254, 254, 255], [254, 254, 254, 255], *** [255, 255, 255, 255]],
[[ 0, 0, 0, 255], [ 0, 0, 0, 255], [ 0, 0, 0, 255], ..., [254, 254, 254, 255], [254, 254, 254, 255], *** [255, 255, 255, 255]],
[[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
...,
[254, 254, 254, 255],
[254, 254, 254, 255],
* [255, 255, 255, 255]]], dtype=uint8), None, True, 'u2net_human_seg', 225, 16, 16, False, False, 3, False, 0, ControlNetUnit(input_mode=<InputMode.SIMPLE: 'simple'>, use_preview_as_input=False, batch_image_dir='', batch_mask_dir='', batch_input_gallery=[], batch_mask_gallery=[], multi_inputs_gallery=[], generated_image=None, mask_image=None, hr_option=<HiResFixOption.BOTH: 'Both'>, enabled=False, module='None', model='None', weight=1, image=None, resize_mode=<ResizeMode.INNER_FIT: 'Crop and Resize'>, processor_res=-1, threshold_a=-1, threshold_b=-1, guidance_start=0, guidance_end=1, pixel_perfect=False, control_mode=<ControlMode.BALANCED: 'Balanced'>, advanced_weighting=None, save_detected_map=True), ControlNetUnit(input_mode=<InputMode.SIMPLE: 'simple'>, use_preview_as_input=False, batch_image_dir='', batch_mask_dir='', batch_input_gallery=[], batch_mask_gallery=[], multi_inputs_gallery=[], generated_image=None, mask_image=None, hr_option=<HiResFixOption.BOTH: 'Both'>, enabled=False, module='None', model='None', weight=1, image=None, resize_mode=<ResizeMode.INNER_FIT: 'Crop and Resize'>, processor_res=-1, threshold_a=-1, threshold_b=-1, guidance_start=0, guidance_end=1, pixel_perfect=False, control_mode=<ControlMode.BALANCED: 'Balanced'>, advanced_weighting=None, save_detected_map=True), ControlNetUnit(input_mode=<InputMode.SIMPLE: 'simple'>, use_preview_as_input=False, batch_image_dir='', batch_mask_dir='', batch_input_gallery=[], batch_mask_gallery=[], multi_inputs_gallery=[], generated_image=None, mask_image=None, hr_option=<HiResFixOption.BOTH: 'Both'>, enabled=False, module='None', model='None', weight=1, image=None, resize_mode=<ResizeMode.INNER_FIT: 'Crop and Resize'>, processor_res=-1, threshold_a=-1, threshold_b=-1, guidance_start=0, guidance_end=1, pixel_perfect=False, control_mode=<ControlMode.BALANCED: 'Balanced'>, advanced_weighting=None, save_detected_map=True), False, 7, 1, 'Constant', 0, 'Constant', 0, 1, 'enable', 'MEAN', 'AD', 1, False, 1.01, 1.02, 0.99, 0.95, False, 0.5, 2, False, 256, 2, 0, False, False, 3, 2, 0, 0.35, True, 'bicubic', 'bicubic', False, 0, 'anisotropic', 0, 'reinhard', 100, 0, 'subtract', 0, 0, 'gaussian', 'add', 0, 100, 127, 0, 'hard_clamp', 5, 0, 'None', 'None', False, 'MultiDiffusion', 768, 768, 64, 4, False, False, False, ' Recommended settings: Sampling Steps: 80-100, Sampler: Euler a, Denoising strength: 0.8 Will upscale the image by the selected scale factor; use width and height sliders to set tile size Will upscale the image depending on the selected target size typeCFG Scale
should be 2 or lower.', True, True, '', '', True, 50, True, 1, 0, False, 4, 0.5, 'Linear', 'None', '
Many thanks for the update, working fine on my end!
Hi there, thanks for your all hard work!
I did fork and do updates up to A1111/Comfy upstream here https://github.com/Panchovix/stable-diffusion-webui-reForge/tree/dev_upstream
Since I changed the code to upstream comfy for ldm_patched\ldm\modules\diffusionmodules\openaimodel.py and conv2d on ldm_patched/modules/ops.py, now there is some issues.
Error is
For VAE it does get it from def clone(self) on https://github.com/Panchovix/stable-diffusion-webui-reForge/blob/99cb084fbdac6e0084052b82bbe31140867b9213/ldm_patched/modules/sd.py#L293