"git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "bf1fe3282419d7e381f12b570f883b2c20c47fd2"
Unverified Commit 2922e394 authored by Younes Belkada's avatar Younes Belkada Committed by GitHub
Browse files

[`Pix2Struct`] Add conditional generation on docstring example (#23399)

add conditional generation on docstring
parent 52d516c3
...@@ -1687,6 +1687,15 @@ class Pix2StructForConditionalGeneration(Pix2StructPreTrainedModel): ...@@ -1687,6 +1687,15 @@ class Pix2StructForConditionalGeneration(Pix2StructPreTrainedModel):
>>> generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0] >>> generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
>>> print(generated_text) >>> print(generated_text)
A stop sign is on a street corner. A stop sign is on a street corner.
>>> # conditional generation
>>> text = "A picture of"
>>> inputs = processor(text=text, images=image, return_tensors="pt", add_special_tokens=False)
>>> generated_ids = model.generate(**inputs, max_new_tokens=50)
>>> generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
>>> print(generated_text)
A picture of a stop sign with a red stop sign on it.
``` ```
Training: Training:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment