kohya-ss / sd-scripts

Apache License 2.0
5.13k stars 855 forks source link

Attention Couple + Reginal LoRA running error in gen_imgs_diffusers.py #587

Open jiangds2018 opened 1 year ago

jiangds2018 commented 1 year ago

this is my scripts: CUDA_VISIBLE_DEVICES=3 python gen_img.py --ckpt /models/dreamshaper \ --outdir /images_outputs/latentcouple \ --mask_path /tools/region_mask.jpg \ --network_module networks.lora networks.lora \ --network_weights /models/lora/ganyu2ep10_0.85dim32.safetensors /models/lora/huTaoGenshinImpact_v12.safetensors \ --network_mul 0.8 0.8 \ --textual_inversion_embeddings /embeddings/embeddings/BadDream.pt /embeddings/embeddings/FastNegativeV2.pt \ --W=512 \ --H=512 \ --fp16 \ --scale=7.5 \ --vae /models/vae/vae-ft-mse-840000-ema-pruned.safetensors \ --sampler=euler_a \ --steps=20 \ --seed=1337 \ --batch_size=1 \ --diffusers_xformers \ --images_per_prompt=4 \ --clip_skip=2 \ --prompt "shs 2girls, looking at viewer, smile AND bsb 2girls, looking back AND 2girls --n bad quality, worst quality"

The error report is as follows:

/networks/lora.py:234 in forward │ │ │ │ 231 │ │ │ │ 232 │ │ # import pdb;pdb.set_trace() │ │ 233 │ │ if self.regional: │ │ ❱ 234 │ │ │ return self.regional_forward(x) │ │ 235 │ │ else: │ │ 236 │ │ │ return self.sub_prompt_forward(x) │ │ 237 │ │ │ │ /networks/lora.py:255 in regional_forward │ │ │ │ 252 │ │ │ 253 │ def regional_forward(self, x): │ │ 254 │ │ if "attn2_to_out" in self.lora_name: │ │ ❱ 255 │ │ │ return self.to_out_forward(x) │ │ 256 │ │ │ │ 257 │ │ if self.network.mask_dic is None: # sub_prompt_index >= 3 │ │ 258 │ │ │ return self.default_forward(x) │ │ │ │ /networks/lora.py:357 in to_out_forward │ │ │ │ 354 │ │ # if masks[i] is None: │ │ 355 │ │ # masks[i] = torch.zeros_like(masks[-1]) │ │ 356 │ │ │ │ ❱ 357 │ │ mask = torch.cat(masks) │ │ 358 │ │ mask_sum = torch.sum(mask, dim=0) + 1e-4 │ │ 359 │ │ for i in range(self.network.batch_size): │ │ 360 │ │ │ # 1枚の画像ごとに処理する

TypeError: expected Tensor as element 2 in argument 0, but got NoneType

I don't know if there is something wrong with my script settings or something else, but at least for now I can't solve it

kohya-ss commented 1 year ago

Unfortunately regional LoRA doesn't work with xformers of Diffusers. Please use --xformers option instead of --diffusers_xformers.

ifenghao commented 1 year ago

same problem, it comes up because of the B channel is default None, just fill in an all-zeros tensor to solve

kohya-ss commented 1 year ago

I think this is solved in sdxl branch. sdxl branch will be merged in main sooner.