kohya-ss / kohya-ss/sd-scripts
Attention Couple + Reginal LoRA running error in gen_imgs_diffusers.py
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.2k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
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
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the reported command from gen_img.py and trace the regional LoRA path in networks/lora.py, especially regional_forward and to_out_forward. Inspect why masks contains a None value before torch.cat; done means the command runs without this TypeError and produces the requested images.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100