Skip to content

Commit 8962008

Browse files
coryMosaicMLcorystephenson-db
authored andcommitted
Fix bug in stable diffusion when mask_pad_tokens is false (mosaicml#147)
1 parent b4d7380 commit 8962008

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

diffusion/models/stable_diffusion.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,10 @@ def _prepare_text_embeddings(self, prompt, tokenized_prompts, tokenized_pad_mask
484484
truncation=True,
485485
return_tensors='pt')
486486
tokenized_prompts = tokenized_out['input_ids']
487-
tokenized_pad_mask = tokenized_out['attention_mask']
487+
if self.mask_pad_tokens:
488+
tokenized_pad_mask = tokenized_out['attention_mask']
489+
else:
490+
tokenized_pad_mask = None
488491
if tokenized_pad_mask is not None:
489492
tokenized_pad_mask = tokenized_pad_mask.to(device)
490493
text_encoder_out = self.text_encoder(tokenized_prompts.to(device), attention_mask=tokenized_pad_mask)

0 commit comments

Comments
 (0)