1
0
mirror of https://github.com/huggingface/diffusers.git synced 2026-01-27 17:22:53 +03:00

Fixed get_word_inds mistake/typo in P2P community pipeline (breaking code examples) (#5089)

Fixed `get_word_inds` mistake/typo in P2P community pipeline

The function `get_word_inds` was taking a string of text and either a word (str) or a word index (int) and returned the indices of token(s) the word would be encoded to.

However, there was a typo, in which in the second `if` branch the word was checked to be a `str` **again**, not `int`, which resulted in an [example code from the docs](https://github.com/huggingface/diffusers/tree/main/examples/community#prompt2prompt-pipeline) to result in an error
This commit is contained in:
maksymbekuzarovSC
2023-09-19 10:34:49 +01:00
committed by GitHub
parent 04d696d650
commit 65c162a5b3

View File

@@ -681,7 +681,7 @@ def get_word_inds(text: str, word_place: int, tokenizer):
split_text = text.split(" ")
if isinstance(word_place, str):
word_place = [i for i, word in enumerate(split_text) if word_place == word]
elif isinstance(word_place, str):
elif isinstance(word_place, int):
word_place = [word_place]
out = []
if len(word_place) > 0: