From 65c162a5b3f41bc493e24e57329ac52257e2a795 Mon Sep 17 00:00:00 2001 From: maksymbekuzarovSC <143528551+maksymbekuzarovSC@users.noreply.github.com> Date: Tue, 19 Sep 2023 10:34:49 +0100 Subject: [PATCH] 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 --- examples/community/pipeline_prompt2prompt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/community/pipeline_prompt2prompt.py b/examples/community/pipeline_prompt2prompt.py index d190d2602d..83e7c7d77c 100644 --- a/examples/community/pipeline_prompt2prompt.py +++ b/examples/community/pipeline_prompt2prompt.py @@ -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: