Skip to content

Commit

Permalink
Fix bug in stable diffusion when mask_pad_tokens is false (mosaicml#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
coryMosaicML authored and corystephenson-db committed Jun 4, 2024
1 parent b4d7380 commit 8962008
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion diffusion/models/stable_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,10 @@ def _prepare_text_embeddings(self, prompt, tokenized_prompts, tokenized_pad_mask
truncation=True,
return_tensors='pt')
tokenized_prompts = tokenized_out['input_ids']
tokenized_pad_mask = tokenized_out['attention_mask']
if self.mask_pad_tokens:
tokenized_pad_mask = tokenized_out['attention_mask']
else:
tokenized_pad_mask = None
if tokenized_pad_mask is not None:
tokenized_pad_mask = tokenized_pad_mask.to(device)
text_encoder_out = self.text_encoder(tokenized_prompts.to(device), attention_mask=tokenized_pad_mask)
Expand Down

0 comments on commit 8962008

Please sign in to comment.