Skip to content

Conversation

@patrickvonplaten
Copy link
Contributor

@patrickvonplaten patrickvonplaten commented Nov 9, 2022

This should fix the padding issue remarked in #1165 .

Still need to add tests, but maybe you could already give it a quick review @anton-l @pcuenca @patil-suraj

@HuggingFaceDocBuilder
Copy link

HuggingFaceDocBuilder commented Nov 9, 2022

The documentation is not available anymore as the PR was closed or merged.

untruncated_ids = self.tokenizer(prompt, padding="max_length", return_tensors="np").input_ids

if text_input_ids.shape[-1] > self.tokenizer.model_max_length:
if not np.equal(text_input_ids, untruncated_ids):
Copy link

@averad averad Nov 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Suggested Change:
if not np.equal(text_input_ids.all, untruncated_ids.all):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Thanks - this should be fixed :-)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested changes, verified is it fixed 👍

@averad
Copy link

averad commented Nov 11, 2022

Error:
removed_text is not correctly being outputted via logging

Prompt: cat,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

Output:
The following part of your input was truncated because CLIP can only handle sequences up to 77 tokens: ['']

@patrickvonplaten
Copy link
Contributor Author

Error: removed_text is not correctly being outputted via logging

Prompt: cat,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

Output: The following part of your input was truncated because CLIP can only handle sequences up to 77 tokens: ['']

Thanks should be fixed as well

@patrickvonplaten
Copy link
Contributor Author

Merging as it's blocking on some other PRs

@patrickvonplaten patrickvonplaten merged commit 4c660d1 into main Nov 13, 2022
@patrickvonplaten patrickvonplaten deleted the fix_padding_truncation_sd branch November 13, 2022 19:19
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
* [Stable Diffusion] Fix padding / truncation

* finish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants