Upload app.py
Browse files
app.py
CHANGED
@@ -262,10 +262,11 @@ def stream_chat(input_images: List[Image.Image], caption_type: str, caption_tone
|
|
262 |
generate_ids = text_model.generate(input_ids=input_ids, inputs_embeds=inputs_embeds, attention_mask=attention_mask, do_sample=True,
|
263 |
suppress_tokens=None, max_new_tokens=max_new_tokens, top_p=top_p, temperature=temperature)
|
264 |
|
|
|
265 |
generate_ids = generate_ids[:, input_ids.shape[1]:]
|
266 |
-
|
267 |
for ids in generate_ids:
|
268 |
-
caption = tokenizer.decode(ids[
|
|
|
269 |
caption = caption.replace('<|end_of_text|>', '').replace('<|finetune_right_pad_id|>', '').strip()
|
270 |
all_captions.append(caption)
|
271 |
|
|
|
262 |
generate_ids = text_model.generate(input_ids=input_ids, inputs_embeds=inputs_embeds, attention_mask=attention_mask, do_sample=True,
|
263 |
suppress_tokens=None, max_new_tokens=max_new_tokens, top_p=top_p, temperature=temperature)
|
264 |
|
265 |
+
# Trim off the prompt
|
266 |
generate_ids = generate_ids[:, input_ids.shape[1]:]
|
|
|
267 |
for ids in generate_ids:
|
268 |
+
caption = tokenizer.decode(ids[:] if ids[0] == tokenizer.eos_token_id or ids[0] == tokenizer.convert_tokens_to_ids("<|eot_id|>") else ids,
|
269 |
+
skip_special_tokens=True, clean_up_tokenization_spaces=True)
|
270 |
caption = caption.replace('<|end_of_text|>', '').replace('<|finetune_right_pad_id|>', '').strip()
|
271 |
all_captions.append(caption)
|
272 |
|