import{S as Gi,i as Yi,s as Qi,e as o,k as c,w as v,t as r,M as Ki,c as a,d as s,m as p,a as n,x as b,h as i,b as l,N as Zi,G as e,g as m,y as w,q as k,o as D,B as x,v as el,L as Ji}from"../../chunks/vendor-hf-doc-builder.js";import{T as $r}from"../../chunks/Tip-hf-doc-builder.js";import{D as L}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Rs}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as ie}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Bi}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function tl(N){let h,j,g,f,$;return f=new Rs({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=o("p"),j=r("Example:"),g=c(),v(f.$$.fragment)},l(u){h=a(u,"P",{});var _=n(h);j=i(_,"Example:"),_.forEach(s),g=p(u),b(f.$$.fragment,u)},m(u,_){m(u,h,_),e(h,j),m(u,g,_),w(f,u,_),$=!0},p:Ji,i(u){$||(k(f.$$.fragment,u),$=!0)},o(u){D(f.$$.fragment,u),$=!1},d(u){u&&s(h),u&&s(g),x(f,u)}}}function sl(N){let h,j,g,f,$,u,_,q,A,E,z;return{c(){h=o("p"),j=r(`This class method is simply calling the feature extractor
`),g=o("a"),f=r("from_pretrained()"),$=r(`, image processor
`),u=o("a"),_=r("ImageProcessingMixin"),q=r(` and the tokenizer
`),A=o("code"),E=r("~tokenization_utils_base.PreTrainedTokenizer.from_pretrained"),z=r(` methods. Please refer to the docstrings of the
methods above for more information.`),this.h()},l(P){h=a(P,"P",{});var S=n(h);j=i(S,`This class method is simply calling the feature extractor
`),g=a(S,"A",{href:!0});var H=n(g);f=i(H,"from_pretrained()"),H.forEach(s),$=i(S,`, image processor
`),u=a(S,"A",{href:!0});var kt=n(u);_=i(kt,"ImageProcessingMixin"),kt.forEach(s),q=i(S,` and the tokenizer
`),A=a(S,"CODE",{});var le=n(A);E=i(le,"~tokenization_utils_base.PreTrainedTokenizer.from_pretrained"),le.forEach(s),z=i(S,` methods. Please refer to the docstrings of the
methods above for more information.`),S.forEach(s),this.h()},h(){l(g,"href","/docs/transformers/v4.29.0/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin.from_pretrained"),l(u,"href","/docs/transformers/v4.29.0/en/main_classes/image_processor#transformers.ImageProcessingMixin")},m(P,S){m(P,h,S),e(h,j),e(h,g),e(g,f),e(h,$),e(h,u),e(u,_),e(h,q),e(h,A),e(A,E),e(h,z)},d(P){P&&s(h)}}}function ol(N){let h,j,g,f,$,u,_,q;return{c(){h=o("p"),j=r("This class method is simply calling "),g=o("a"),f=r("save_pretrained()"),$=r(` and
`),u=o("a"),_=r("save_pretrained()"),q=r(`. Please refer to the docstrings of the
methods above for more information.`),this.h()},l(A){h=a(A,"P",{});var E=n(h);j=i(E,"This class method is simply calling "),g=a(E,"A",{href:!0});var z=n(g);f=i(z,"save_pretrained()"),z.forEach(s),$=i(E,` and
`),u=a(E,"A",{href:!0});var P=n(u);_=i(P,"save_pretrained()"),P.forEach(s),q=i(E,`. Please refer to the docstrings of the
methods above for more information.`),E.forEach(s),this.h()},h(){l(g,"href","/docs/transformers/v4.29.0/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin.save_pretrained"),l(u,"href","/docs/transformers/v4.29.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.save_pretrained")},m(A,E){m(A,h,E),e(h,j),e(h,g),e(g,f),e(h,$),e(h,u),e(u,_),e(h,q)},d(A){A&&s(h)}}}function al(N){let h,j,g,f,$;return{c(){h=o("p"),j=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=o("code"),f=r("Module"),$=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);j=i(_,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=a(_,"CODE",{});var q=n(g);f=i(q,"Module"),q.forEach(s),$=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(s)},m(u,_){m(u,h,_),e(h,j),e(h,g),e(g,f),e(h,$)},d(u){u&&s(h)}}}function nl(N){let h,j,g,f,$;return f=new Rs({props:{code:`from transformers import AutoImageProcessor, DonutSwinModel
import torch
from datasets import load_dataset

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

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

inputs = image_processor(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> AutoImageProcessor, 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>image_processor = AutoImageProcessor.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 = image_processor(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=o("p"),j=r("Example:"),g=c(),v(f.$$.fragment)},l(u){h=a(u,"P",{});var _=n(h);j=i(_,"Example:"),_.forEach(s),g=p(u),b(f.$$.fragment,u)},m(u,_){m(u,h,_),e(h,j),m(u,g,_),w(f,u,_),$=!0},p:Ji,i(u){$||(k(f.$$.fragment,u),$=!0)},o(u){D(f.$$.fragment,u),$=!1},d(u){u&&s(h),u&&s(g),x(f,u)}}}function rl(N){let h,j,g,f,$,u,_,q,A,E,z,P,S,H,kt,le,No,Fs,de,Oo,Me,Vo,Uo,Ls,Dt,Wo,Ns,xt,Zt,Ho,Os,ce,jr,Vs,pe,Xo,$t,Bo,Jo,Us,X,Go,Ae,Yo,Qo,Re,Ko,Zo,Ws,jt,ea,Hs,me,Fe,ta,Le,sa,oa,aa,Ne,na,yt,ra,ia,Xs,Y,ue,es,Oe,la,ts,da,Bs,B,ca,ss,pa,ma,Tt,ua,ha,Js,T,ga,Et,fa,_a,os,va,ba,as,wa,ka,Pt,Da,xa,qt,$a,ja,ns,ya,Ta,rs,Ea,Pa,Gs,zt,is,qa,Ys,Ve,Qs,St,ls,za,Ks,Ue,Zs,It,ds,Sa,eo,We,to,he,Ia,He,Ca,Ma,so,Q,ge,cs,Xe,Aa,ps,Ra,oo,fe,Fa,Be,La,Na,ao,K,_e,ms,Je,Oa,us,Va,no,R,Ge,Ua,Z,Wa,Ct,Ha,Xa,Ye,Ba,Ja,Ga,ee,Ya,Mt,Qa,Ka,At,Za,en,tn,ve,ro,te,be,hs,Qe,sn,gs,on,io,V,Ke,an,fs,nn,rn,we,Ze,ln,_s,dn,lo,se,ke,vs,et,cn,bs,pn,co,oe,tt,mn,De,st,un,ws,hn,po,ae,xe,ks,ot,gn,Ds,fn,mo,y,at,_n,xs,vn,bn,I,Rt,wn,kn,Ft,Dn,xn,$s,$n,jn,js,yn,Tn,nt,ys,En,Pn,qn,Lt,zn,Sn,In,$e,rt,Cn,U,Mn,Ts,An,Rn,Es,Fn,Ln,Ps,Nn,On,Vn,J,it,Un,qs,Wn,Hn,je,Xn,G,lt,Bn,dt,Jn,Nt,Gn,Yn,Qn,ye,Kn,Te,ct,Zn,pt,er,Ot,tr,sr,or,Ee,mt,ar,ut,nr,Vt,rr,ir,uo,ne,Pe,zs,ht,lr,Ss,dr,ho,W,gt,cr,ft,pr,_t,mr,ur,hr,O,vt,gr,re,fr,Ut,_r,vr,Is,br,wr,kr,qe,Dr,ze,go;return u=new ie({}),H=new ie({}),Oe=new ie({}),Ve=new Rs({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>}`}}),Ue=new Rs({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>}}`}}),We=new Rs({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>}`}}),Xe=new ie({}),Je=new ie({}),Ge=new L({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:"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.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.29.0/src/transformers/models/donut/configuration_donut_swin.py#L29"}}),ve=new Bi({props:{anchor:"transformers.DonutSwinConfig.example",$$slots:{default:[tl]},$$scope:{ctx:N}}}),Qe=new ie({}),Ke=new L({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_thumbnail",description:`<strong>do_thumbnail</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to resize the image using thumbnail method.`,name:"do_thumbnail"},{anchor:"transformers.DonutImageProcessor.do_align_long_axis",description:`<strong>do_align_long_axis</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</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.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to pad the image. If <code>random_padding</code> is set to <code>True</code> in <code>preprocess</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.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"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/donut/image_processing_donut.py#L52"}}),Ze=new L({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.29.0/src/transformers/models/donut/image_processing_donut.py#L315"}}),et=new ie({}),tt=new L({props:{name:"class transformers.DonutFeatureExtractor",anchor:"transformers.DonutFeatureExtractor",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/donut/feature_extraction_donut.py#L26"}}),st=new L({props:{name:"__call__",anchor:"transformers.DonutFeatureExtractor.__call__",parameters:[{name:"images",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/image_processing_utils.py#L462"}}),ot=new ie({}),at=new L({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.image_processor",description:`<strong>image_processor</strong> (<a href="/docs/transformers/v4.29.0/en/model_doc/donut#transformers.DonutImageProcessor">DonutImageProcessor</a>) &#x2014;
An instance of <a href="/docs/transformers/v4.29.0/en/model_doc/donut#transformers.DonutImageProcessor">DonutImageProcessor</a>. The image processor is a required input.`,name:"image_processor"},{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.29.0/src/transformers/models/donut/processing_donut.py#L25"}}),rt=new L({props:{name:"__call__",anchor:"transformers.DonutProcessor.__call__",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/donut/processing_donut.py#L63"}}),it=new L({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.29.0/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.29.0/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.29.0/src/transformers/processing_utils.py#L153"}}),je=new $r({props:{$$slots:{default:[sl]},$$scope:{ctx:N}}}),lt=new L({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.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.push_to_hub">push_to_hub()</a> method.`,name:"push_to_hub"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/processing_utils.py#L91"}}),ye=new $r({props:{$$slots:{default:[ol]},$$scope:{ctx:N}}}),ct=new L({props:{name:"batch_decode",anchor:"transformers.DonutProcessor.batch_decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/donut/processing_donut.py#L96"}}),mt=new L({props:{name:"decode",anchor:"transformers.DonutProcessor.decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/donut/processing_donut.py#L103"}}),ht=new ie({}),gt=new L({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.29.0/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.29.0/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.29.0/src/transformers/models/donut/modeling_donut_swin.py#L871"}}),vt=new L({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.29.0/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<a href="/docs/transformers/v4.29.0/en/model_doc/dpt#transformers.DPTFeatureExtractor.__call__">DonutImageProcessor.<strong>call</strong>()</a> 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.29.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.DonutSwinModel.forward.bool_masked_pos",description:`<strong>bool_masked_pos</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, num_patches)</code>) &#x2014;
Boolean masked positions. Indicates which patches are masked (1) and which aren&#x2019;t (0).`,name:"bool_masked_pos"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/donut/modeling_donut_swin.py#L897",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.29.0/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>
`}}),qe=new $r({props:{$$slots:{default:[al]},$$scope:{ctx:N}}}),ze=new Bi({props:{anchor:"transformers.DonutSwinModel.forward.example",$$slots:{default:[nl]},$$scope:{ctx:N}}}),{c(){h=o("meta"),j=c(),g=o("h1"),f=o("a"),$=o("span"),v(u.$$.fragment),_=c(),q=o("span"),A=r("Donut"),E=c(),z=o("h2"),P=o("a"),S=o("span"),v(H.$$.fragment),kt=c(),le=o("span"),No=r("Overview"),Fs=c(),de=o("p"),Oo=r("The Donut model was proposed in "),Me=o("a"),Vo=r("OCR-free Document Understanding Transformer"),Uo=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.`),Ls=c(),Dt=o("p"),Wo=r("The abstract from the paper is the following:"),Ns=c(),xt=o("p"),Zt=o("em"),Ho=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."),Os=c(),ce=o("img"),Vs=c(),pe=o("small"),Xo=r("Donut high-level overview. Taken from the "),$t=o("a"),Bo=r("original paper"),Jo=r("."),Us=c(),X=o("p"),Go=r("This model was contributed by "),Ae=o("a"),Yo=r("nielsr"),Qo=r(`. The original code can be found
`),Re=o("a"),Ko=r("here"),Zo=r("."),Ws=c(),jt=o("p"),ea=r("Tips:"),Hs=c(),me=o("ul"),Fe=o("li"),ta=r("The quickest way to get started with Donut is by checking the "),Le=o("a"),sa=r(`tutorial
notebooks`),oa=r(`, which show how to use the model
at inference time as well as fine-tuning on custom data.`),aa=c(),Ne=o("li"),na=r("Donut is always used within the "),yt=o("a"),ra=r("VisionEncoderDecoder"),ia=r(" framework."),Xs=c(),Y=o("h2"),ue=o("a"),es=o("span"),v(Oe.$$.fragment),la=c(),ts=o("span"),da=r("Inference"),Bs=c(),B=o("p"),ca=r("Donut\u2019s "),ss=o("code"),pa=r("VisionEncoderDecoder"),ma=r(` model accepts images as input and makes use of
`),Tt=o("a"),ua=r("generate()"),ha=r(" to autoregressively generate text given the input image."),Js=c(),T=o("p"),ga=r("The "),Et=o("a"),fa=r("DonutFeatureExtractor"),_a=r(` class is responsible for preprocessing the input image and
[`),os=o("code"),va=r("XLMRobertaTokenizer"),ba=r("/"),as=o("code"),wa=r("XLMRobertaTokenizerFast"),ka=r(`] decodes the generated target tokens to the target string. The
`),Pt=o("a"),Da=r("DonutProcessor"),xa=r(" wraps "),qt=o("a"),$a=r("DonutFeatureExtractor"),ja=r(" and ["),ns=o("code"),ya=r("XLMRobertaTokenizer"),Ta=r("/"),rs=o("code"),Ea=r("XLMRobertaTokenizerFast"),Pa=r(`]
into a single instance to both extract the input features and decode the predicted token ids.`),Gs=c(),zt=o("ul"),is=o("li"),qa=r("Step-by-step Document Image Classification"),Ys=c(),v(Ve.$$.fragment),Qs=c(),St=o("ul"),ls=o("li"),za=r("Step-by-step Document Parsing"),Ks=c(),v(Ue.$$.fragment),Zs=c(),It=o("ul"),ds=o("li"),Sa=r("Step-by-step Document Visual Question Answering (DocVQA)"),eo=c(),v(We.$$.fragment),to=c(),he=o("p"),Ia=r("See the "),He=o("a"),Ca=r("model hub"),Ma=r(" to look for Donut checkpoints."),so=c(),Q=o("h2"),ge=o("a"),cs=o("span"),v(Xe.$$.fragment),Aa=c(),ps=o("span"),Ra=r("Training"),oo=c(),fe=o("p"),Fa=r("We refer to the "),Be=o("a"),La=r("tutorial notebooks"),Na=r("."),ao=c(),K=o("h2"),_e=o("a"),ms=o("span"),v(Je.$$.fragment),Oa=c(),us=o("span"),Va=r("DonutSwinConfig"),no=c(),R=o("div"),v(Ge.$$.fragment),Ua=c(),Z=o("p"),Wa=r("This is the configuration class to store the configuration of a "),Ct=o("a"),Ha=r("DonutSwinModel"),Xa=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
`),Ye=o("a"),Ba=r("naver-clova-ix/donut-base"),Ja=r(" architecture."),Ga=c(),ee=o("p"),Ya=r("Configuration objects inherit from "),Mt=o("a"),Qa=r("PretrainedConfig"),Ka=r(` and can be used to control the model outputs. Read the
documentation from `),At=o("a"),Za=r("PretrainedConfig"),en=r(" for more information."),tn=c(),v(ve.$$.fragment),ro=c(),te=o("h2"),be=o("a"),hs=o("span"),v(Qe.$$.fragment),sn=c(),gs=o("span"),on=r("DonutImageProcessor"),io=c(),V=o("div"),v(Ke.$$.fragment),an=c(),fs=o("p"),nn=r("Constructs a Donut image processor."),rn=c(),we=o("div"),v(Ze.$$.fragment),ln=c(),_s=o("p"),dn=r("Preprocess an image or batch of images."),lo=c(),se=o("h2"),ke=o("a"),vs=o("span"),v(et.$$.fragment),cn=c(),bs=o("span"),pn=r("DonutFeatureExtractor"),co=c(),oe=o("div"),v(tt.$$.fragment),mn=c(),De=o("div"),v(st.$$.fragment),un=c(),ws=o("p"),hn=r("Preprocess an image or a batch of images."),po=c(),ae=o("h2"),xe=o("a"),ks=o("span"),v(ot.$$.fragment),gn=c(),Ds=o("span"),fn=r("DonutProcessor"),mo=c(),y=o("div"),v(at.$$.fragment),_n=c(),xs=o("p"),vn=r(`Constructs a Donut processor which wraps a Donut image processor and an XLMRoBERTa tokenizer into a single
processor.`),bn=c(),I=o("p"),Rt=o("a"),wn=r("DonutProcessor"),kn=r(" offers all the functionalities of "),Ft=o("a"),Dn=r("DonutImageProcessor"),xn=r(` and
[`),$s=o("code"),$n=r("XLMRobertaTokenizer"),jn=r("/"),js=o("code"),yn=r("XLMRobertaTokenizerFast"),Tn=r("]. See the "),nt=o("a"),ys=o("strong"),En=r("call"),Pn=r("()"),qn=r(` and
`),Lt=o("a"),zn=r("decode()"),Sn=r(" for more information."),In=c(),$e=o("div"),v(rt.$$.fragment),Cn=c(),U=o("p"),Mn=r(`When used in normal mode, this method forwards all its arguments to AutoImageProcessor\u2019s
`),Ts=o("code"),An=r("__call__()"),Rn=r(` and returns its output. If used in the context
`),Es=o("code"),Fn=r("as_target_processor()"),Ln=r(` this method forwards all its arguments to DonutTokenizer\u2019s
`),Ps=o("code"),Nn=r("~DonutTokenizer.__call__"),On=r(". Please refer to the doctsring of the above two methods for more information."),Vn=c(),J=o("div"),v(it.$$.fragment),Un=c(),qs=o("p"),Wn=r("Instantiate a processor associated with a pretrained model."),Hn=c(),v(je.$$.fragment),Xn=c(),G=o("div"),v(lt.$$.fragment),Bn=c(),dt=o("p"),Jn=r(`Saves the attributes of this processor (feature extractor, tokenizer\u2026) in the specified directory so that it
can be reloaded using the `),Nt=o("a"),Gn=r("from_pretrained()"),Yn=r(" method."),Qn=c(),v(ye.$$.fragment),Kn=c(),Te=o("div"),v(ct.$$.fragment),Zn=c(),pt=o("p"),er=r("This method forwards all its arguments to DonutTokenizer\u2019s "),Ot=o("a"),tr=r("batch_decode()"),sr=r(`. Please refer
to the docstring of this method for more information.`),or=c(),Ee=o("div"),v(mt.$$.fragment),ar=c(),ut=o("p"),nr=r("This method forwards all its arguments to DonutTokenizer\u2019s "),Vt=o("a"),rr=r("decode()"),ir=r(`. Please refer to the
docstring of this method for more information.`),uo=c(),ne=o("h2"),Pe=o("a"),zs=o("span"),v(ht.$$.fragment),lr=c(),Ss=o("span"),dr=r("DonutSwinModel"),ho=c(),W=o("div"),v(gt.$$.fragment),cr=c(),ft=o("p"),pr=r(`The bare Donut Swin Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),_t=o("a"),mr=r("torch.nn.Module"),ur=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.`),hr=c(),O=o("div"),v(vt.$$.fragment),gr=c(),re=o("p"),fr=r("The "),Ut=o("a"),_r=r("DonutSwinModel"),vr=r(" forward method, overrides the "),Is=o("code"),br=r("__call__"),wr=r(" special method."),kr=c(),v(qe.$$.fragment),Dr=c(),v(ze.$$.fragment),this.h()},l(t){const d=Ki('[data-svelte="svelte-1phssyn"]',document.head);h=a(d,"META",{name:!0,content:!0}),d.forEach(s),j=p(t),g=a(t,"H1",{class:!0});var bt=n(g);f=a(bt,"A",{id:!0,class:!0,href:!0});var Cs=n(f);$=a(Cs,"SPAN",{});var Ms=n($);b(u.$$.fragment,Ms),Ms.forEach(s),Cs.forEach(s),_=p(bt),q=a(bt,"SPAN",{});var As=n(q);A=i(As,"Donut"),As.forEach(s),bt.forEach(s),E=p(t),z=a(t,"H2",{class:!0});var wt=n(z);P=a(wt,"A",{id:!0,class:!0,href:!0});var yr=n(P);S=a(yr,"SPAN",{});var Tr=n(S);b(H.$$.fragment,Tr),Tr.forEach(s),yr.forEach(s),kt=p(wt),le=a(wt,"SPAN",{});var Er=n(le);No=i(Er,"Overview"),Er.forEach(s),wt.forEach(s),Fs=p(t),de=a(t,"P",{});var fo=n(de);Oo=i(fo,"The Donut model was proposed in "),Me=a(fo,"A",{href:!0,rel:!0});var Pr=n(Me);Vo=i(Pr,"OCR-free Document Understanding Transformer"),Pr.forEach(s),Uo=i(fo,` 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.`),fo.forEach(s),Ls=p(t),Dt=a(t,"P",{});var qr=n(Dt);Wo=i(qr,"The abstract from the paper is the following:"),qr.forEach(s),Ns=p(t),xt=a(t,"P",{});var zr=n(xt);Zt=a(zr,"EM",{});var Sr=n(Zt);Ho=i(Sr,"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."),Sr.forEach(s),zr.forEach(s),Os=p(t),ce=a(t,"IMG",{src:!0,alt:!0,width:!0}),Vs=p(t),pe=a(t,"SMALL",{});var _o=n(pe);Xo=i(_o,"Donut high-level overview. Taken from the "),$t=a(_o,"A",{href:!0});var Ir=n($t);Bo=i(Ir,"original paper"),Ir.forEach(s),Jo=i(_o,"."),_o.forEach(s),Us=p(t),X=a(t,"P",{});var Wt=n(X);Go=i(Wt,"This model was contributed by "),Ae=a(Wt,"A",{href:!0,rel:!0});var Cr=n(Ae);Yo=i(Cr,"nielsr"),Cr.forEach(s),Qo=i(Wt,`. The original code can be found
`),Re=a(Wt,"A",{href:!0,rel:!0});var Mr=n(Re);Ko=i(Mr,"here"),Mr.forEach(s),Zo=i(Wt,"."),Wt.forEach(s),Ws=p(t),jt=a(t,"P",{});var Ar=n(jt);ea=i(Ar,"Tips:"),Ar.forEach(s),Hs=p(t),me=a(t,"UL",{});var vo=n(me);Fe=a(vo,"LI",{});var bo=n(Fe);ta=i(bo,"The quickest way to get started with Donut is by checking the "),Le=a(bo,"A",{href:!0,rel:!0});var Rr=n(Le);sa=i(Rr,`tutorial
notebooks`),Rr.forEach(s),oa=i(bo,`, which show how to use the model
at inference time as well as fine-tuning on custom data.`),bo.forEach(s),aa=p(vo),Ne=a(vo,"LI",{});var wo=n(Ne);na=i(wo,"Donut is always used within the "),yt=a(wo,"A",{href:!0});var Fr=n(yt);ra=i(Fr,"VisionEncoderDecoder"),Fr.forEach(s),ia=i(wo," framework."),wo.forEach(s),vo.forEach(s),Xs=p(t),Y=a(t,"H2",{class:!0});var ko=n(Y);ue=a(ko,"A",{id:!0,class:!0,href:!0});var Lr=n(ue);es=a(Lr,"SPAN",{});var Nr=n(es);b(Oe.$$.fragment,Nr),Nr.forEach(s),Lr.forEach(s),la=p(ko),ts=a(ko,"SPAN",{});var Or=n(ts);da=i(Or,"Inference"),Or.forEach(s),ko.forEach(s),Bs=p(t),B=a(t,"P",{});var Ht=n(B);ca=i(Ht,"Donut\u2019s "),ss=a(Ht,"CODE",{});var Vr=n(ss);pa=i(Vr,"VisionEncoderDecoder"),Vr.forEach(s),ma=i(Ht,` model accepts images as input and makes use of
`),Tt=a(Ht,"A",{href:!0});var Ur=n(Tt);ua=i(Ur,"generate()"),Ur.forEach(s),ha=i(Ht," to autoregressively generate text given the input image."),Ht.forEach(s),Js=p(t),T=a(t,"P",{});var C=n(T);ga=i(C,"The "),Et=a(C,"A",{href:!0});var Wr=n(Et);fa=i(Wr,"DonutFeatureExtractor"),Wr.forEach(s),_a=i(C,` class is responsible for preprocessing the input image and
[`),os=a(C,"CODE",{});var Hr=n(os);va=i(Hr,"XLMRobertaTokenizer"),Hr.forEach(s),ba=i(C,"/"),as=a(C,"CODE",{});var Xr=n(as);wa=i(Xr,"XLMRobertaTokenizerFast"),Xr.forEach(s),ka=i(C,`] decodes the generated target tokens to the target string. The
`),Pt=a(C,"A",{href:!0});var Br=n(Pt);Da=i(Br,"DonutProcessor"),Br.forEach(s),xa=i(C," wraps "),qt=a(C,"A",{href:!0});var Jr=n(qt);$a=i(Jr,"DonutFeatureExtractor"),Jr.forEach(s),ja=i(C," and ["),ns=a(C,"CODE",{});var Gr=n(ns);ya=i(Gr,"XLMRobertaTokenizer"),Gr.forEach(s),Ta=i(C,"/"),rs=a(C,"CODE",{});var Yr=n(rs);Ea=i(Yr,"XLMRobertaTokenizerFast"),Yr.forEach(s),Pa=i(C,`]
into a single instance to both extract the input features and decode the predicted token ids.`),C.forEach(s),Gs=p(t),zt=a(t,"UL",{});var Qr=n(zt);is=a(Qr,"LI",{});var Kr=n(is);qa=i(Kr,"Step-by-step Document Image Classification"),Kr.forEach(s),Qr.forEach(s),Ys=p(t),b(Ve.$$.fragment,t),Qs=p(t),St=a(t,"UL",{});var Zr=n(St);ls=a(Zr,"LI",{});var ei=n(ls);za=i(ei,"Step-by-step Document Parsing"),ei.forEach(s),Zr.forEach(s),Ks=p(t),b(Ue.$$.fragment,t),Zs=p(t),It=a(t,"UL",{});var ti=n(It);ds=a(ti,"LI",{});var si=n(ds);Sa=i(si,"Step-by-step Document Visual Question Answering (DocVQA)"),si.forEach(s),ti.forEach(s),eo=p(t),b(We.$$.fragment,t),to=p(t),he=a(t,"P",{});var Do=n(he);Ia=i(Do,"See the "),He=a(Do,"A",{href:!0,rel:!0});var oi=n(He);Ca=i(oi,"model hub"),oi.forEach(s),Ma=i(Do," to look for Donut checkpoints."),Do.forEach(s),so=p(t),Q=a(t,"H2",{class:!0});var xo=n(Q);ge=a(xo,"A",{id:!0,class:!0,href:!0});var ai=n(ge);cs=a(ai,"SPAN",{});var ni=n(cs);b(Xe.$$.fragment,ni),ni.forEach(s),ai.forEach(s),Aa=p(xo),ps=a(xo,"SPAN",{});var ri=n(ps);Ra=i(ri,"Training"),ri.forEach(s),xo.forEach(s),oo=p(t),fe=a(t,"P",{});var $o=n(fe);Fa=i($o,"We refer to the "),Be=a($o,"A",{href:!0,rel:!0});var ii=n(Be);La=i(ii,"tutorial notebooks"),ii.forEach(s),Na=i($o,"."),$o.forEach(s),ao=p(t),K=a(t,"H2",{class:!0});var jo=n(K);_e=a(jo,"A",{id:!0,class:!0,href:!0});var li=n(_e);ms=a(li,"SPAN",{});var di=n(ms);b(Je.$$.fragment,di),di.forEach(s),li.forEach(s),Oa=p(jo),us=a(jo,"SPAN",{});var ci=n(us);Va=i(ci,"DonutSwinConfig"),ci.forEach(s),jo.forEach(s),no=p(t),R=a(t,"DIV",{class:!0});var Se=n(R);b(Ge.$$.fragment,Se),Ua=p(Se),Z=a(Se,"P",{});var Xt=n(Z);Wa=i(Xt,"This is the configuration class to store the configuration of a "),Ct=a(Xt,"A",{href:!0});var pi=n(Ct);Ha=i(pi,"DonutSwinModel"),pi.forEach(s),Xa=i(Xt,`. 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
`),Ye=a(Xt,"A",{href:!0,rel:!0});var mi=n(Ye);Ba=i(mi,"naver-clova-ix/donut-base"),mi.forEach(s),Ja=i(Xt," architecture."),Xt.forEach(s),Ga=p(Se),ee=a(Se,"P",{});var Bt=n(ee);Ya=i(Bt,"Configuration objects inherit from "),Mt=a(Bt,"A",{href:!0});var ui=n(Mt);Qa=i(ui,"PretrainedConfig"),ui.forEach(s),Ka=i(Bt,` and can be used to control the model outputs. Read the
documentation from `),At=a(Bt,"A",{href:!0});var hi=n(At);Za=i(hi,"PretrainedConfig"),hi.forEach(s),en=i(Bt," for more information."),Bt.forEach(s),tn=p(Se),b(ve.$$.fragment,Se),Se.forEach(s),ro=p(t),te=a(t,"H2",{class:!0});var yo=n(te);be=a(yo,"A",{id:!0,class:!0,href:!0});var gi=n(be);hs=a(gi,"SPAN",{});var fi=n(hs);b(Qe.$$.fragment,fi),fi.forEach(s),gi.forEach(s),sn=p(yo),gs=a(yo,"SPAN",{});var _i=n(gs);on=i(_i,"DonutImageProcessor"),_i.forEach(s),yo.forEach(s),io=p(t),V=a(t,"DIV",{class:!0});var Jt=n(V);b(Ke.$$.fragment,Jt),an=p(Jt),fs=a(Jt,"P",{});var vi=n(fs);nn=i(vi,"Constructs a Donut image processor."),vi.forEach(s),rn=p(Jt),we=a(Jt,"DIV",{class:!0});var To=n(we);b(Ze.$$.fragment,To),ln=p(To),_s=a(To,"P",{});var bi=n(_s);dn=i(bi,"Preprocess an image or batch of images."),bi.forEach(s),To.forEach(s),Jt.forEach(s),lo=p(t),se=a(t,"H2",{class:!0});var Eo=n(se);ke=a(Eo,"A",{id:!0,class:!0,href:!0});var wi=n(ke);vs=a(wi,"SPAN",{});var ki=n(vs);b(et.$$.fragment,ki),ki.forEach(s),wi.forEach(s),cn=p(Eo),bs=a(Eo,"SPAN",{});var Di=n(bs);pn=i(Di,"DonutFeatureExtractor"),Di.forEach(s),Eo.forEach(s),co=p(t),oe=a(t,"DIV",{class:!0});var Po=n(oe);b(tt.$$.fragment,Po),mn=p(Po),De=a(Po,"DIV",{class:!0});var qo=n(De);b(st.$$.fragment,qo),un=p(qo),ws=a(qo,"P",{});var xi=n(ws);hn=i(xi,"Preprocess an image or a batch of images."),xi.forEach(s),qo.forEach(s),Po.forEach(s),po=p(t),ae=a(t,"H2",{class:!0});var zo=n(ae);xe=a(zo,"A",{id:!0,class:!0,href:!0});var $i=n(xe);ks=a($i,"SPAN",{});var ji=n(ks);b(ot.$$.fragment,ji),ji.forEach(s),$i.forEach(s),gn=p(zo),Ds=a(zo,"SPAN",{});var yi=n(Ds);fn=i(yi,"DonutProcessor"),yi.forEach(s),zo.forEach(s),mo=p(t),y=a(t,"DIV",{class:!0});var M=n(y);b(at.$$.fragment,M),_n=p(M),xs=a(M,"P",{});var Ti=n(xs);vn=i(Ti,`Constructs a Donut processor which wraps a Donut image processor and an XLMRoBERTa tokenizer into a single
processor.`),Ti.forEach(s),bn=p(M),I=a(M,"P",{});var F=n(I);Rt=a(F,"A",{href:!0});var Ei=n(Rt);wn=i(Ei,"DonutProcessor"),Ei.forEach(s),kn=i(F," offers all the functionalities of "),Ft=a(F,"A",{href:!0});var Pi=n(Ft);Dn=i(Pi,"DonutImageProcessor"),Pi.forEach(s),xn=i(F,` and
[`),$s=a(F,"CODE",{});var qi=n($s);$n=i(qi,"XLMRobertaTokenizer"),qi.forEach(s),jn=i(F,"/"),js=a(F,"CODE",{});var zi=n(js);yn=i(zi,"XLMRobertaTokenizerFast"),zi.forEach(s),Tn=i(F,"]. See the "),nt=a(F,"A",{href:!0});var xr=n(nt);ys=a(xr,"STRONG",{});var Si=n(ys);En=i(Si,"call"),Si.forEach(s),Pn=i(xr,"()"),xr.forEach(s),qn=i(F,` and
`),Lt=a(F,"A",{href:!0});var Ii=n(Lt);zn=i(Ii,"decode()"),Ii.forEach(s),Sn=i(F," for more information."),F.forEach(s),In=p(M),$e=a(M,"DIV",{class:!0});var So=n($e);b(rt.$$.fragment,So),Cn=p(So),U=a(So,"P",{});var Ie=n(U);Mn=i(Ie,`When used in normal mode, this method forwards all its arguments to AutoImageProcessor\u2019s
`),Ts=a(Ie,"CODE",{});var Ci=n(Ts);An=i(Ci,"__call__()"),Ci.forEach(s),Rn=i(Ie,` and returns its output. If used in the context
`),Es=a(Ie,"CODE",{});var Mi=n(Es);Fn=i(Mi,"as_target_processor()"),Mi.forEach(s),Ln=i(Ie,` this method forwards all its arguments to DonutTokenizer\u2019s
`),Ps=a(Ie,"CODE",{});var Ai=n(Ps);Nn=i(Ai,"~DonutTokenizer.__call__"),Ai.forEach(s),On=i(Ie,". Please refer to the doctsring of the above two methods for more information."),Ie.forEach(s),So.forEach(s),Vn=p(M),J=a(M,"DIV",{class:!0});var Gt=n(J);b(it.$$.fragment,Gt),Un=p(Gt),qs=a(Gt,"P",{});var Ri=n(qs);Wn=i(Ri,"Instantiate a processor associated with a pretrained model."),Ri.forEach(s),Hn=p(Gt),b(je.$$.fragment,Gt),Gt.forEach(s),Xn=p(M),G=a(M,"DIV",{class:!0});var Yt=n(G);b(lt.$$.fragment,Yt),Bn=p(Yt),dt=a(Yt,"P",{});var Io=n(dt);Jn=i(Io,`Saves the attributes of this processor (feature extractor, tokenizer\u2026) in the specified directory so that it
can be reloaded using the `),Nt=a(Io,"A",{href:!0});var Fi=n(Nt);Gn=i(Fi,"from_pretrained()"),Fi.forEach(s),Yn=i(Io," method."),Io.forEach(s),Qn=p(Yt),b(ye.$$.fragment,Yt),Yt.forEach(s),Kn=p(M),Te=a(M,"DIV",{class:!0});var Co=n(Te);b(ct.$$.fragment,Co),Zn=p(Co),pt=a(Co,"P",{});var Mo=n(pt);er=i(Mo,"This method forwards all its arguments to DonutTokenizer\u2019s "),Ot=a(Mo,"A",{href:!0});var Li=n(Ot);tr=i(Li,"batch_decode()"),Li.forEach(s),sr=i(Mo,`. Please refer
to the docstring of this method for more information.`),Mo.forEach(s),Co.forEach(s),or=p(M),Ee=a(M,"DIV",{class:!0});var Ao=n(Ee);b(mt.$$.fragment,Ao),ar=p(Ao),ut=a(Ao,"P",{});var Ro=n(ut);nr=i(Ro,"This method forwards all its arguments to DonutTokenizer\u2019s "),Vt=a(Ro,"A",{href:!0});var Ni=n(Vt);rr=i(Ni,"decode()"),Ni.forEach(s),ir=i(Ro,`. Please refer to the
docstring of this method for more information.`),Ro.forEach(s),Ao.forEach(s),M.forEach(s),uo=p(t),ne=a(t,"H2",{class:!0});var Fo=n(ne);Pe=a(Fo,"A",{id:!0,class:!0,href:!0});var Oi=n(Pe);zs=a(Oi,"SPAN",{});var Vi=n(zs);b(ht.$$.fragment,Vi),Vi.forEach(s),Oi.forEach(s),lr=p(Fo),Ss=a(Fo,"SPAN",{});var Ui=n(Ss);dr=i(Ui,"DonutSwinModel"),Ui.forEach(s),Fo.forEach(s),ho=p(t),W=a(t,"DIV",{class:!0});var Qt=n(W);b(gt.$$.fragment,Qt),cr=p(Qt),ft=a(Qt,"P",{});var Lo=n(ft);pr=i(Lo,`The bare Donut Swin Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),_t=a(Lo,"A",{href:!0,rel:!0});var Wi=n(_t);mr=i(Wi,"torch.nn.Module"),Wi.forEach(s),ur=i(Lo,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Lo.forEach(s),hr=p(Qt),O=a(Qt,"DIV",{class:!0});var Ce=n(O);b(vt.$$.fragment,Ce),gr=p(Ce),re=a(Ce,"P",{});var Kt=n(re);fr=i(Kt,"The "),Ut=a(Kt,"A",{href:!0});var Hi=n(Ut);_r=i(Hi,"DonutSwinModel"),Hi.forEach(s),vr=i(Kt," forward method, overrides the "),Is=a(Kt,"CODE",{});var Xi=n(Is);br=i(Xi,"__call__"),Xi.forEach(s),wr=i(Kt," special method."),Kt.forEach(s),kr=p(Ce),b(qe.$$.fragment,Ce),Dr=p(Ce),b(ze.$$.fragment,Ce),Ce.forEach(s),Qt.forEach(s),this.h()},h(){l(h,"name","hf:doc:metadata"),l(h,"content",JSON.stringify(il)),l(f,"id","donut"),l(f,"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(f,"href","#donut"),l(g,"class","relative group"),l(P,"id","overview"),l(P,"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(P,"href","#overview"),l(z,"class","relative group"),l(Me,"href","https://arxiv.org/abs/2111.15664"),l(Me,"rel","nofollow"),Zi(ce.src,jr="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/donut_architecture.jpg")||l(ce,"src",jr),l(ce,"alt","drawing"),l(ce,"width","600"),l($t,"href","https://arxiv.org/abs/2111.15664"),l(Ae,"href","https://huggingface.co/nielsr"),l(Ae,"rel","nofollow"),l(Re,"href","https://github.com/clovaai/donut"),l(Re,"rel","nofollow"),l(Le,"href","https://github.com/NielsRogge/Transformers-Tutorials/tree/master/Donut"),l(Le,"rel","nofollow"),l(yt,"href","vision-encoder-decoder"),l(ue,"id","inference"),l(ue,"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(ue,"href","#inference"),l(Y,"class","relative group"),l(Tt,"href","/docs/transformers/v4.29.0/en/main_classes/text_generation#transformers.GenerationMixin.generate"),l(Et,"href","/docs/transformers/v4.29.0/en/model_doc/donut#transformers.DonutFeatureExtractor"),l(Pt,"href","/docs/transformers/v4.29.0/en/model_doc/donut#transformers.DonutProcessor"),l(qt,"href","/docs/transformers/v4.29.0/en/model_doc/donut#transformers.DonutFeatureExtractor"),l(He,"href","https://huggingface.co/models?filter=donut"),l(He,"rel","nofollow"),l(ge,"id","training"),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","#training"),l(Q,"class","relative group"),l(Be,"href","https://github.com/NielsRogge/Transformers-Tutorials/tree/master/Donut"),l(Be,"rel","nofollow"),l(_e,"id","transformers.DonutSwinConfig"),l(_e,"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(_e,"href","#transformers.DonutSwinConfig"),l(K,"class","relative group"),l(Ct,"href","/docs/transformers/v4.29.0/en/model_doc/donut#transformers.DonutSwinModel"),l(Ye,"href","https://huggingface.co/naver-clova-ix/donut-base"),l(Ye,"rel","nofollow"),l(Mt,"href","/docs/transformers/v4.29.0/en/main_classes/configuration#transformers.PretrainedConfig"),l(At,"href","/docs/transformers/v4.29.0/en/main_classes/configuration#transformers.PretrainedConfig"),l(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(be,"id","transformers.DonutImageProcessor"),l(be,"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(be,"href","#transformers.DonutImageProcessor"),l(te,"class","relative group"),l(we,"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(ke,"id","transformers.DonutFeatureExtractor"),l(ke,"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(ke,"href","#transformers.DonutFeatureExtractor"),l(se,"class","relative group"),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(oe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(xe,"id","transformers.DonutProcessor"),l(xe,"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(xe,"href","#transformers.DonutProcessor"),l(ae,"class","relative group"),l(Rt,"href","/docs/transformers/v4.29.0/en/model_doc/donut#transformers.DonutProcessor"),l(Ft,"href","/docs/transformers/v4.29.0/en/model_doc/donut#transformers.DonutImageProcessor"),l(nt,"href","/docs/transformers/v4.29.0/en/model_doc/donut#transformers.DonutProcessor.__call__"),l(Lt,"href","/docs/transformers/v4.29.0/en/model_doc/donut#transformers.DonutProcessor.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(J,"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.29.0/en/main_classes/processors#transformers.ProcessorMixin.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(Ot,"href","/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.batch_decode"),l(Te,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(Vt,"href","/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.decode"),l(Ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(Pe,"id","transformers.DonutSwinModel"),l(Pe,"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(Pe,"href","#transformers.DonutSwinModel"),l(ne,"class","relative group"),l(_t,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(_t,"rel","nofollow"),l(Ut,"href","/docs/transformers/v4.29.0/en/model_doc/donut#transformers.DonutSwinModel"),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(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,j,d),m(t,g,d),e(g,f),e(f,$),w(u,$,null),e(g,_),e(g,q),e(q,A),m(t,E,d),m(t,z,d),e(z,P),e(P,S),w(H,S,null),e(z,kt),e(z,le),e(le,No),m(t,Fs,d),m(t,de,d),e(de,Oo),e(de,Me),e(Me,Vo),e(de,Uo),m(t,Ls,d),m(t,Dt,d),e(Dt,Wo),m(t,Ns,d),m(t,xt,d),e(xt,Zt),e(Zt,Ho),m(t,Os,d),m(t,ce,d),m(t,Vs,d),m(t,pe,d),e(pe,Xo),e(pe,$t),e($t,Bo),e(pe,Jo),m(t,Us,d),m(t,X,d),e(X,Go),e(X,Ae),e(Ae,Yo),e(X,Qo),e(X,Re),e(Re,Ko),e(X,Zo),m(t,Ws,d),m(t,jt,d),e(jt,ea),m(t,Hs,d),m(t,me,d),e(me,Fe),e(Fe,ta),e(Fe,Le),e(Le,sa),e(Fe,oa),e(me,aa),e(me,Ne),e(Ne,na),e(Ne,yt),e(yt,ra),e(Ne,ia),m(t,Xs,d),m(t,Y,d),e(Y,ue),e(ue,es),w(Oe,es,null),e(Y,la),e(Y,ts),e(ts,da),m(t,Bs,d),m(t,B,d),e(B,ca),e(B,ss),e(ss,pa),e(B,ma),e(B,Tt),e(Tt,ua),e(B,ha),m(t,Js,d),m(t,T,d),e(T,ga),e(T,Et),e(Et,fa),e(T,_a),e(T,os),e(os,va),e(T,ba),e(T,as),e(as,wa),e(T,ka),e(T,Pt),e(Pt,Da),e(T,xa),e(T,qt),e(qt,$a),e(T,ja),e(T,ns),e(ns,ya),e(T,Ta),e(T,rs),e(rs,Ea),e(T,Pa),m(t,Gs,d),m(t,zt,d),e(zt,is),e(is,qa),m(t,Ys,d),w(Ve,t,d),m(t,Qs,d),m(t,St,d),e(St,ls),e(ls,za),m(t,Ks,d),w(Ue,t,d),m(t,Zs,d),m(t,It,d),e(It,ds),e(ds,Sa),m(t,eo,d),w(We,t,d),m(t,to,d),m(t,he,d),e(he,Ia),e(he,He),e(He,Ca),e(he,Ma),m(t,so,d),m(t,Q,d),e(Q,ge),e(ge,cs),w(Xe,cs,null),e(Q,Aa),e(Q,ps),e(ps,Ra),m(t,oo,d),m(t,fe,d),e(fe,Fa),e(fe,Be),e(Be,La),e(fe,Na),m(t,ao,d),m(t,K,d),e(K,_e),e(_e,ms),w(Je,ms,null),e(K,Oa),e(K,us),e(us,Va),m(t,no,d),m(t,R,d),w(Ge,R,null),e(R,Ua),e(R,Z),e(Z,Wa),e(Z,Ct),e(Ct,Ha),e(Z,Xa),e(Z,Ye),e(Ye,Ba),e(Z,Ja),e(R,Ga),e(R,ee),e(ee,Ya),e(ee,Mt),e(Mt,Qa),e(ee,Ka),e(ee,At),e(At,Za),e(ee,en),e(R,tn),w(ve,R,null),m(t,ro,d),m(t,te,d),e(te,be),e(be,hs),w(Qe,hs,null),e(te,sn),e(te,gs),e(gs,on),m(t,io,d),m(t,V,d),w(Ke,V,null),e(V,an),e(V,fs),e(fs,nn),e(V,rn),e(V,we),w(Ze,we,null),e(we,ln),e(we,_s),e(_s,dn),m(t,lo,d),m(t,se,d),e(se,ke),e(ke,vs),w(et,vs,null),e(se,cn),e(se,bs),e(bs,pn),m(t,co,d),m(t,oe,d),w(tt,oe,null),e(oe,mn),e(oe,De),w(st,De,null),e(De,un),e(De,ws),e(ws,hn),m(t,po,d),m(t,ae,d),e(ae,xe),e(xe,ks),w(ot,ks,null),e(ae,gn),e(ae,Ds),e(Ds,fn),m(t,mo,d),m(t,y,d),w(at,y,null),e(y,_n),e(y,xs),e(xs,vn),e(y,bn),e(y,I),e(I,Rt),e(Rt,wn),e(I,kn),e(I,Ft),e(Ft,Dn),e(I,xn),e(I,$s),e($s,$n),e(I,jn),e(I,js),e(js,yn),e(I,Tn),e(I,nt),e(nt,ys),e(ys,En),e(nt,Pn),e(I,qn),e(I,Lt),e(Lt,zn),e(I,Sn),e(y,In),e(y,$e),w(rt,$e,null),e($e,Cn),e($e,U),e(U,Mn),e(U,Ts),e(Ts,An),e(U,Rn),e(U,Es),e(Es,Fn),e(U,Ln),e(U,Ps),e(Ps,Nn),e(U,On),e(y,Vn),e(y,J),w(it,J,null),e(J,Un),e(J,qs),e(qs,Wn),e(J,Hn),w(je,J,null),e(y,Xn),e(y,G),w(lt,G,null),e(G,Bn),e(G,dt),e(dt,Jn),e(dt,Nt),e(Nt,Gn),e(dt,Yn),e(G,Qn),w(ye,G,null),e(y,Kn),e(y,Te),w(ct,Te,null),e(Te,Zn),e(Te,pt),e(pt,er),e(pt,Ot),e(Ot,tr),e(pt,sr),e(y,or),e(y,Ee),w(mt,Ee,null),e(Ee,ar),e(Ee,ut),e(ut,nr),e(ut,Vt),e(Vt,rr),e(ut,ir),m(t,uo,d),m(t,ne,d),e(ne,Pe),e(Pe,zs),w(ht,zs,null),e(ne,lr),e(ne,Ss),e(Ss,dr),m(t,ho,d),m(t,W,d),w(gt,W,null),e(W,cr),e(W,ft),e(ft,pr),e(ft,_t),e(_t,mr),e(ft,ur),e(W,hr),e(W,O),w(vt,O,null),e(O,gr),e(O,re),e(re,fr),e(re,Ut),e(Ut,_r),e(re,vr),e(re,Is),e(Is,br),e(re,wr),e(O,kr),w(qe,O,null),e(O,Dr),w(ze,O,null),go=!0},p(t,[d]){const bt={};d&2&&(bt.$$scope={dirty:d,ctx:t}),ve.$set(bt);const Cs={};d&2&&(Cs.$$scope={dirty:d,ctx:t}),je.$set(Cs);const Ms={};d&2&&(Ms.$$scope={dirty:d,ctx:t}),ye.$set(Ms);const As={};d&2&&(As.$$scope={dirty:d,ctx:t}),qe.$set(As);const wt={};d&2&&(wt.$$scope={dirty:d,ctx:t}),ze.$set(wt)},i(t){go||(k(u.$$.fragment,t),k(H.$$.fragment,t),k(Oe.$$.fragment,t),k(Ve.$$.fragment,t),k(Ue.$$.fragment,t),k(We.$$.fragment,t),k(Xe.$$.fragment,t),k(Je.$$.fragment,t),k(Ge.$$.fragment,t),k(ve.$$.fragment,t),k(Qe.$$.fragment,t),k(Ke.$$.fragment,t),k(Ze.$$.fragment,t),k(et.$$.fragment,t),k(tt.$$.fragment,t),k(st.$$.fragment,t),k(ot.$$.fragment,t),k(at.$$.fragment,t),k(rt.$$.fragment,t),k(it.$$.fragment,t),k(je.$$.fragment,t),k(lt.$$.fragment,t),k(ye.$$.fragment,t),k(ct.$$.fragment,t),k(mt.$$.fragment,t),k(ht.$$.fragment,t),k(gt.$$.fragment,t),k(vt.$$.fragment,t),k(qe.$$.fragment,t),k(ze.$$.fragment,t),go=!0)},o(t){D(u.$$.fragment,t),D(H.$$.fragment,t),D(Oe.$$.fragment,t),D(Ve.$$.fragment,t),D(Ue.$$.fragment,t),D(We.$$.fragment,t),D(Xe.$$.fragment,t),D(Je.$$.fragment,t),D(Ge.$$.fragment,t),D(ve.$$.fragment,t),D(Qe.$$.fragment,t),D(Ke.$$.fragment,t),D(Ze.$$.fragment,t),D(et.$$.fragment,t),D(tt.$$.fragment,t),D(st.$$.fragment,t),D(ot.$$.fragment,t),D(at.$$.fragment,t),D(rt.$$.fragment,t),D(it.$$.fragment,t),D(je.$$.fragment,t),D(lt.$$.fragment,t),D(ye.$$.fragment,t),D(ct.$$.fragment,t),D(mt.$$.fragment,t),D(ht.$$.fragment,t),D(gt.$$.fragment,t),D(vt.$$.fragment,t),D(qe.$$.fragment,t),D(ze.$$.fragment,t),go=!1},d(t){s(h),t&&s(j),t&&s(g),x(u),t&&s(E),t&&s(z),x(H),t&&s(Fs),t&&s(de),t&&s(Ls),t&&s(Dt),t&&s(Ns),t&&s(xt),t&&s(Os),t&&s(ce),t&&s(Vs),t&&s(pe),t&&s(Us),t&&s(X),t&&s(Ws),t&&s(jt),t&&s(Hs),t&&s(me),t&&s(Xs),t&&s(Y),x(Oe),t&&s(Bs),t&&s(B),t&&s(Js),t&&s(T),t&&s(Gs),t&&s(zt),t&&s(Ys),x(Ve,t),t&&s(Qs),t&&s(St),t&&s(Ks),x(Ue,t),t&&s(Zs),t&&s(It),t&&s(eo),x(We,t),t&&s(to),t&&s(he),t&&s(so),t&&s(Q),x(Xe),t&&s(oo),t&&s(fe),t&&s(ao),t&&s(K),x(Je),t&&s(no),t&&s(R),x(Ge),x(ve),t&&s(ro),t&&s(te),x(Qe),t&&s(io),t&&s(V),x(Ke),x(Ze),t&&s(lo),t&&s(se),x(et),t&&s(co),t&&s(oe),x(tt),x(st),t&&s(po),t&&s(ae),x(ot),t&&s(mo),t&&s(y),x(at),x(rt),x(it),x(je),x(lt),x(ye),x(ct),x(mt),t&&s(uo),t&&s(ne),x(ht),t&&s(ho),t&&s(W),x(gt),x(vt),x(qe),x(ze)}}}const il={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.DonutFeatureExtractor",title:"DonutFeatureExtractor"},{local:"transformers.DonutProcessor",title:"DonutProcessor"},{local:"transformers.DonutSwinModel",title:"DonutSwinModel"}],title:"Donut"};function ll(N){return el(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class gl extends Gi{constructor(h){super();Yi(this,h,ll,rl,Qi,{})}}export{gl as default,il as metadata};
