import{S as Zi,i as el,s as tl,e as s,k as c,w as v,t as r,M as ol,c as a,d as o,m as p,a as n,x as b,h as i,b as l,N as sl,G as e,g as m,y as w,q as D,o as k,B as x,v as al,L as Ki}from"../../chunks/vendor-hf-doc-builder.js";import{T as Tr}from"../../chunks/Tip-hf-doc-builder.js";import{D as N}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Lo}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as ne}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Qi}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function nl(L){let h,$,f,g,y;return g=new Lo({props:{code:`from transformers import DonutSwinConfig, DonutSwinModel

# Initializing a Donut naver-clova-ix/donut-base style configuration
configuration = DonutSwinConfig()

# Randomly initializing a model from the naver-clova-ix/donut-base style configuration
model = DonutSwinModel(configuration)

# Accessing the model configuration
configuration = model.config`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DonutSwinConfig, DonutSwinModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Donut naver-clova-ix/donut-base style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = DonutSwinConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Randomly initializing a model from the naver-clova-ix/donut-base style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = DonutSwinModel(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`}}),{c(){h=s("p"),$=r("Example:"),f=c(),v(g.$$.fragment)},l(u){h=a(u,"P",{});var _=n(h);$=i(_,"Example:"),_.forEach(o),f=p(u),b(g.$$.fragment,u)},m(u,_){m(u,h,_),e(h,$),m(u,f,_),w(g,u,_),y=!0},p:Ki,i(u){y||(D(g.$$.fragment,u),y=!0)},o(u){k(g.$$.fragment,u),y=!1},d(u){u&&o(h),u&&o(f),x(g,u)}}}function rl(L){let h,$,f,g,y,u,_,E;return{c(){h=s("p"),$=r(`This class method is simply calling the feature extractor
`),f=s("a"),g=r("from_pretrained()"),y=r(` and the tokenizer
`),u=s("code"),_=r("~tokenization_utils_base.PreTrainedTokenizer.from_pretrained"),E=r(` methods. Please refer to the docstrings of the
methods above for more information.`),this.h()},l(I){h=a(I,"P",{});var j=n(h);$=i(j,`This class method is simply calling the feature extractor
`),f=a(j,"A",{href:!0});var C=n(f);g=i(C,"from_pretrained()"),C.forEach(o),y=i(j,` and the tokenizer
`),u=a(j,"CODE",{});var A=n(u);_=i(A,"~tokenization_utils_base.PreTrainedTokenizer.from_pretrained"),A.forEach(o),E=i(j,` methods. Please refer to the docstrings of the
methods above for more information.`),j.forEach(o),this.h()},h(){l(f,"href","/docs/transformers/v4.25.1/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin.from_pretrained")},m(I,j){m(I,h,j),e(h,$),e(h,f),e(f,g),e(h,y),e(h,u),e(u,_),e(h,E)},d(I){I&&o(h)}}}function il(L){let h,$,f,g,y,u,_,E;return{c(){h=s("p"),$=r("This class method is simply calling "),f=s("a"),g=r("save_pretrained()"),y=r(` and
`),u=s("a"),_=r("save_pretrained()"),E=r(`. Please refer to the docstrings of the
methods above for more information.`),this.h()},l(I){h=a(I,"P",{});var j=n(h);$=i(j,"This class method is simply calling "),f=a(j,"A",{href:!0});var C=n(f);g=i(C,"save_pretrained()"),C.forEach(o),y=i(j,` and
`),u=a(j,"A",{href:!0});var A=n(u);_=i(A,"save_pretrained()"),A.forEach(o),E=i(j,`. Please refer to the docstrings of the
methods above for more information.`),j.forEach(o),this.h()},h(){l(f,"href","/docs/transformers/v4.25.1/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin.save_pretrained"),l(u,"href","/docs/transformers/v4.25.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.save_pretrained")},m(I,j){m(I,h,j),e(h,$),e(h,f),e(f,g),e(h,y),e(h,u),e(u,_),e(h,E)},d(I){I&&o(h)}}}function ll(L){let h,$,f,g,y;return{c(){h=s("p"),$=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=s("code"),g=r("Module"),y=r(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(u){h=a(u,"P",{});var _=n(h);$=i(_,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a(_,"CODE",{});var E=n(f);g=i(E,"Module"),E.forEach(o),y=i(_,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),_.forEach(o)},m(u,_){m(u,h,_),e(h,$),e(h,f),e(f,g),e(h,y)},d(u){u&&o(h)}}}function dl(L){let h,$,f,g,y;return g=new Lo({props:{code:`from transformers import AutoFeatureExtractor, DonutSwinModel
import torch
from datasets import load_dataset

dataset = load_dataset("huggingface/cats-image")
image = dataset["test"]["image"][0]

feature_extractor = AutoFeatureExtractor.from_pretrained("https://huggingface.co/naver-clova-ix/donut-base")
model = DonutSwinModel.from_pretrained("https://huggingface.co/naver-clova-ix/donut-base")

inputs = feature_extractor(image, return_tensors="pt")

with torch.no_grad():
    outputs = model(**inputs)

last_hidden_states = outputs.last_hidden_state
list(last_hidden_states.shape)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoFeatureExtractor, DonutSwinModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;huggingface/cats-image&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = dataset[<span class="hljs-string">&quot;test&quot;</span>][<span class="hljs-string">&quot;image&quot;</span>][<span class="hljs-number">0</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>feature_extractor = AutoFeatureExtractor.from_pretrained(<span class="hljs-string">&quot;https://huggingface.co/naver-clova-ix/donut-base&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = DonutSwinModel.from_pretrained(<span class="hljs-string">&quot;https://huggingface.co/naver-clova-ix/donut-base&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = feature_extractor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(last_hidden_states.shape)
[<span class="hljs-number">1</span>, <span class="hljs-number">49</span>, <span class="hljs-number">768</span>]`}}),{c(){h=s("p"),$=r("Example:"),f=c(),v(g.$$.fragment)},l(u){h=a(u,"P",{});var _=n(h);$=i(_,"Example:"),_.forEach(o),f=p(u),b(g.$$.fragment,u)},m(u,_){m(u,h,_),e(h,$),m(u,f,_),w(g,u,_),y=!0},p:Ki,i(u){y||(D(g.$$.fragment,u),y=!0)},o(u){k(g.$$.fragment,u),y=!1},d(u){u&&o(h),u&&o(f),x(g,u)}}}function cl(L){let h,$,f,g,y,u,_,E,I,j,C,A,Qt,Se,Fs,Kt,Os,Fo,re,Vs,Ie,Us,Ws,Oo,bt,Hs,Vo,wt,Zt,Xs,Uo,ie,zr,Wo,le,Bs,Dt,Gs,Js,Ho,H,Ys,Ce,Qs,Ks,Ae,Zs,ea,Xo,kt,ta,Bo,de,Me,oa,Re,sa,aa,na,Ne,ra,xt,ia,la,Go,J,ce,eo,Le,da,to,ca,Jo,X,pa,oo,ma,ua,yt,ha,fa,Yo,z,ga,$t,_a,va,so,ba,wa,ao,Da,ka,jt,xa,ya,Tt,$a,ja,no,Ta,za,ro,Ea,Pa,Qo,zt,io,qa,Ko,Fe,Zo,Et,lo,Sa,es,Oe,ts,Pt,co,Ia,os,Ve,ss,pe,Ca,Ue,Aa,Ma,as,Y,me,po,We,Ra,mo,Na,ns,ue,La,He,Fa,Oa,rs,Q,he,uo,Xe,Va,ho,Ua,is,M,Be,Wa,K,Ha,qt,Xa,Ba,Ge,Ga,Ja,Ya,Z,Qa,St,Ka,Za,It,en,tn,on,fe,ls,ee,ge,fo,Je,sn,go,an,ds,O,Ye,nn,_o,rn,ln,_e,Qe,dn,vo,cn,cs,te,ve,bo,Ke,pn,wo,mn,ps,V,Ze,un,Do,hn,fn,be,et,gn,ko,_n,ms,oe,we,xo,tt,vn,yo,bn,us,T,ot,wn,$o,Dn,kn,P,Ct,xn,yn,At,$n,jn,jo,Tn,zn,To,En,Pn,st,zo,qn,Sn,In,Mt,Cn,An,Mn,De,at,Rn,U,Nn,Eo,Ln,Fn,Po,On,Vn,qo,Un,Wn,Hn,B,nt,Xn,So,Bn,Gn,ke,Jn,G,rt,Yn,it,Qn,Rt,Kn,Zn,er,xe,tr,ye,lt,or,dt,sr,Nt,ar,nr,rr,$e,ct,ir,pt,lr,Lt,dr,cr,hs,se,je,Io,mt,pr,Co,mr,fs,W,ut,ur,ht,hr,ft,fr,gr,_r,F,gt,vr,ae,br,Ft,wr,Dr,Ao,kr,xr,yr,Te,$r,ze,gs;return u=new ne({}),Se=new ne({}),Le=new ne({}),Fe=new Lo({props:{code:`import re

from transformers import DonutProcessor, VisionEncoderDecoderModel
from datasets import load_dataset
import torch

processor = DonutProcessor.from_pretrained("naver-clova-ix/donut-base-finetuned-rvlcdip")
model = VisionEncoderDecoderModel.from_pretrained("naver-clova-ix/donut-base-finetuned-rvlcdip")

device = "cuda" if torch.cuda.is_available() else "cpu"
model.to(device)
# load document image
dataset = load_dataset("hf-internal-testing/example-documents", split="test")
image = dataset[1]["image"]

# prepare decoder inputs
task_prompt = "<s_rvlcdip>"
decoder_input_ids = processor.tokenizer(task_prompt, add_special_tokens=False, return_tensors="pt").input_ids

pixel_values = processor(image, return_tensors="pt").pixel_values

outputs = model.generate(
    pixel_values.to(device),
    decoder_input_ids=decoder_input_ids.to(device),
    max_length=model.decoder.config.max_position_embeddings,
    early_stopping=True,
    pad_token_id=processor.tokenizer.pad_token_id,
    eos_token_id=processor.tokenizer.eos_token_id,
    use_cache=True,
    num_beams=1,
    bad_words_ids=[[processor.tokenizer.unk_token_id]],
    return_dict_in_generate=True,
)

sequence = processor.batch_decode(outputs.sequences)[0]
sequence = sequence.replace(processor.tokenizer.eos_token, "").replace(processor.tokenizer.pad_token, "")
sequence = re.sub(r"<.*?>", "", sequence, count=1).strip()  # remove first task start token
print(processor.token2json(sequence))`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> re

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DonutProcessor, VisionEncoderDecoderModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = DonutProcessor.from_pretrained(<span class="hljs-string">&quot;naver-clova-ix/donut-base-finetuned-rvlcdip&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;naver-clova-ix/donut-base-finetuned-rvlcdip&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&quot;cuda&quot;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cpu&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load document image</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;hf-internal-testing/example-documents&quot;</span>, split=<span class="hljs-string">&quot;test&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = dataset[<span class="hljs-number">1</span>][<span class="hljs-string">&quot;image&quot;</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># prepare decoder inputs</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>task_prompt = <span class="hljs-string">&quot;&lt;s_rvlcdip&gt;&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder_input_ids = processor.tokenizer(task_prompt, add_special_tokens=<span class="hljs-literal">False</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids

<span class="hljs-meta">&gt;&gt;&gt; </span>pixel_values = processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).pixel_values

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(
<span class="hljs-meta">... </span>    pixel_values.to(device),
<span class="hljs-meta">... </span>    decoder_input_ids=decoder_input_ids.to(device),
<span class="hljs-meta">... </span>    max_length=model.decoder.config.max_position_embeddings,
<span class="hljs-meta">... </span>    early_stopping=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    pad_token_id=processor.tokenizer.pad_token_id,
<span class="hljs-meta">... </span>    eos_token_id=processor.tokenizer.eos_token_id,
<span class="hljs-meta">... </span>    use_cache=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    num_beams=<span class="hljs-number">1</span>,
<span class="hljs-meta">... </span>    bad_words_ids=[[processor.tokenizer.unk_token_id]],
<span class="hljs-meta">... </span>    return_dict_in_generate=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>sequence = processor.batch_decode(outputs.sequences)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>sequence = sequence.replace(processor.tokenizer.eos_token, <span class="hljs-string">&quot;&quot;</span>).replace(processor.tokenizer.pad_token, <span class="hljs-string">&quot;&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>sequence = re.sub(<span class="hljs-string">r&quot;&lt;.*?&gt;&quot;</span>, <span class="hljs-string">&quot;&quot;</span>, sequence, count=<span class="hljs-number">1</span>).strip()  <span class="hljs-comment"># remove first task start token</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(processor.token2json(sequence))
{<span class="hljs-string">&#x27;class&#x27;</span>: <span class="hljs-string">&#x27;advertisement&#x27;</span>}`}}),Oe=new Lo({props:{code:`import re

from transformers import DonutProcessor, VisionEncoderDecoderModel
from datasets import load_dataset
import torch

processor = DonutProcessor.from_pretrained("naver-clova-ix/donut-base-finetuned-cord-v2")
model = VisionEncoderDecoderModel.from_pretrained("naver-clova-ix/donut-base-finetuned-cord-v2")

device = "cuda" if torch.cuda.is_available() else "cpu"
model.to(device)
# load document image
dataset = load_dataset("hf-internal-testing/example-documents", split="test")
image = dataset[2]["image"]

# prepare decoder inputs
task_prompt = "<s_cord-v2>"
decoder_input_ids = processor.tokenizer(task_prompt, add_special_tokens=False, return_tensors="pt").input_ids

pixel_values = processor(image, return_tensors="pt").pixel_values

outputs = model.generate(
    pixel_values.to(device),
    decoder_input_ids=decoder_input_ids.to(device),
    max_length=model.decoder.config.max_position_embeddings,
    early_stopping=True,
    pad_token_id=processor.tokenizer.pad_token_id,
    eos_token_id=processor.tokenizer.eos_token_id,
    use_cache=True,
    num_beams=1,
    bad_words_ids=[[processor.tokenizer.unk_token_id]],
    return_dict_in_generate=True,
)

sequence = processor.batch_decode(outputs.sequences)[0]
sequence = sequence.replace(processor.tokenizer.eos_token, "").replace(processor.tokenizer.pad_token, "")
sequence = re.sub(r"<.*?>", "", sequence, count=1).strip()  # remove first task start token
print(processor.token2json(sequence))`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> re

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DonutProcessor, VisionEncoderDecoderModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = DonutProcessor.from_pretrained(<span class="hljs-string">&quot;naver-clova-ix/donut-base-finetuned-cord-v2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;naver-clova-ix/donut-base-finetuned-cord-v2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&quot;cuda&quot;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cpu&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load document image</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;hf-internal-testing/example-documents&quot;</span>, split=<span class="hljs-string">&quot;test&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = dataset[<span class="hljs-number">2</span>][<span class="hljs-string">&quot;image&quot;</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># prepare decoder inputs</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>task_prompt = <span class="hljs-string">&quot;&lt;s_cord-v2&gt;&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder_input_ids = processor.tokenizer(task_prompt, add_special_tokens=<span class="hljs-literal">False</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids

<span class="hljs-meta">&gt;&gt;&gt; </span>pixel_values = processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).pixel_values

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(
<span class="hljs-meta">... </span>    pixel_values.to(device),
<span class="hljs-meta">... </span>    decoder_input_ids=decoder_input_ids.to(device),
<span class="hljs-meta">... </span>    max_length=model.decoder.config.max_position_embeddings,
<span class="hljs-meta">... </span>    early_stopping=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    pad_token_id=processor.tokenizer.pad_token_id,
<span class="hljs-meta">... </span>    eos_token_id=processor.tokenizer.eos_token_id,
<span class="hljs-meta">... </span>    use_cache=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    num_beams=<span class="hljs-number">1</span>,
<span class="hljs-meta">... </span>    bad_words_ids=[[processor.tokenizer.unk_token_id]],
<span class="hljs-meta">... </span>    return_dict_in_generate=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>sequence = processor.batch_decode(outputs.sequences)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>sequence = sequence.replace(processor.tokenizer.eos_token, <span class="hljs-string">&quot;&quot;</span>).replace(processor.tokenizer.pad_token, <span class="hljs-string">&quot;&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>sequence = re.sub(<span class="hljs-string">r&quot;&lt;.*?&gt;&quot;</span>, <span class="hljs-string">&quot;&quot;</span>, sequence, count=<span class="hljs-number">1</span>).strip()  <span class="hljs-comment"># remove first task start token</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(processor.token2json(sequence))
{<span class="hljs-string">&#x27;menu&#x27;</span>: {<span class="hljs-string">&#x27;nm&#x27;</span>: <span class="hljs-string">&#x27;CINNAMON SUGAR&#x27;</span>, <span class="hljs-string">&#x27;unitprice&#x27;</span>: <span class="hljs-string">&#x27;17,000&#x27;</span>, <span class="hljs-string">&#x27;cnt&#x27;</span>: <span class="hljs-string">&#x27;1 x&#x27;</span>, <span class="hljs-string">&#x27;price&#x27;</span>: <span class="hljs-string">&#x27;17,000&#x27;</span>}, <span class="hljs-string">&#x27;sub_total&#x27;</span>: {<span class="hljs-string">&#x27;subtotal_price&#x27;</span>: <span class="hljs-string">&#x27;17,000&#x27;</span>}, <span class="hljs-string">&#x27;total&#x27;</span>: {<span class="hljs-string">&#x27;total_price&#x27;</span>: <span class="hljs-string">&#x27;17,000&#x27;</span>, <span class="hljs-string">&#x27;cashprice&#x27;</span>: <span class="hljs-string">&#x27;20,000&#x27;</span>, <span class="hljs-string">&#x27;changeprice&#x27;</span>: <span class="hljs-string">&#x27;3,000&#x27;</span>}}`}}),Ve=new Lo({props:{code:`import re

from transformers import DonutProcessor, VisionEncoderDecoderModel
from datasets import load_dataset
import torch

processor = DonutProcessor.from_pretrained("naver-clova-ix/donut-base-finetuned-docvqa")
model = VisionEncoderDecoderModel.from_pretrained("naver-clova-ix/donut-base-finetuned-docvqa")

device = "cuda" if torch.cuda.is_available() else "cpu"
model.to(device)
# load document image from the DocVQA dataset
dataset = load_dataset("hf-internal-testing/example-documents", split="test")
image = dataset[0]["image"]

# prepare decoder inputs
task_prompt = "<s_docvqa><s_question>{user_input}</s_question><s_answer>"
question = "When is the coffee break?"
prompt = task_prompt.replace("{user_input}", question)
decoder_input_ids = processor.tokenizer(prompt, add_special_tokens=False, return_tensors="pt").input_ids

pixel_values = processor(image, return_tensors="pt").pixel_values

outputs = model.generate(
    pixel_values.to(device),
    decoder_input_ids=decoder_input_ids.to(device),
    max_length=model.decoder.config.max_position_embeddings,
    early_stopping=True,
    pad_token_id=processor.tokenizer.pad_token_id,
    eos_token_id=processor.tokenizer.eos_token_id,
    use_cache=True,
    num_beams=1,
    bad_words_ids=[[processor.tokenizer.unk_token_id]],
    return_dict_in_generate=True,
)

sequence = processor.batch_decode(outputs.sequences)[0]
sequence = sequence.replace(processor.tokenizer.eos_token, "").replace(processor.tokenizer.pad_token, "")
sequence = re.sub(r"<.*?>", "", sequence, count=1).strip()  # remove first task start token
print(processor.token2json(sequence))`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> re

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DonutProcessor, VisionEncoderDecoderModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = DonutProcessor.from_pretrained(<span class="hljs-string">&quot;naver-clova-ix/donut-base-finetuned-docvqa&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;naver-clova-ix/donut-base-finetuned-docvqa&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&quot;cuda&quot;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cpu&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load document image from the DocVQA dataset</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;hf-internal-testing/example-documents&quot;</span>, split=<span class="hljs-string">&quot;test&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = dataset[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;image&quot;</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># prepare decoder inputs</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>task_prompt = <span class="hljs-string">&quot;&lt;s_docvqa&gt;&lt;s_question&gt;{user_input}&lt;/s_question&gt;&lt;s_answer&gt;&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>question = <span class="hljs-string">&quot;When is the coffee break?&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = task_prompt.replace(<span class="hljs-string">&quot;{user_input}&quot;</span>, question)
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder_input_ids = processor.tokenizer(prompt, add_special_tokens=<span class="hljs-literal">False</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids

<span class="hljs-meta">&gt;&gt;&gt; </span>pixel_values = processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).pixel_values

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(
<span class="hljs-meta">... </span>    pixel_values.to(device),
<span class="hljs-meta">... </span>    decoder_input_ids=decoder_input_ids.to(device),
<span class="hljs-meta">... </span>    max_length=model.decoder.config.max_position_embeddings,
<span class="hljs-meta">... </span>    early_stopping=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    pad_token_id=processor.tokenizer.pad_token_id,
<span class="hljs-meta">... </span>    eos_token_id=processor.tokenizer.eos_token_id,
<span class="hljs-meta">... </span>    use_cache=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    num_beams=<span class="hljs-number">1</span>,
<span class="hljs-meta">... </span>    bad_words_ids=[[processor.tokenizer.unk_token_id]],
<span class="hljs-meta">... </span>    return_dict_in_generate=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>sequence = processor.batch_decode(outputs.sequences)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>sequence = sequence.replace(processor.tokenizer.eos_token, <span class="hljs-string">&quot;&quot;</span>).replace(processor.tokenizer.pad_token, <span class="hljs-string">&quot;&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>sequence = re.sub(<span class="hljs-string">r&quot;&lt;.*?&gt;&quot;</span>, <span class="hljs-string">&quot;&quot;</span>, sequence, count=<span class="hljs-number">1</span>).strip()  <span class="hljs-comment"># remove first task start token</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(processor.token2json(sequence))
{<span class="hljs-string">&#x27;question&#x27;</span>: <span class="hljs-string">&#x27;When is the coffee break?&#x27;</span>, <span class="hljs-string">&#x27;answer&#x27;</span>: <span class="hljs-string">&#x27;11-14 to 11:39 a.m.&#x27;</span>}`}}),We=new ne({}),Xe=new ne({}),Be=new N({props:{name:"class transformers.DonutSwinConfig",anchor:"transformers.DonutSwinConfig",parameters:[{name:"image_size",val:" = 224"},{name:"patch_size",val:" = 4"},{name:"num_channels",val:" = 3"},{name:"embed_dim",val:" = 96"},{name:"depths",val:" = [2, 2, 6, 2]"},{name:"num_heads",val:" = [3, 6, 12, 24]"},{name:"window_size",val:" = 7"},{name:"mlp_ratio",val:" = 4.0"},{name:"qkv_bias",val:" = True"},{name:"hidden_dropout_prob",val:" = 0.0"},{name:"attention_probs_dropout_prob",val:" = 0.0"},{name:"drop_path_rate",val:" = 0.1"},{name:"hidden_act",val:" = 'gelu'"},{name:"use_absolute_embeddings",val:" = False"},{name:"patch_norm",val:" = True"},{name:"initializer_range",val:" = 0.02"},{name:"layer_norm_eps",val:" = 1e-05"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.DonutSwinConfig.image_size",description:`<strong>image_size</strong> (<code>int</code>, <em>optional</em>, defaults to 224) &#x2014;
The size (resolution) of each image.`,name:"image_size"},{anchor:"transformers.DonutSwinConfig.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014;
The size (resolution) of each patch.`,name:"patch_size"},{anchor:"transformers.DonutSwinConfig.num_channels",description:`<strong>num_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 3) &#x2014;
The number of input channels.`,name:"num_channels"},{anchor:"transformers.DonutSwinConfig.embed_dim",description:`<strong>embed_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 96) &#x2014;
Dimensionality of patch embedding.`,name:"embed_dim"},{anchor:"transformers.DonutSwinConfig.depths",description:`<strong>depths</strong> (<code>list(int)</code>, <em>optional</em>, defaults to [2, 2, 6, 2]) &#x2014;
Depth of each layer in the Transformer encoder.`,name:"depths"},{anchor:"transformers.DonutSwinConfig.num_heads",description:`<strong>num_heads</strong> (<code>list(int)</code>, <em>optional</em>, defaults to [3, 6, 12, 24]) &#x2014;
Number of attention heads in each layer of the Transformer encoder.`,name:"num_heads"},{anchor:"transformers.DonutSwinConfig.window_size",description:`<strong>window_size</strong> (<code>int</code>, <em>optional</em>, defaults to 7) &#x2014;
Size of windows.`,name:"window_size"},{anchor:"transformers.DonutSwinConfig.mlp_ratio",description:`<strong>mlp_ratio</strong> (<code>float</code>, <em>optional</em>, defaults to 4.0) &#x2014;
Ratio of MLP hidden dimensionality to embedding dimensionality.`,name:"mlp_ratio"},{anchor:"transformers.DonutSwinConfig.qkv_bias",description:`<strong>qkv_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to True) &#x2014;
Whether or not a learnable bias should be added to the queries, keys and values.`,name:"qkv_bias"},{anchor:"transformers.DonutSwinConfig.hidden_dropout_prob",description:`<strong>hidden_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout probability for all fully connected layers in the embeddings and encoder.`,name:"hidden_dropout_prob"},{anchor:"transformers.DonutSwinConfig.attention_probs_dropout_prob",description:`<strong>attention_probs_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout ratio for the attention probabilities.`,name:"attention_probs_dropout_prob"},{anchor:"transformers.DonutSwinConfig.drop_path_rate",description:`<strong>drop_path_rate</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
Stochastic depth rate.`,name:"drop_path_rate"},{anchor:"transformers.DonutSwinConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the encoder. If string, <code>&quot;gelu&quot;</code>, <code>&quot;relu&quot;</code>,
<code>&quot;selu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"hidden_act"},{anchor:"transformers.DonutSwinConfig.use_absolute_embeddings",description:`<strong>use_absolute_embeddings</strong> (<code>bool</code>, <em>optional</em>, defaults to False) &#x2014;
Whether or not to add absolute position embeddings to the patch embeddings.`,name:"use_absolute_embeddings"},{anchor:"transformers.DonutSwinConfig.patch_norm",description:`<strong>patch_norm</strong> (<code>bool</code>, <em>optional</em>, defaults to True) &#x2014;
Whether or not to add layer normalization after patch embedding.`,name:"patch_norm"},{anchor:"transformers.DonutSwinConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.DonutSwinConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-12) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"}],source:"https://github.com/huggingface/transformers/blob/v4.25.1/src/transformers/models/donut/configuration_donut_swin.py#L29"}}),fe=new Qi({props:{anchor:"transformers.DonutSwinConfig.example",$$slots:{default:[nl]},$$scope:{ctx:L}}}),Je=new ne({}),Ye=new N({props:{name:"class transformers.DonutImageProcessor",anchor:"transformers.DonutImageProcessor",parameters:[{name:"do_resize",val:": bool = True"},{name:"size",val:": typing.Dict[str, int] = None"},{name:"resample",val:": Resampling = <Resampling.BILINEAR: 2>"},{name:"do_thumbnail",val:": bool = True"},{name:"do_align_long_axis",val:": bool = False"},{name:"do_pad",val:": bool = True"},{name:"do_rescale",val:": bool = True"},{name:"rescale_factor",val:": typing.Union[int, float] = 0.00392156862745098"},{name:"do_normalize",val:": bool = True"},{name:"image_mean",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"image_std",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.DonutImageProcessor.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to resize the image&#x2019;s (height, width) dimensions to the specified <code>size</code>. Can be overridden by
<code>do_resize</code> in the <code>preprocess</code> method.`,name:"do_resize"},{anchor:"transformers.DonutImageProcessor.size",description:`<strong>size</strong> (<code>Dict[str, int]</code> <em>optional</em>, defaults to <code>{&quot;shortest_edge&quot; -- 224}</code>):
Size of the image after resizing. The shortest edge of the image is resized to size[&#x201C;shortest_edge&#x201D;], with
the longest edge resized to keep the input aspect ratio. Can be overridden by <code>size</code> in the <code>preprocess</code>
method.`,name:"size"},{anchor:"transformers.DonutImageProcessor.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code>, <em>optional</em>, defaults to <code>PILImageResampling.BILINEAR</code>) &#x2014;
Resampling filter to use if resizing the image. Can be overridden by <code>resample</code> in the <code>preprocess</code> method.`,name:"resample"},{anchor:"transformers.DonutImageProcessor.do_center_crop",description:`<strong>do_center_crop</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to center crop the image to the specified <code>crop_size</code>. Can be overridden by <code>do_center_crop</code> in the
<code>preprocess</code> method.`,name:"do_center_crop"},{anchor:"transformers.DonutImageProcessor.crop_size",description:`<strong>crop_size</strong> (<code>Dict[str, int]</code> <em>optional</em>, defaults to 224) &#x2014;
Size of the output image after applying <code>center_crop</code>. Can be overridden by <code>crop_size</code> in the <code>preprocess</code>
method.`,name:"crop_size"},{anchor:"transformers.DonutImageProcessor.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to rescale the image by the specified scale <code>rescale_factor</code>. Can be overridden by <code>do_rescale</code> in
the <code>preprocess</code> method.`,name:"do_rescale"},{anchor:"transformers.DonutImageProcessor.rescale_factor",description:`<strong>rescale_factor</strong> (<code>int</code> or <code>float</code>, <em>optional</em>, defaults to <code>1/255</code>) &#x2014;
Scale factor to use if rescaling the image. Can be overridden by <code>rescale_factor</code> in the <code>preprocess</code>
method.
do_normalize &#x2014;
Whether to normalize the image. Can be overridden by <code>do_normalize</code> in the <code>preprocess</code> method.`,name:"rescale_factor"},{anchor:"transformers.DonutImageProcessor.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IMAGENET_STANDARD_MEAN</code>) &#x2014;
Mean to use if normalizing the image. This is a float or list of floats the length of the number of
channels in the image. Can be overridden by the <code>image_mean</code> parameter in the <code>preprocess</code> method.`,name:"image_mean"},{anchor:"transformers.DonutImageProcessor.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IMAGENET_STANDARD_STD</code>) &#x2014;
Image standard deviation.`,name:"image_std"},{anchor:"transformers.DonutImageProcessor.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Standard deviation to use if normalizing the image. This is a float or list of floats the length of the
number of channels in the image. Can be overridden by the <code>image_std</code> parameter in the <code>preprocess</code> method.`,name:"do_convert_rgb"}],source:"https://github.com/huggingface/transformers/blob/v4.25.1/src/transformers/models/donut/image_processing_donut.py#L52"}}),Qe=new N({props:{name:"preprocess",anchor:"transformers.DonutImageProcessor.preprocess",parameters:[{name:"images",val:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), typing.List[ForwardRef('PIL.Image.Image')], typing.List[numpy.ndarray], typing.List[ForwardRef('torch.Tensor')]]"},{name:"do_resize",val:": bool = None"},{name:"size",val:": typing.Dict[str, int] = None"},{name:"resample",val:": Resampling = None"},{name:"do_thumbnail",val:": bool = None"},{name:"do_align_long_axis",val:": bool = None"},{name:"do_pad",val:": bool = None"},{name:"random_padding",val:": bool = False"},{name:"do_rescale",val:": bool = None"},{name:"rescale_factor",val:": float = None"},{name:"do_normalize",val:": bool = None"},{name:"image_mean",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"image_std",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"return_tensors",val:": typing.Union[str, transformers.utils.generic.TensorType, NoneType] = None"},{name:"data_format",val:": typing.Optional[transformers.image_utils.ChannelDimension] = <ChannelDimension.FIRST: 'channels_first'>"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.DonutImageProcessor.preprocess.images",description:`<strong>images</strong> (<code>ImageInput</code>) &#x2014;
Image to preprocess.`,name:"images"},{anchor:"transformers.DonutImageProcessor.preprocess.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_resize</code>) &#x2014;
Whether to resize the image.`,name:"do_resize"},{anchor:"transformers.DonutImageProcessor.preprocess.size",description:`<strong>size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>self.size</code>) &#x2014;
Size of the image after resizing. Shortest edge of the image is resized to min(size[&#x201C;height&#x201D;],
size[&#x201C;width&#x201D;]) with the longest edge resized to keep the input aspect ratio.`,name:"size"},{anchor:"transformers.DonutImageProcessor.preprocess.resample",description:`<strong>resample</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.resample</code>) &#x2014;
Resampling filter to use if resizing the image. This can be one of the enum <code>PILImageResampling</code>. Only
has an effect if <code>do_resize</code> is set to <code>True</code>.`,name:"resample"},{anchor:"transformers.DonutImageProcessor.preprocess.do_thumbnail",description:`<strong>do_thumbnail</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_thumbnail</code>) &#x2014;
Whether to resize the image using thumbnail method.`,name:"do_thumbnail"},{anchor:"transformers.DonutImageProcessor.preprocess.do_align_long_axis",description:`<strong>do_align_long_axis</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_align_long_axis</code>) &#x2014;
Whether to align the long axis of the image with the long axis of <code>size</code> by rotating by 90 degrees.`,name:"do_align_long_axis"},{anchor:"transformers.DonutImageProcessor.preprocess.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_pad</code>) &#x2014;
Whether to pad the image. If <code>random_padding</code> is set to <code>True</code>, each image is padded with a random
amont of padding on each size, up to the largest image size in the batch. Otherwise, all images are
padded to the largest image size in the batch.`,name:"do_pad"},{anchor:"transformers.DonutImageProcessor.preprocess.random_padding",description:`<strong>random_padding</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.random_padding</code>) &#x2014;
Whether to use random padding when padding the image. If <code>True</code>, each image in the batch with be padded
with a random amount of padding on each side up to the size of the largest image in the batch.`,name:"random_padding"},{anchor:"transformers.DonutImageProcessor.preprocess.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_rescale</code>) &#x2014;
Whether to rescale the image pixel values.`,name:"do_rescale"},{anchor:"transformers.DonutImageProcessor.preprocess.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>optional</em>, defaults to <code>self.rescale_factor</code>) &#x2014;
Rescale factor to rescale the image by if <code>do_rescale</code> is set to <code>True</code>.`,name:"rescale_factor"},{anchor:"transformers.DonutImageProcessor.preprocess.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_normalize</code>) &#x2014;
Whether to normalize the image.`,name:"do_normalize"},{anchor:"transformers.DonutImageProcessor.preprocess.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_mean</code>) &#x2014;
Image mean to use for normalization.`,name:"image_mean"},{anchor:"transformers.DonutImageProcessor.preprocess.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_std</code>) &#x2014;
Image standard deviation to use for normalization.`,name:"image_std"},{anchor:"transformers.DonutImageProcessor.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <code>TensorType</code>, <em>optional</em>) &#x2014;
The type of tensors to return. Can be one of:<ul>
<li>Unset: Return a list of <code>np.ndarray</code>.</li>
<li><code>TensorType.TENSORFLOW</code> or <code>&apos;tf&apos;</code>: Return a batch of type <code>tf.Tensor</code>.</li>
<li><code>TensorType.PYTORCH</code> or <code>&apos;pt&apos;</code>: Return a batch of type <code>torch.Tensor</code>.</li>
<li><code>TensorType.NUMPY</code> or <code>&apos;np&apos;</code>: Return a batch of type <code>np.ndarray</code>.</li>
<li><code>TensorType.JAX</code> or <code>&apos;jax&apos;</code>: Return a batch of type <code>jax.numpy.ndarray</code>.</li>
</ul>`,name:"return_tensors"},{anchor:"transformers.DonutImageProcessor.preprocess.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>, defaults to <code>ChannelDimension.FIRST</code>) &#x2014;
The channel dimension format for the output image. Can be one of:<ul>
<li><code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
<li>Unset: defaults to the channel dimension format of the input image.</li>
</ul>`,name:"data_format"}],source:"https://github.com/huggingface/transformers/blob/v4.25.1/src/transformers/models/donut/image_processing_donut.py#L298"}}),Ke=new ne({}),Ze=new N({props:{name:"class transformers.DonutImageProcessor",anchor:"transformers.DonutImageProcessor",parameters:[{name:"do_resize",val:": bool = True"},{name:"size",val:": typing.Dict[str, int] = None"},{name:"resample",val:": Resampling = <Resampling.BILINEAR: 2>"},{name:"do_thumbnail",val:": bool = True"},{name:"do_align_long_axis",val:": bool = False"},{name:"do_pad",val:": bool = True"},{name:"do_rescale",val:": bool = True"},{name:"rescale_factor",val:": typing.Union[int, float] = 0.00392156862745098"},{name:"do_normalize",val:": bool = True"},{name:"image_mean",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"image_std",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.DonutImageProcessor.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to resize the image&#x2019;s (height, width) dimensions to the specified <code>size</code>. Can be overridden by
<code>do_resize</code> in the <code>preprocess</code> method.`,name:"do_resize"},{anchor:"transformers.DonutImageProcessor.size",description:`<strong>size</strong> (<code>Dict[str, int]</code> <em>optional</em>, defaults to <code>{&quot;shortest_edge&quot; -- 224}</code>):
Size of the image after resizing. The shortest edge of the image is resized to size[&#x201C;shortest_edge&#x201D;], with
the longest edge resized to keep the input aspect ratio. Can be overridden by <code>size</code> in the <code>preprocess</code>
method.`,name:"size"},{anchor:"transformers.DonutImageProcessor.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code>, <em>optional</em>, defaults to <code>PILImageResampling.BILINEAR</code>) &#x2014;
Resampling filter to use if resizing the image. Can be overridden by <code>resample</code> in the <code>preprocess</code> method.`,name:"resample"},{anchor:"transformers.DonutImageProcessor.do_center_crop",description:`<strong>do_center_crop</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to center crop the image to the specified <code>crop_size</code>. Can be overridden by <code>do_center_crop</code> in the
<code>preprocess</code> method.`,name:"do_center_crop"},{anchor:"transformers.DonutImageProcessor.crop_size",description:`<strong>crop_size</strong> (<code>Dict[str, int]</code> <em>optional</em>, defaults to 224) &#x2014;
Size of the output image after applying <code>center_crop</code>. Can be overridden by <code>crop_size</code> in the <code>preprocess</code>
method.`,name:"crop_size"},{anchor:"transformers.DonutImageProcessor.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to rescale the image by the specified scale <code>rescale_factor</code>. Can be overridden by <code>do_rescale</code> in
the <code>preprocess</code> method.`,name:"do_rescale"},{anchor:"transformers.DonutImageProcessor.rescale_factor",description:`<strong>rescale_factor</strong> (<code>int</code> or <code>float</code>, <em>optional</em>, defaults to <code>1/255</code>) &#x2014;
Scale factor to use if rescaling the image. Can be overridden by <code>rescale_factor</code> in the <code>preprocess</code>
method.
do_normalize &#x2014;
Whether to normalize the image. Can be overridden by <code>do_normalize</code> in the <code>preprocess</code> method.`,name:"rescale_factor"},{anchor:"transformers.DonutImageProcessor.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IMAGENET_STANDARD_MEAN</code>) &#x2014;
Mean to use if normalizing the image. This is a float or list of floats the length of the number of
channels in the image. Can be overridden by the <code>image_mean</code> parameter in the <code>preprocess</code> method.`,name:"image_mean"},{anchor:"transformers.DonutImageProcessor.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IMAGENET_STANDARD_STD</code>) &#x2014;
Image standard deviation.`,name:"image_std"},{anchor:"transformers.DonutImageProcessor.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Standard deviation to use if normalizing the image. This is a float or list of floats the length of the
number of channels in the image. Can be overridden by the <code>image_std</code> parameter in the <code>preprocess</code> method.`,name:"do_convert_rgb"}],source:"https://github.com/huggingface/transformers/blob/v4.25.1/src/transformers/models/donut/image_processing_donut.py#L52"}}),et=new N({props:{name:"__call__",anchor:"transformers.DonutImageProcessor.__call__",parameters:[{name:"images",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.25.1/src/transformers/image_processing_utils.py#L435"}}),tt=new ne({}),ot=new N({props:{name:"class transformers.DonutProcessor",anchor:"transformers.DonutProcessor",parameters:[{name:"image_processor",val:" = None"},{name:"tokenizer",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.DonutProcessor.feature_extractor",description:`<strong>feature_extractor</strong> (<a href="/docs/transformers/v4.25.1/en/model_doc/donut#transformers.DonutImageProcessor">DonutFeatureExtractor</a>) &#x2014;
An instance of <a href="/docs/transformers/v4.25.1/en/model_doc/donut#transformers.DonutImageProcessor">DonutFeatureExtractor</a>. The feature extractor is a required input.`,name:"feature_extractor"},{anchor:"transformers.DonutProcessor.tokenizer",description:`<strong>tokenizer</strong> ([<code>XLMRobertaTokenizer</code>/<code>XLMRobertaTokenizerFast</code>]) &#x2014;
An instance of [<code>XLMRobertaTokenizer</code>/<code>XLMRobertaTokenizerFast</code>]. The tokenizer is a required input.`,name:"tokenizer"}],source:"https://github.com/huggingface/transformers/blob/v4.25.1/src/transformers/models/donut/processing_donut.py#L25"}}),at=new N({props:{name:"__call__",anchor:"transformers.DonutProcessor.__call__",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.25.1/src/transformers/models/donut/processing_donut.py#L63"}}),nt=new N({props:{name:"from_pretrained",anchor:"transformers.DonutProcessor.from_pretrained",parameters:[{name:"pretrained_model_name_or_path",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.DonutProcessor.from_pretrained.pretrained_model_name_or_path",description:`<strong>pretrained_model_name_or_path</strong> (<code>str</code> or <code>os.PathLike</code>) &#x2014;
This can be either:</p>
<ul>
<li>a string, the <em>model id</em> of a pretrained feature_extractor hosted inside a model repo on
huggingface.co. Valid model ids can be located at the root-level, like <code>bert-base-uncased</code>, or
namespaced under a user or organization name, like <code>dbmdz/bert-base-german-cased</code>.</li>
<li>a path to a <em>directory</em> containing a feature extractor file saved using the
<a href="/docs/transformers/v4.25.1/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin.save_pretrained">save_pretrained()</a> method, e.g., <code>./my_model_directory/</code>.</li>
<li>a path or url to a saved feature extractor JSON <em>file</em>, e.g.,
<code>./my_model_directory/preprocessor_config.json</code>.
**kwargs &#x2014;
Additional keyword arguments passed along to both
<a href="/docs/transformers/v4.25.1/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin.from_pretrained">from_pretrained()</a> and
<code>~tokenization_utils_base.PreTrainedTokenizer.from_pretrained</code>.</li>
</ul>`,name:"pretrained_model_name_or_path"}],source:"https://github.com/huggingface/transformers/blob/v4.25.1/src/transformers/processing_utils.py#L153"}}),ke=new Tr({props:{$$slots:{default:[rl]},$$scope:{ctx:L}}}),rt=new N({props:{name:"save_pretrained",anchor:"transformers.DonutProcessor.save_pretrained",parameters:[{name:"save_directory",val:""},{name:"push_to_hub",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.DonutProcessor.save_pretrained.save_directory",description:`<strong>save_directory</strong> (<code>str</code> or <code>os.PathLike</code>) &#x2014;
Directory where the feature extractor JSON file and the tokenizer files will be saved (directory will
be created if it does not exist).`,name:"save_directory"},{anchor:"transformers.DonutProcessor.save_pretrained.push_to_hub",description:`<strong>push_to_hub</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to push your model to the Hugging Face model hub after saving it. You can specify the
repository you want to push to with <code>repo_id</code> (will default to the name of <code>save_directory</code> in your
namespace).
kwargs &#x2014;
Additional key word arguments passed along to the <a href="/docs/transformers/v4.25.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.push_to_hub">push_to_hub()</a> method.`,name:"push_to_hub"}],source:"https://github.com/huggingface/transformers/blob/v4.25.1/src/transformers/processing_utils.py#L95"}}),xe=new Tr({props:{$$slots:{default:[il]},$$scope:{ctx:L}}}),lt=new N({props:{name:"batch_decode",anchor:"transformers.DonutProcessor.batch_decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.25.1/src/transformers/models/donut/processing_donut.py#L96"}}),ct=new N({props:{name:"decode",anchor:"transformers.DonutProcessor.decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.25.1/src/transformers/models/donut/processing_donut.py#L103"}}),mt=new ne({}),ut=new N({props:{name:"class transformers.DonutSwinModel",anchor:"transformers.DonutSwinModel",parameters:[{name:"config",val:""},{name:"add_pooling_layer",val:" = True"},{name:"use_mask_token",val:" = False"}],parametersDescription:[{anchor:"transformers.DonutSwinModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.25.1/en/model_doc/donut#transformers.DonutSwinConfig">DonutSwinConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.25.1/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.25.1/src/transformers/models/donut/modeling_donut_swin.py#L851"}}),gt=new N({props:{name:"forward",anchor:"transformers.DonutSwinModel.forward",parameters:[{name:"pixel_values",val:": typing.Optional[torch.FloatTensor] = None"},{name:"bool_masked_pos",val:": typing.Optional[torch.BoolTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.DonutSwinModel.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/v4.25.1/en/model_doc/auto#transformers.AutoFeatureExtractor">AutoFeatureExtractor</a>. See
<code>AutoFeatureExtractor.__call__()</code> for details.`,name:"pixel_values"},{anchor:"transformers.DonutSwinModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.DonutSwinModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.DonutSwinModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.DonutSwinModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.25.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.25.1/src/transformers/models/donut/modeling_donut_swin.py#L877",returnDescription:`
<p>A <code>transformers.models.donut.modeling_donut_swin.DonutSwinModelOutput</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.25.1/en/model_doc/donut#transformers.DonutSwinConfig"
>DonutSwinConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>pooler_output</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, hidden_size)</code>, <em>optional</em>, returned when <code>add_pooling_layer=True</code> is passed) \u2014 Average pooling of the last layer hidden-state.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each stage) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each stage) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
<li>
<p><strong>reshaped_hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each stage) of
shape <code>(batch_size, hidden_size, height, width)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs reshaped to
include the spatial dimensions.</p>
</li>
</ul>
`,returnType:`
<p><code>transformers.models.donut.modeling_donut_swin.DonutSwinModelOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Te=new Tr({props:{$$slots:{default:[ll]},$$scope:{ctx:L}}}),ze=new Qi({props:{anchor:"transformers.DonutSwinModel.forward.example",$$slots:{default:[dl]},$$scope:{ctx:L}}}),{c(){h=s("meta"),$=c(),f=s("h1"),g=s("a"),y=s("span"),v(u.$$.fragment),_=c(),E=s("span"),I=r("Donut"),j=c(),C=s("h2"),A=s("a"),Qt=s("span"),v(Se.$$.fragment),Fs=c(),Kt=s("span"),Os=r("Overview"),Fo=c(),re=s("p"),Vs=r("The Donut model was proposed in "),Ie=s("a"),Us=r("OCR-free Document Understanding Transformer"),Ws=r(` by
Geewook Kim, Teakgyu Hong, Moonbin Yim, Jeongyeon Nam, Jinyoung Park, Jinyeong Yim, Wonseok Hwang, Sangdoo Yun, Dongyoon Han, Seunghyun Park.
Donut consists of an image Transformer encoder and an autoregressive text Transformer decoder to perform document understanding
tasks such as document image classification, form understanding and visual question answering.`),Oo=c(),bt=s("p"),Hs=r("The abstract from the paper is the following:"),Vo=c(),wt=s("p"),Zt=s("em"),Xs=r("Understanding document images (e.g., invoices) is a core but challenging task since it requires complex functions such as reading text and a holistic understanding of the document. Current Visual Document Understanding (VDU) methods outsource the task of reading text to off-the-shelf Optical Character Recognition (OCR) engines and focus on the understanding task with the OCR outputs. Although such OCR-based approaches have shown promising performance, they suffer from 1) high computational costs for using OCR; 2) inflexibility of OCR models on languages or types of document; 3) OCR error propagation to the subsequent process. To address these issues, in this paper, we introduce a novel OCR-free VDU model named Donut, which stands for Document understanding transformer. As the first step in OCR-free VDU research, we propose a simple architecture (i.e., Transformer) with a pre-training objective (i.e., cross-entropy loss). Donut is conceptually simple yet effective. Through extensive experiments and analyses, we show a simple OCR-free VDU model, Donut, achieves state-of-the-art performances on various VDU tasks in terms of both speed and accuracy. In addition, we offer a synthetic data generator that helps the model pre-training to be flexible in various languages and domains."),Uo=c(),ie=s("img"),Wo=c(),le=s("small"),Bs=r("Donut high-level overview. Taken from the "),Dt=s("a"),Gs=r("original paper"),Js=r("."),Ho=c(),H=s("p"),Ys=r("This model was contributed by "),Ce=s("a"),Qs=r("nielsr"),Ks=r(`. The original code can be found
`),Ae=s("a"),Zs=r("here"),ea=r("."),Xo=c(),kt=s("p"),ta=r("Tips:"),Bo=c(),de=s("ul"),Me=s("li"),oa=r("The quickest way to get started with Donut is by checking the "),Re=s("a"),sa=r(`tutorial
notebooks`),aa=r(`, which show how to use the model
at inference time as well as fine-tuning on custom data.`),na=c(),Ne=s("li"),ra=r("Donut is always used within the "),xt=s("a"),ia=r("VisionEncoderDecoder"),la=r(" framework."),Go=c(),J=s("h2"),ce=s("a"),eo=s("span"),v(Le.$$.fragment),da=c(),to=s("span"),ca=r("Inference"),Jo=c(),X=s("p"),pa=r("Donut\u2019s "),oo=s("code"),ma=r("VisionEncoderDecoder"),ua=r(` model accepts images as input and makes use of
`),yt=s("a"),ha=r("generate()"),fa=r(" to autoregressively generate text given the input image."),Yo=c(),z=s("p"),ga=r("The "),$t=s("a"),_a=r("DonutFeatureExtractor"),va=r(` class is responsible for preprocessing the input image and
[`),so=s("code"),ba=r("XLMRobertaTokenizer"),wa=r("/"),ao=s("code"),Da=r("XLMRobertaTokenizerFast"),ka=r(`] decodes the generated target tokens to the target string. The
`),jt=s("a"),xa=r("DonutProcessor"),ya=r(" wraps "),Tt=s("a"),$a=r("DonutFeatureExtractor"),ja=r(" and ["),no=s("code"),Ta=r("XLMRobertaTokenizer"),za=r("/"),ro=s("code"),Ea=r("XLMRobertaTokenizerFast"),Pa=r(`]
into a single instance to both extract the input features and decode the predicted token ids.`),Qo=c(),zt=s("ul"),io=s("li"),qa=r("Step-by-step Document Image Classification"),Ko=c(),v(Fe.$$.fragment),Zo=c(),Et=s("ul"),lo=s("li"),Sa=r("Step-by-step Document Parsing"),es=c(),v(Oe.$$.fragment),ts=c(),Pt=s("ul"),co=s("li"),Ia=r("Step-by-step Document Visual Question Answering (DocVQA)"),os=c(),v(Ve.$$.fragment),ss=c(),pe=s("p"),Ca=r("See the "),Ue=s("a"),Aa=r("model hub"),Ma=r(" to look for Donut checkpoints."),as=c(),Y=s("h2"),me=s("a"),po=s("span"),v(We.$$.fragment),Ra=c(),mo=s("span"),Na=r("Training"),ns=c(),ue=s("p"),La=r("We refer to the "),He=s("a"),Fa=r("tutorial notebooks"),Oa=r("."),rs=c(),Q=s("h2"),he=s("a"),uo=s("span"),v(Xe.$$.fragment),Va=c(),ho=s("span"),Ua=r("DonutSwinConfig"),is=c(),M=s("div"),v(Be.$$.fragment),Wa=c(),K=s("p"),Ha=r("This is the configuration class to store the configuration of a "),qt=s("a"),Xa=r("DonutSwinModel"),Ba=r(`. It is used to instantiate a
Donut model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a similar configuration to that of the Donut
`),Ge=s("a"),Ga=r("naver-clova-ix/donut-base"),Ja=r(" architecture."),Ya=c(),Z=s("p"),Qa=r("Configuration objects inherit from "),St=s("a"),Ka=r("PretrainedConfig"),Za=r(` and can be used to control the model outputs. Read the
documentation from `),It=s("a"),en=r("PretrainedConfig"),tn=r(" for more information."),on=c(),v(fe.$$.fragment),ls=c(),ee=s("h2"),ge=s("a"),fo=s("span"),v(Je.$$.fragment),sn=c(),go=s("span"),an=r("DonutImageProcessor"),ds=c(),O=s("div"),v(Ye.$$.fragment),nn=c(),_o=s("p"),rn=r("Constructs a Donut image processor."),ln=c(),_e=s("div"),v(Qe.$$.fragment),dn=c(),vo=s("p"),cn=r("Preprocess an image or batch of images."),cs=c(),te=s("h2"),ve=s("a"),bo=s("span"),v(Ke.$$.fragment),pn=c(),wo=s("span"),mn=r("DonutFeatureExtractor"),ps=c(),V=s("div"),v(Ze.$$.fragment),un=c(),Do=s("p"),hn=r("Constructs a Donut image processor."),fn=c(),be=s("div"),v(et.$$.fragment),gn=c(),ko=s("p"),_n=r("Preprocess an image or a batch of images."),ms=c(),oe=s("h2"),we=s("a"),xo=s("span"),v(tt.$$.fragment),vn=c(),yo=s("span"),bn=r("DonutProcessor"),us=c(),T=s("div"),v(ot.$$.fragment),wn=c(),$o=s("p"),Dn=r(`Constructs a Donut processor which wraps a Donut feature extractor and an XLMRoBERTa tokenizer into a single
processor.`),kn=c(),P=s("p"),Ct=s("a"),xn=r("DonutProcessor"),yn=r(" offers all the functionalities of "),At=s("a"),$n=r("DonutFeatureExtractor"),jn=r(` and
[`),jo=s("code"),Tn=r("XLMRobertaTokenizer"),zn=r("/"),To=s("code"),En=r("XLMRobertaTokenizerFast"),Pn=r("]. See the "),st=s("a"),zo=s("strong"),qn=r("call"),Sn=r("()"),In=r(` and
`),Mt=s("a"),Cn=r("decode()"),An=r(" for more information."),Mn=c(),De=s("div"),v(at.$$.fragment),Rn=c(),U=s("p"),Nn=r(`When used in normal mode, this method forwards all its arguments to AutoFeatureExtractor\u2019s
`),Eo=s("code"),Ln=r("__call__()"),Fn=r(` and returns its output. If used in the context
`),Po=s("code"),On=r("as_target_processor()"),Vn=r(` this method forwards all its arguments to DonutTokenizer\u2019s
`),qo=s("code"),Un=r("~DonutTokenizer.__call__"),Wn=r(". Please refer to the doctsring of the above two methods for more information."),Hn=c(),B=s("div"),v(nt.$$.fragment),Xn=c(),So=s("p"),Bn=r("Instantiate a processor associated with a pretrained model."),Gn=c(),v(ke.$$.fragment),Jn=c(),G=s("div"),v(rt.$$.fragment),Yn=c(),it=s("p"),Qn=r(`Saves the attributes of this processor (feature extractor, tokenizer\u2026) in the specified directory so that it
can be reloaded using the `),Rt=s("a"),Kn=r("from_pretrained()"),Zn=r(" method."),er=c(),v(xe.$$.fragment),tr=c(),ye=s("div"),v(lt.$$.fragment),or=c(),dt=s("p"),sr=r("This method forwards all its arguments to DonutTokenizer\u2019s "),Nt=s("a"),ar=r("batch_decode()"),nr=r(`. Please refer
to the docstring of this method for more information.`),rr=c(),$e=s("div"),v(ct.$$.fragment),ir=c(),pt=s("p"),lr=r("This method forwards all its arguments to DonutTokenizer\u2019s "),Lt=s("a"),dr=r("decode()"),cr=r(`. Please refer to the
docstring of this method for more information.`),hs=c(),se=s("h2"),je=s("a"),Io=s("span"),v(mt.$$.fragment),pr=c(),Co=s("span"),mr=r("DonutSwinModel"),fs=c(),W=s("div"),v(ut.$$.fragment),ur=c(),ht=s("p"),hr=r(`The bare Donut Swin Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),ft=s("a"),fr=r("torch.nn.Module"),gr=r(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),_r=c(),F=s("div"),v(gt.$$.fragment),vr=c(),ae=s("p"),br=r("The "),Ft=s("a"),wr=r("DonutSwinModel"),Dr=r(" forward method, overrides the "),Ao=s("code"),kr=r("__call__"),xr=r(" special method."),yr=c(),v(Te.$$.fragment),$r=c(),v(ze.$$.fragment),this.h()},l(t){const d=ol('[data-svelte="svelte-1phssyn"]',document.head);h=a(d,"META",{name:!0,content:!0}),d.forEach(o),$=p(t),f=a(t,"H1",{class:!0});var _t=n(f);g=a(_t,"A",{id:!0,class:!0,href:!0});var Mo=n(g);y=a(Mo,"SPAN",{});var Ro=n(y);b(u.$$.fragment,Ro),Ro.forEach(o),Mo.forEach(o),_=p(_t),E=a(_t,"SPAN",{});var No=n(E);I=i(No,"Donut"),No.forEach(o),_t.forEach(o),j=p(t),C=a(t,"H2",{class:!0});var vt=n(C);A=a(vt,"A",{id:!0,class:!0,href:!0});var Er=n(A);Qt=a(Er,"SPAN",{});var Pr=n(Qt);b(Se.$$.fragment,Pr),Pr.forEach(o),Er.forEach(o),Fs=p(vt),Kt=a(vt,"SPAN",{});var qr=n(Kt);Os=i(qr,"Overview"),qr.forEach(o),vt.forEach(o),Fo=p(t),re=a(t,"P",{});var _s=n(re);Vs=i(_s,"The Donut model was proposed in "),Ie=a(_s,"A",{href:!0,rel:!0});var Sr=n(Ie);Us=i(Sr,"OCR-free Document Understanding Transformer"),Sr.forEach(o),Ws=i(_s,` by
Geewook Kim, Teakgyu Hong, Moonbin Yim, Jeongyeon Nam, Jinyoung Park, Jinyeong Yim, Wonseok Hwang, Sangdoo Yun, Dongyoon Han, Seunghyun Park.
Donut consists of an image Transformer encoder and an autoregressive text Transformer decoder to perform document understanding
tasks such as document image classification, form understanding and visual question answering.`),_s.forEach(o),Oo=p(t),bt=a(t,"P",{});var Ir=n(bt);Hs=i(Ir,"The abstract from the paper is the following:"),Ir.forEach(o),Vo=p(t),wt=a(t,"P",{});var Cr=n(wt);Zt=a(Cr,"EM",{});var Ar=n(Zt);Xs=i(Ar,"Understanding document images (e.g., invoices) is a core but challenging task since it requires complex functions such as reading text and a holistic understanding of the document. Current Visual Document Understanding (VDU) methods outsource the task of reading text to off-the-shelf Optical Character Recognition (OCR) engines and focus on the understanding task with the OCR outputs. Although such OCR-based approaches have shown promising performance, they suffer from 1) high computational costs for using OCR; 2) inflexibility of OCR models on languages or types of document; 3) OCR error propagation to the subsequent process. To address these issues, in this paper, we introduce a novel OCR-free VDU model named Donut, which stands for Document understanding transformer. As the first step in OCR-free VDU research, we propose a simple architecture (i.e., Transformer) with a pre-training objective (i.e., cross-entropy loss). Donut is conceptually simple yet effective. Through extensive experiments and analyses, we show a simple OCR-free VDU model, Donut, achieves state-of-the-art performances on various VDU tasks in terms of both speed and accuracy. In addition, we offer a synthetic data generator that helps the model pre-training to be flexible in various languages and domains."),Ar.forEach(o),Cr.forEach(o),Uo=p(t),ie=a(t,"IMG",{src:!0,alt:!0,width:!0}),Wo=p(t),le=a(t,"SMALL",{});var vs=n(le);Bs=i(vs,"Donut high-level overview. Taken from the "),Dt=a(vs,"A",{href:!0});var Mr=n(Dt);Gs=i(Mr,"original paper"),Mr.forEach(o),Js=i(vs,"."),vs.forEach(o),Ho=p(t),H=a(t,"P",{});var Ot=n(H);Ys=i(Ot,"This model was contributed by "),Ce=a(Ot,"A",{href:!0,rel:!0});var Rr=n(Ce);Qs=i(Rr,"nielsr"),Rr.forEach(o),Ks=i(Ot,`. The original code can be found
`),Ae=a(Ot,"A",{href:!0,rel:!0});var Nr=n(Ae);Zs=i(Nr,"here"),Nr.forEach(o),ea=i(Ot,"."),Ot.forEach(o),Xo=p(t),kt=a(t,"P",{});var Lr=n(kt);ta=i(Lr,"Tips:"),Lr.forEach(o),Bo=p(t),de=a(t,"UL",{});var bs=n(de);Me=a(bs,"LI",{});var ws=n(Me);oa=i(ws,"The quickest way to get started with Donut is by checking the "),Re=a(ws,"A",{href:!0,rel:!0});var Fr=n(Re);sa=i(Fr,`tutorial
notebooks`),Fr.forEach(o),aa=i(ws,`, which show how to use the model
at inference time as well as fine-tuning on custom data.`),ws.forEach(o),na=p(bs),Ne=a(bs,"LI",{});var Ds=n(Ne);ra=i(Ds,"Donut is always used within the "),xt=a(Ds,"A",{href:!0});var Or=n(xt);ia=i(Or,"VisionEncoderDecoder"),Or.forEach(o),la=i(Ds," framework."),Ds.forEach(o),bs.forEach(o),Go=p(t),J=a(t,"H2",{class:!0});var ks=n(J);ce=a(ks,"A",{id:!0,class:!0,href:!0});var Vr=n(ce);eo=a(Vr,"SPAN",{});var Ur=n(eo);b(Le.$$.fragment,Ur),Ur.forEach(o),Vr.forEach(o),da=p(ks),to=a(ks,"SPAN",{});var Wr=n(to);ca=i(Wr,"Inference"),Wr.forEach(o),ks.forEach(o),Jo=p(t),X=a(t,"P",{});var Vt=n(X);pa=i(Vt,"Donut\u2019s "),oo=a(Vt,"CODE",{});var Hr=n(oo);ma=i(Hr,"VisionEncoderDecoder"),Hr.forEach(o),ua=i(Vt,` model accepts images as input and makes use of
`),yt=a(Vt,"A",{href:!0});var Xr=n(yt);ha=i(Xr,"generate()"),Xr.forEach(o),fa=i(Vt," to autoregressively generate text given the input image."),Vt.forEach(o),Yo=p(t),z=a(t,"P",{});var q=n(z);ga=i(q,"The "),$t=a(q,"A",{href:!0});var Br=n($t);_a=i(Br,"DonutFeatureExtractor"),Br.forEach(o),va=i(q,` class is responsible for preprocessing the input image and
[`),so=a(q,"CODE",{});var Gr=n(so);ba=i(Gr,"XLMRobertaTokenizer"),Gr.forEach(o),wa=i(q,"/"),ao=a(q,"CODE",{});var Jr=n(ao);Da=i(Jr,"XLMRobertaTokenizerFast"),Jr.forEach(o),ka=i(q,`] decodes the generated target tokens to the target string. The
`),jt=a(q,"A",{href:!0});var Yr=n(jt);xa=i(Yr,"DonutProcessor"),Yr.forEach(o),ya=i(q," wraps "),Tt=a(q,"A",{href:!0});var Qr=n(Tt);$a=i(Qr,"DonutFeatureExtractor"),Qr.forEach(o),ja=i(q," and ["),no=a(q,"CODE",{});var Kr=n(no);Ta=i(Kr,"XLMRobertaTokenizer"),Kr.forEach(o),za=i(q,"/"),ro=a(q,"CODE",{});var Zr=n(ro);Ea=i(Zr,"XLMRobertaTokenizerFast"),Zr.forEach(o),Pa=i(q,`]
into a single instance to both extract the input features and decode the predicted token ids.`),q.forEach(o),Qo=p(t),zt=a(t,"UL",{});var ei=n(zt);io=a(ei,"LI",{});var ti=n(io);qa=i(ti,"Step-by-step Document Image Classification"),ti.forEach(o),ei.forEach(o),Ko=p(t),b(Fe.$$.fragment,t),Zo=p(t),Et=a(t,"UL",{});var oi=n(Et);lo=a(oi,"LI",{});var si=n(lo);Sa=i(si,"Step-by-step Document Parsing"),si.forEach(o),oi.forEach(o),es=p(t),b(Oe.$$.fragment,t),ts=p(t),Pt=a(t,"UL",{});var ai=n(Pt);co=a(ai,"LI",{});var ni=n(co);Ia=i(ni,"Step-by-step Document Visual Question Answering (DocVQA)"),ni.forEach(o),ai.forEach(o),os=p(t),b(Ve.$$.fragment,t),ss=p(t),pe=a(t,"P",{});var xs=n(pe);Ca=i(xs,"See the "),Ue=a(xs,"A",{href:!0,rel:!0});var ri=n(Ue);Aa=i(ri,"model hub"),ri.forEach(o),Ma=i(xs," to look for Donut checkpoints."),xs.forEach(o),as=p(t),Y=a(t,"H2",{class:!0});var ys=n(Y);me=a(ys,"A",{id:!0,class:!0,href:!0});var ii=n(me);po=a(ii,"SPAN",{});var li=n(po);b(We.$$.fragment,li),li.forEach(o),ii.forEach(o),Ra=p(ys),mo=a(ys,"SPAN",{});var di=n(mo);Na=i(di,"Training"),di.forEach(o),ys.forEach(o),ns=p(t),ue=a(t,"P",{});var $s=n(ue);La=i($s,"We refer to the "),He=a($s,"A",{href:!0,rel:!0});var ci=n(He);Fa=i(ci,"tutorial notebooks"),ci.forEach(o),Oa=i($s,"."),$s.forEach(o),rs=p(t),Q=a(t,"H2",{class:!0});var js=n(Q);he=a(js,"A",{id:!0,class:!0,href:!0});var pi=n(he);uo=a(pi,"SPAN",{});var mi=n(uo);b(Xe.$$.fragment,mi),mi.forEach(o),pi.forEach(o),Va=p(js),ho=a(js,"SPAN",{});var ui=n(ho);Ua=i(ui,"DonutSwinConfig"),ui.forEach(o),js.forEach(o),is=p(t),M=a(t,"DIV",{class:!0});var Ee=n(M);b(Be.$$.fragment,Ee),Wa=p(Ee),K=a(Ee,"P",{});var Ut=n(K);Ha=i(Ut,"This is the configuration class to store the configuration of a "),qt=a(Ut,"A",{href:!0});var hi=n(qt);Xa=i(hi,"DonutSwinModel"),hi.forEach(o),Ba=i(Ut,`. It is used to instantiate a
Donut model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a similar configuration to that of the Donut
`),Ge=a(Ut,"A",{href:!0,rel:!0});var fi=n(Ge);Ga=i(fi,"naver-clova-ix/donut-base"),fi.forEach(o),Ja=i(Ut," architecture."),Ut.forEach(o),Ya=p(Ee),Z=a(Ee,"P",{});var Wt=n(Z);Qa=i(Wt,"Configuration objects inherit from "),St=a(Wt,"A",{href:!0});var gi=n(St);Ka=i(gi,"PretrainedConfig"),gi.forEach(o),Za=i(Wt,` and can be used to control the model outputs. Read the
documentation from `),It=a(Wt,"A",{href:!0});var _i=n(It);en=i(_i,"PretrainedConfig"),_i.forEach(o),tn=i(Wt," for more information."),Wt.forEach(o),on=p(Ee),b(fe.$$.fragment,Ee),Ee.forEach(o),ls=p(t),ee=a(t,"H2",{class:!0});var Ts=n(ee);ge=a(Ts,"A",{id:!0,class:!0,href:!0});var vi=n(ge);fo=a(vi,"SPAN",{});var bi=n(fo);b(Je.$$.fragment,bi),bi.forEach(o),vi.forEach(o),sn=p(Ts),go=a(Ts,"SPAN",{});var wi=n(go);an=i(wi,"DonutImageProcessor"),wi.forEach(o),Ts.forEach(o),ds=p(t),O=a(t,"DIV",{class:!0});var Ht=n(O);b(Ye.$$.fragment,Ht),nn=p(Ht),_o=a(Ht,"P",{});var Di=n(_o);rn=i(Di,"Constructs a Donut image processor."),Di.forEach(o),ln=p(Ht),_e=a(Ht,"DIV",{class:!0});var zs=n(_e);b(Qe.$$.fragment,zs),dn=p(zs),vo=a(zs,"P",{});var ki=n(vo);cn=i(ki,"Preprocess an image or batch of images."),ki.forEach(o),zs.forEach(o),Ht.forEach(o),cs=p(t),te=a(t,"H2",{class:!0});var Es=n(te);ve=a(Es,"A",{id:!0,class:!0,href:!0});var xi=n(ve);bo=a(xi,"SPAN",{});var yi=n(bo);b(Ke.$$.fragment,yi),yi.forEach(o),xi.forEach(o),pn=p(Es),wo=a(Es,"SPAN",{});var $i=n(wo);mn=i($i,"DonutFeatureExtractor"),$i.forEach(o),Es.forEach(o),ps=p(t),V=a(t,"DIV",{class:!0});var Xt=n(V);b(Ze.$$.fragment,Xt),un=p(Xt),Do=a(Xt,"P",{});var ji=n(Do);hn=i(ji,"Constructs a Donut image processor."),ji.forEach(o),fn=p(Xt),be=a(Xt,"DIV",{class:!0});var Ps=n(be);b(et.$$.fragment,Ps),gn=p(Ps),ko=a(Ps,"P",{});var Ti=n(ko);_n=i(Ti,"Preprocess an image or a batch of images."),Ti.forEach(o),Ps.forEach(o),Xt.forEach(o),ms=p(t),oe=a(t,"H2",{class:!0});var qs=n(oe);we=a(qs,"A",{id:!0,class:!0,href:!0});var zi=n(we);xo=a(zi,"SPAN",{});var Ei=n(xo);b(tt.$$.fragment,Ei),Ei.forEach(o),zi.forEach(o),vn=p(qs),yo=a(qs,"SPAN",{});var Pi=n(yo);bn=i(Pi,"DonutProcessor"),Pi.forEach(o),qs.forEach(o),us=p(t),T=a(t,"DIV",{class:!0});var S=n(T);b(ot.$$.fragment,S),wn=p(S),$o=a(S,"P",{});var qi=n($o);Dn=i(qi,`Constructs a Donut processor which wraps a Donut feature extractor and an XLMRoBERTa tokenizer into a single
processor.`),qi.forEach(o),kn=p(S),P=a(S,"P",{});var R=n(P);Ct=a(R,"A",{href:!0});var Si=n(Ct);xn=i(Si,"DonutProcessor"),Si.forEach(o),yn=i(R," offers all the functionalities of "),At=a(R,"A",{href:!0});var Ii=n(At);$n=i(Ii,"DonutFeatureExtractor"),Ii.forEach(o),jn=i(R,` and
[`),jo=a(R,"CODE",{});var Ci=n(jo);Tn=i(Ci,"XLMRobertaTokenizer"),Ci.forEach(o),zn=i(R,"/"),To=a(R,"CODE",{});var Ai=n(To);En=i(Ai,"XLMRobertaTokenizerFast"),Ai.forEach(o),Pn=i(R,"]. See the "),st=a(R,"A",{href:!0});var jr=n(st);zo=a(jr,"STRONG",{});var Mi=n(zo);qn=i(Mi,"call"),Mi.forEach(o),Sn=i(jr,"()"),jr.forEach(o),In=i(R,` and
`),Mt=a(R,"A",{href:!0});var Ri=n(Mt);Cn=i(Ri,"decode()"),Ri.forEach(o),An=i(R," for more information."),R.forEach(o),Mn=p(S),De=a(S,"DIV",{class:!0});var Ss=n(De);b(at.$$.fragment,Ss),Rn=p(Ss),U=a(Ss,"P",{});var Pe=n(U);Nn=i(Pe,`When used in normal mode, this method forwards all its arguments to AutoFeatureExtractor\u2019s
`),Eo=a(Pe,"CODE",{});var Ni=n(Eo);Ln=i(Ni,"__call__()"),Ni.forEach(o),Fn=i(Pe,` and returns its output. If used in the context
`),Po=a(Pe,"CODE",{});var Li=n(Po);On=i(Li,"as_target_processor()"),Li.forEach(o),Vn=i(Pe,` this method forwards all its arguments to DonutTokenizer\u2019s
`),qo=a(Pe,"CODE",{});var Fi=n(qo);Un=i(Fi,"~DonutTokenizer.__call__"),Fi.forEach(o),Wn=i(Pe,". Please refer to the doctsring of the above two methods for more information."),Pe.forEach(o),Ss.forEach(o),Hn=p(S),B=a(S,"DIV",{class:!0});var Bt=n(B);b(nt.$$.fragment,Bt),Xn=p(Bt),So=a(Bt,"P",{});var Oi=n(So);Bn=i(Oi,"Instantiate a processor associated with a pretrained model."),Oi.forEach(o),Gn=p(Bt),b(ke.$$.fragment,Bt),Bt.forEach(o),Jn=p(S),G=a(S,"DIV",{class:!0});var Gt=n(G);b(rt.$$.fragment,Gt),Yn=p(Gt),it=a(Gt,"P",{});var Is=n(it);Qn=i(Is,`Saves the attributes of this processor (feature extractor, tokenizer\u2026) in the specified directory so that it
can be reloaded using the `),Rt=a(Is,"A",{href:!0});var Vi=n(Rt);Kn=i(Vi,"from_pretrained()"),Vi.forEach(o),Zn=i(Is," method."),Is.forEach(o),er=p(Gt),b(xe.$$.fragment,Gt),Gt.forEach(o),tr=p(S),ye=a(S,"DIV",{class:!0});var Cs=n(ye);b(lt.$$.fragment,Cs),or=p(Cs),dt=a(Cs,"P",{});var As=n(dt);sr=i(As,"This method forwards all its arguments to DonutTokenizer\u2019s "),Nt=a(As,"A",{href:!0});var Ui=n(Nt);ar=i(Ui,"batch_decode()"),Ui.forEach(o),nr=i(As,`. Please refer
to the docstring of this method for more information.`),As.forEach(o),Cs.forEach(o),rr=p(S),$e=a(S,"DIV",{class:!0});var Ms=n($e);b(ct.$$.fragment,Ms),ir=p(Ms),pt=a(Ms,"P",{});var Rs=n(pt);lr=i(Rs,"This method forwards all its arguments to DonutTokenizer\u2019s "),Lt=a(Rs,"A",{href:!0});var Wi=n(Lt);dr=i(Wi,"decode()"),Wi.forEach(o),cr=i(Rs,`. Please refer to the
docstring of this method for more information.`),Rs.forEach(o),Ms.forEach(o),S.forEach(o),hs=p(t),se=a(t,"H2",{class:!0});var Ns=n(se);je=a(Ns,"A",{id:!0,class:!0,href:!0});var Hi=n(je);Io=a(Hi,"SPAN",{});var Xi=n(Io);b(mt.$$.fragment,Xi),Xi.forEach(o),Hi.forEach(o),pr=p(Ns),Co=a(Ns,"SPAN",{});var Bi=n(Co);mr=i(Bi,"DonutSwinModel"),Bi.forEach(o),Ns.forEach(o),fs=p(t),W=a(t,"DIV",{class:!0});var Jt=n(W);b(ut.$$.fragment,Jt),ur=p(Jt),ht=a(Jt,"P",{});var Ls=n(ht);hr=i(Ls,`The bare Donut Swin Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),ft=a(Ls,"A",{href:!0,rel:!0});var Gi=n(ft);fr=i(Gi,"torch.nn.Module"),Gi.forEach(o),gr=i(Ls,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Ls.forEach(o),_r=p(Jt),F=a(Jt,"DIV",{class:!0});var qe=n(F);b(gt.$$.fragment,qe),vr=p(qe),ae=a(qe,"P",{});var Yt=n(ae);br=i(Yt,"The "),Ft=a(Yt,"A",{href:!0});var Ji=n(Ft);wr=i(Ji,"DonutSwinModel"),Ji.forEach(o),Dr=i(Yt," forward method, overrides the "),Ao=a(Yt,"CODE",{});var Yi=n(Ao);kr=i(Yi,"__call__"),Yi.forEach(o),xr=i(Yt," special method."),Yt.forEach(o),yr=p(qe),b(Te.$$.fragment,qe),$r=p(qe),b(ze.$$.fragment,qe),qe.forEach(o),Jt.forEach(o),this.h()},h(){l(h,"name","hf:doc:metadata"),l(h,"content",JSON.stringify(pl)),l(g,"id","donut"),l(g,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(g,"href","#donut"),l(f,"class","relative group"),l(A,"id","overview"),l(A,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(A,"href","#overview"),l(C,"class","relative group"),l(Ie,"href","https://arxiv.org/abs/2111.15664"),l(Ie,"rel","nofollow"),sl(ie.src,zr="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/donut_architecture.jpg")||l(ie,"src",zr),l(ie,"alt","drawing"),l(ie,"width","600"),l(Dt,"href","https://arxiv.org/abs/2111.15664"),l(Ce,"href","https://huggingface.co/nielsr"),l(Ce,"rel","nofollow"),l(Ae,"href","https://github.com/clovaai/donut"),l(Ae,"rel","nofollow"),l(Re,"href","https://github.com/NielsRogge/Transformers-Tutorials/tree/master/Donut"),l(Re,"rel","nofollow"),l(xt,"href","vision-encoder-decoder"),l(ce,"id","inference"),l(ce,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(ce,"href","#inference"),l(J,"class","relative group"),l(yt,"href","/docs/transformers/v4.25.1/en/main_classes/text_generation#transformers.GenerationMixin.generate"),l($t,"href","/docs/transformers/v4.25.1/en/model_doc/donut#transformers.DonutImageProcessor"),l(jt,"href","/docs/transformers/v4.25.1/en/model_doc/donut#transformers.DonutProcessor"),l(Tt,"href","/docs/transformers/v4.25.1/en/model_doc/donut#transformers.DonutImageProcessor"),l(Ue,"href","https://huggingface.co/models?filter=donut"),l(Ue,"rel","nofollow"),l(me,"id","training"),l(me,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(me,"href","#training"),l(Y,"class","relative group"),l(He,"href","https://github.com/NielsRogge/Transformers-Tutorials/tree/master/Donut"),l(He,"rel","nofollow"),l(he,"id","transformers.DonutSwinConfig"),l(he,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(he,"href","#transformers.DonutSwinConfig"),l(Q,"class","relative group"),l(qt,"href","/docs/transformers/v4.25.1/en/model_doc/donut#transformers.DonutSwinModel"),l(Ge,"href","https://huggingface.co/naver-clova-ix/donut-base"),l(Ge,"rel","nofollow"),l(St,"href","/docs/transformers/v4.25.1/en/main_classes/configuration#transformers.PretrainedConfig"),l(It,"href","/docs/transformers/v4.25.1/en/main_classes/configuration#transformers.PretrainedConfig"),l(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ge,"id","transformers.DonutImageProcessor"),l(ge,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(ge,"href","#transformers.DonutImageProcessor"),l(ee,"class","relative group"),l(_e,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ve,"id","transformers.DonutImageProcessor"),l(ve,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(ve,"href","#transformers.DonutImageProcessor"),l(te,"class","relative group"),l(be,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(we,"id","transformers.DonutProcessor"),l(we,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(we,"href","#transformers.DonutProcessor"),l(oe,"class","relative group"),l(Ct,"href","/docs/transformers/v4.25.1/en/model_doc/donut#transformers.DonutProcessor"),l(At,"href","/docs/transformers/v4.25.1/en/model_doc/donut#transformers.DonutImageProcessor"),l(st,"href","/docs/transformers/v4.25.1/en/model_doc/donut#transformers.DonutProcessor.__call__"),l(Mt,"href","/docs/transformers/v4.25.1/en/model_doc/donut#transformers.DonutProcessor.decode"),l(De,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(Rt,"href","/docs/transformers/v4.25.1/en/model_doc/donut#transformers.DonutProcessor.from_pretrained"),l(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(Nt,"href","/docs/transformers/v4.25.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.batch_decode"),l(ye,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(Lt,"href","/docs/transformers/v4.25.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.decode"),l($e,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(je,"id","transformers.DonutSwinModel"),l(je,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(je,"href","#transformers.DonutSwinModel"),l(se,"class","relative group"),l(ft,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(ft,"rel","nofollow"),l(Ft,"href","/docs/transformers/v4.25.1/en/model_doc/donut#transformers.DonutSwinModel"),l(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,d){e(document.head,h),m(t,$,d),m(t,f,d),e(f,g),e(g,y),w(u,y,null),e(f,_),e(f,E),e(E,I),m(t,j,d),m(t,C,d),e(C,A),e(A,Qt),w(Se,Qt,null),e(C,Fs),e(C,Kt),e(Kt,Os),m(t,Fo,d),m(t,re,d),e(re,Vs),e(re,Ie),e(Ie,Us),e(re,Ws),m(t,Oo,d),m(t,bt,d),e(bt,Hs),m(t,Vo,d),m(t,wt,d),e(wt,Zt),e(Zt,Xs),m(t,Uo,d),m(t,ie,d),m(t,Wo,d),m(t,le,d),e(le,Bs),e(le,Dt),e(Dt,Gs),e(le,Js),m(t,Ho,d),m(t,H,d),e(H,Ys),e(H,Ce),e(Ce,Qs),e(H,Ks),e(H,Ae),e(Ae,Zs),e(H,ea),m(t,Xo,d),m(t,kt,d),e(kt,ta),m(t,Bo,d),m(t,de,d),e(de,Me),e(Me,oa),e(Me,Re),e(Re,sa),e(Me,aa),e(de,na),e(de,Ne),e(Ne,ra),e(Ne,xt),e(xt,ia),e(Ne,la),m(t,Go,d),m(t,J,d),e(J,ce),e(ce,eo),w(Le,eo,null),e(J,da),e(J,to),e(to,ca),m(t,Jo,d),m(t,X,d),e(X,pa),e(X,oo),e(oo,ma),e(X,ua),e(X,yt),e(yt,ha),e(X,fa),m(t,Yo,d),m(t,z,d),e(z,ga),e(z,$t),e($t,_a),e(z,va),e(z,so),e(so,ba),e(z,wa),e(z,ao),e(ao,Da),e(z,ka),e(z,jt),e(jt,xa),e(z,ya),e(z,Tt),e(Tt,$a),e(z,ja),e(z,no),e(no,Ta),e(z,za),e(z,ro),e(ro,Ea),e(z,Pa),m(t,Qo,d),m(t,zt,d),e(zt,io),e(io,qa),m(t,Ko,d),w(Fe,t,d),m(t,Zo,d),m(t,Et,d),e(Et,lo),e(lo,Sa),m(t,es,d),w(Oe,t,d),m(t,ts,d),m(t,Pt,d),e(Pt,co),e(co,Ia),m(t,os,d),w(Ve,t,d),m(t,ss,d),m(t,pe,d),e(pe,Ca),e(pe,Ue),e(Ue,Aa),e(pe,Ma),m(t,as,d),m(t,Y,d),e(Y,me),e(me,po),w(We,po,null),e(Y,Ra),e(Y,mo),e(mo,Na),m(t,ns,d),m(t,ue,d),e(ue,La),e(ue,He),e(He,Fa),e(ue,Oa),m(t,rs,d),m(t,Q,d),e(Q,he),e(he,uo),w(Xe,uo,null),e(Q,Va),e(Q,ho),e(ho,Ua),m(t,is,d),m(t,M,d),w(Be,M,null),e(M,Wa),e(M,K),e(K,Ha),e(K,qt),e(qt,Xa),e(K,Ba),e(K,Ge),e(Ge,Ga),e(K,Ja),e(M,Ya),e(M,Z),e(Z,Qa),e(Z,St),e(St,Ka),e(Z,Za),e(Z,It),e(It,en),e(Z,tn),e(M,on),w(fe,M,null),m(t,ls,d),m(t,ee,d),e(ee,ge),e(ge,fo),w(Je,fo,null),e(ee,sn),e(ee,go),e(go,an),m(t,ds,d),m(t,O,d),w(Ye,O,null),e(O,nn),e(O,_o),e(_o,rn),e(O,ln),e(O,_e),w(Qe,_e,null),e(_e,dn),e(_e,vo),e(vo,cn),m(t,cs,d),m(t,te,d),e(te,ve),e(ve,bo),w(Ke,bo,null),e(te,pn),e(te,wo),e(wo,mn),m(t,ps,d),m(t,V,d),w(Ze,V,null),e(V,un),e(V,Do),e(Do,hn),e(V,fn),e(V,be),w(et,be,null),e(be,gn),e(be,ko),e(ko,_n),m(t,ms,d),m(t,oe,d),e(oe,we),e(we,xo),w(tt,xo,null),e(oe,vn),e(oe,yo),e(yo,bn),m(t,us,d),m(t,T,d),w(ot,T,null),e(T,wn),e(T,$o),e($o,Dn),e(T,kn),e(T,P),e(P,Ct),e(Ct,xn),e(P,yn),e(P,At),e(At,$n),e(P,jn),e(P,jo),e(jo,Tn),e(P,zn),e(P,To),e(To,En),e(P,Pn),e(P,st),e(st,zo),e(zo,qn),e(st,Sn),e(P,In),e(P,Mt),e(Mt,Cn),e(P,An),e(T,Mn),e(T,De),w(at,De,null),e(De,Rn),e(De,U),e(U,Nn),e(U,Eo),e(Eo,Ln),e(U,Fn),e(U,Po),e(Po,On),e(U,Vn),e(U,qo),e(qo,Un),e(U,Wn),e(T,Hn),e(T,B),w(nt,B,null),e(B,Xn),e(B,So),e(So,Bn),e(B,Gn),w(ke,B,null),e(T,Jn),e(T,G),w(rt,G,null),e(G,Yn),e(G,it),e(it,Qn),e(it,Rt),e(Rt,Kn),e(it,Zn),e(G,er),w(xe,G,null),e(T,tr),e(T,ye),w(lt,ye,null),e(ye,or),e(ye,dt),e(dt,sr),e(dt,Nt),e(Nt,ar),e(dt,nr),e(T,rr),e(T,$e),w(ct,$e,null),e($e,ir),e($e,pt),e(pt,lr),e(pt,Lt),e(Lt,dr),e(pt,cr),m(t,hs,d),m(t,se,d),e(se,je),e(je,Io),w(mt,Io,null),e(se,pr),e(se,Co),e(Co,mr),m(t,fs,d),m(t,W,d),w(ut,W,null),e(W,ur),e(W,ht),e(ht,hr),e(ht,ft),e(ft,fr),e(ht,gr),e(W,_r),e(W,F),w(gt,F,null),e(F,vr),e(F,ae),e(ae,br),e(ae,Ft),e(Ft,wr),e(ae,Dr),e(ae,Ao),e(Ao,kr),e(ae,xr),e(F,yr),w(Te,F,null),e(F,$r),w(ze,F,null),gs=!0},p(t,[d]){const _t={};d&2&&(_t.$$scope={dirty:d,ctx:t}),fe.$set(_t);const Mo={};d&2&&(Mo.$$scope={dirty:d,ctx:t}),ke.$set(Mo);const Ro={};d&2&&(Ro.$$scope={dirty:d,ctx:t}),xe.$set(Ro);const No={};d&2&&(No.$$scope={dirty:d,ctx:t}),Te.$set(No);const vt={};d&2&&(vt.$$scope={dirty:d,ctx:t}),ze.$set(vt)},i(t){gs||(D(u.$$.fragment,t),D(Se.$$.fragment,t),D(Le.$$.fragment,t),D(Fe.$$.fragment,t),D(Oe.$$.fragment,t),D(Ve.$$.fragment,t),D(We.$$.fragment,t),D(Xe.$$.fragment,t),D(Be.$$.fragment,t),D(fe.$$.fragment,t),D(Je.$$.fragment,t),D(Ye.$$.fragment,t),D(Qe.$$.fragment,t),D(Ke.$$.fragment,t),D(Ze.$$.fragment,t),D(et.$$.fragment,t),D(tt.$$.fragment,t),D(ot.$$.fragment,t),D(at.$$.fragment,t),D(nt.$$.fragment,t),D(ke.$$.fragment,t),D(rt.$$.fragment,t),D(xe.$$.fragment,t),D(lt.$$.fragment,t),D(ct.$$.fragment,t),D(mt.$$.fragment,t),D(ut.$$.fragment,t),D(gt.$$.fragment,t),D(Te.$$.fragment,t),D(ze.$$.fragment,t),gs=!0)},o(t){k(u.$$.fragment,t),k(Se.$$.fragment,t),k(Le.$$.fragment,t),k(Fe.$$.fragment,t),k(Oe.$$.fragment,t),k(Ve.$$.fragment,t),k(We.$$.fragment,t),k(Xe.$$.fragment,t),k(Be.$$.fragment,t),k(fe.$$.fragment,t),k(Je.$$.fragment,t),k(Ye.$$.fragment,t),k(Qe.$$.fragment,t),k(Ke.$$.fragment,t),k(Ze.$$.fragment,t),k(et.$$.fragment,t),k(tt.$$.fragment,t),k(ot.$$.fragment,t),k(at.$$.fragment,t),k(nt.$$.fragment,t),k(ke.$$.fragment,t),k(rt.$$.fragment,t),k(xe.$$.fragment,t),k(lt.$$.fragment,t),k(ct.$$.fragment,t),k(mt.$$.fragment,t),k(ut.$$.fragment,t),k(gt.$$.fragment,t),k(Te.$$.fragment,t),k(ze.$$.fragment,t),gs=!1},d(t){o(h),t&&o($),t&&o(f),x(u),t&&o(j),t&&o(C),x(Se),t&&o(Fo),t&&o(re),t&&o(Oo),t&&o(bt),t&&o(Vo),t&&o(wt),t&&o(Uo),t&&o(ie),t&&o(Wo),t&&o(le),t&&o(Ho),t&&o(H),t&&o(Xo),t&&o(kt),t&&o(Bo),t&&o(de),t&&o(Go),t&&o(J),x(Le),t&&o(Jo),t&&o(X),t&&o(Yo),t&&o(z),t&&o(Qo),t&&o(zt),t&&o(Ko),x(Fe,t),t&&o(Zo),t&&o(Et),t&&o(es),x(Oe,t),t&&o(ts),t&&o(Pt),t&&o(os),x(Ve,t),t&&o(ss),t&&o(pe),t&&o(as),t&&o(Y),x(We),t&&o(ns),t&&o(ue),t&&o(rs),t&&o(Q),x(Xe),t&&o(is),t&&o(M),x(Be),x(fe),t&&o(ls),t&&o(ee),x(Je),t&&o(ds),t&&o(O),x(Ye),x(Qe),t&&o(cs),t&&o(te),x(Ke),t&&o(ps),t&&o(V),x(Ze),x(et),t&&o(ms),t&&o(oe),x(tt),t&&o(us),t&&o(T),x(ot),x(at),x(nt),x(ke),x(rt),x(xe),x(lt),x(ct),t&&o(hs),t&&o(se),x(mt),t&&o(fs),t&&o(W),x(ut),x(gt),x(Te),x(ze)}}}const pl={local:"donut",sections:[{local:"overview",title:"Overview"},{local:"inference",title:"Inference"},{local:"training",title:"Training"},{local:"transformers.DonutSwinConfig",title:"DonutSwinConfig"},{local:"transformers.DonutImageProcessor",title:"DonutImageProcessor"},{local:"transformers.DonutImageProcessor",title:"DonutFeatureExtractor"},{local:"transformers.DonutProcessor",title:"DonutProcessor"},{local:"transformers.DonutSwinModel",title:"DonutSwinModel"}],title:"Donut"};function ml(L){return al(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class bl extends Zi{constructor(h){super();el(this,h,ml,cl,tl,{})}}export{bl as default,pl as metadata};
