Commit 7ffdcb7
committed
Fix TypeError in LongCatImageEditPipeline truncation warning
`_encode_prompt` in `LongCatImageEditPipeline` calls `len()` twice on
`all_tokens` when logging the truncation warning:
f" {self.tokenizer_max_length} input token nums : {len(len(all_tokens))}"
`len(all_tokens)` already returns an `int`, so the outer `len()` raises
`TypeError: object of type 'int' has no len()`. The failure triggers
exactly in the only branch this warning exists for (prompts longer
than `tokenizer_max_length`, default 512), turning the intended
informational warning into a hard crash.
The sibling `LongCatImagePipeline._encode_prompt` has the correct
`{len(all_tokens)}` at line 291, so this is a typo local to the edit
pipeline. Minimal fix: drop the extra `len()` call.
Reproduces with any prompt whose tokenization exceeds 512 tokens:
pipe = LongCatImageEditPipeline.from_pretrained(...)
pipe(prompt="a very long prompt ..." * 200, image=...)
# TypeError: object of type 'int' has no len()1 parent c8c8401 commit 7ffdcb7
1 file changed
Lines changed: 1 addition & 1 deletion
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
287 | | - | |
| 287 | + | |
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
| |||
0 commit comments