import{S as Vi,i as Bi,s as Si,e as s,k as c,w as T,t as r,M as Di,c as n,d as o,m as h,a as l,x as v,h as a,b as i,N as Xi,G as e,g as m,y as b,q as y,o as w,B as C,v as Gi,L as Li}from"../../chunks/vendor-hf-doc-builder.js";import{T as Fi}from"../../chunks/Tip-hf-doc-builder.js";import{D as ne}from"../../chunks/Docstring-hf-doc-builder.js";import{C as dl}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Et}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Ai}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";import{P as Ni}from"../../chunks/PipelineTag-hf-doc-builder.js";function qi(S){let f,E,u,g,k;return g=new dl({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyT0NSQ29uZmlnJTJDJTIwVHJPQ1JGb3JDYXVzYWxMTSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBUck9DUi1iYXNlJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMFRyT0NSQ29uZmlnKCklMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwbW9kZWwlMjAod2l0aCUyMHJhbmRvbSUyMHdlaWdodHMpJTIwZnJvbSUyMHRoZSUyMFRyT0NSLWJhc2UlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFtb2RlbCUyMCUzRCUyMFRyT0NSRm9yQ2F1c2FsTE0oY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrOCRConfig, TrOCRForCausalLM

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a TrOCR-base style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = TrOCRConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the TrOCR-base style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TrOCRForCausalLM(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(){f=s("p"),E=r("Example:"),u=c(),T(g.$$.fragment)},l(p){f=n(p,"P",{});var _=l(f);E=a(_,"Example:"),_.forEach(o),u=h(p),v(g.$$.fragment,p)},m(p,_){m(p,f,_),e(f,E),m(p,u,_),b(g,p,_),k=!0},p:Li,i(p){k||(y(g.$$.fragment,p),k=!0)},o(p){w(g.$$.fragment,p),k=!1},d(p){p&&o(f),p&&o(u),C(g,p)}}}function Yi(S){let f,E,u,g,k,p,_,z,W,j,I;return{c(){f=s("p"),E=r(`This class method is simply calling the feature extractor
`),u=s("a"),g=r("from_pretrained()"),k=r(`, image processor
`),p=s("a"),_=r("ImageProcessingMixin"),z=r(` and the tokenizer
`),W=s("code"),j=r("~tokenization_utils_base.PreTrainedTokenizer.from_pretrained"),I=r(` methods. Please refer to the docstrings of the
methods above for more information.`),this.h()},l(J){f=n(J,"P",{});var Z=l(f);E=a(Z,`This class method is simply calling the feature extractor
`),u=n(Z,"A",{href:!0});var D=l(u);g=a(D,"from_pretrained()"),D.forEach(o),k=a(Z,`, image processor
`),p=n(Z,"A",{href:!0});var $t=l(p);_=a($t,"ImageProcessingMixin"),$t.forEach(o),z=a(Z,` and the tokenizer
`),W=n(Z,"CODE",{});var le=l(W);j=a(le,"~tokenization_utils_base.PreTrainedTokenizer.from_pretrained"),le.forEach(o),I=a(Z,` methods. Please refer to the docstrings of the
methods above for more information.`),Z.forEach(o),this.h()},h(){i(u,"href","/docs/transformers/v4.33.0/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin.from_pretrained"),i(p,"href","/docs/transformers/v4.33.0/en/internal/image_processing_utils#transformers.ImageProcessingMixin")},m(J,Z){m(J,f,Z),e(f,E),e(f,u),e(u,g),e(f,k),e(f,p),e(p,_),e(f,z),e(f,W),e(W,j),e(f,I)},d(J){J&&o(f)}}}function Qi(S){let f,E,u,g,k,p,_,z;return{c(){f=s("p"),E=r("This class method is simply calling "),u=s("a"),g=r("save_pretrained()"),k=r(` and
`),p=s("a"),_=r("save_pretrained()"),z=r(`. Please refer to the docstrings of the
methods above for more information.`),this.h()},l(W){f=n(W,"P",{});var j=l(f);E=a(j,"This class method is simply calling "),u=n(j,"A",{href:!0});var I=l(u);g=a(I,"save_pretrained()"),I.forEach(o),k=a(j,` and
`),p=n(j,"A",{href:!0});var J=l(p);_=a(J,"save_pretrained()"),J.forEach(o),z=a(j,`. Please refer to the docstrings of the
methods above for more information.`),j.forEach(o),this.h()},h(){i(u,"href","/docs/transformers/v4.33.0/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin.save_pretrained"),i(p,"href","/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.save_pretrained")},m(W,j){m(W,f,j),e(f,E),e(f,u),e(u,g),e(f,k),e(f,p),e(p,_),e(f,z)},d(W){W&&o(f)}}}function Hi(S){let f,E,u,g,k;return g=new dl({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMCglMEElMjAlMjAlMjAlMjBUck9DUkNvbmZpZyUyQyUwQSUyMCUyMCUyMCUyMFRyT0NSUHJvY2Vzc29yJTJDJTBBJTIwJTIwJTIwJTIwVHJPQ1JGb3JDYXVzYWxMTSUyQyUwQSUyMCUyMCUyMCUyMFZpVENvbmZpZyUyQyUwQSUyMCUyMCUyMCUyMFZpVE1vZGVsJTJDJTBBJTIwJTIwJTIwJTIwVmlzaW9uRW5jb2RlckRlY29kZXJNb2RlbCUyQyUwQSklMEFpbXBvcnQlMjByZXF1ZXN0cyUwQWZyb20lMjBQSUwlMjBpbXBvcnQlMjBJbWFnZSUwQSUwQSUyMyUyMFRyT0NSJTIwaXMlMjBhJTIwZGVjb2RlciUyMG1vZGVsJTIwYW5kJTIwc2hvdWxkJTIwYmUlMjB1c2VkJTIwd2l0aGluJTIwYSUyMFZpc2lvbkVuY29kZXJEZWNvZGVyTW9kZWwlMEElMjMlMjBpbml0JTIwdmlzaW9uMnRleHQlMjBtb2RlbCUyMHdpdGglMjByYW5kb20lMjB3ZWlnaHRzJTBBZW5jb2RlciUyMCUzRCUyMFZpVE1vZGVsKFZpVENvbmZpZygpKSUwQWRlY29kZXIlMjAlM0QlMjBUck9DUkZvckNhdXNhbExNKFRyT0NSQ29uZmlnKCkpJTBBbW9kZWwlMjAlM0QlMjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsKGVuY29kZXIlM0RlbmNvZGVyJTJDJTIwZGVjb2RlciUzRGRlY29kZXIpJTBBJTBBJTIzJTIwSWYlMjB5b3UlMjB3YW50JTIwdG8lMjBzdGFydCUyMGZyb20lMjB0aGUlMjBwcmV0cmFpbmVkJTIwbW9kZWwlMkMlMjBsb2FkJTIwdGhlJTIwY2hlY2twb2ludCUyMHdpdGglMjAlNjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsJTYwJTBBcHJvY2Vzc29yJTIwJTNEJTIwVHJPQ1JQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3Jvc29mdCUyRnRyb2NyLWJhc2UtaGFuZHdyaXR0ZW4lMjIpJTBBbW9kZWwlMjAlM0QlMjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZ0cm9jci1iYXNlLWhhbmR3cml0dGVuJTIyKSUwQSUwQSUyMyUyMGxvYWQlMjBpbWFnZSUyMGZyb20lMjB0aGUlMjBJQU0lMjBkYXRhc2V0JTBBdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZma2kudGljLmhlaWEtZnIuY2glMkZzdGF0aWMlMkZpbWclMkZhMDEtMTIyLTAyLmpwZyUyMiUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQodXJsJTJDJTIwc3RyZWFtJTNEVHJ1ZSkucmF3KS5jb252ZXJ0KCUyMlJHQiUyMiklMEFwaXhlbF92YWx1ZXMlMjAlM0QlMjBwcm9jZXNzb3IoaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS5waXhlbF92YWx1ZXMlMEF0ZXh0JTIwJTNEJTIwJTIyaW5kdXN0cnklMkMlMjAnJTIwTXIuJTIwQnJvd24lMjBjb21tZW50ZWQlMjBpY2lseS4lMjAnJTIwTGV0JTIwdXMlMjBoYXZlJTIwYSUyMiUwQSUwQSUyMyUyMHRyYWluaW5nJTBBbW9kZWwuY29uZmlnLmRlY29kZXJfc3RhcnRfdG9rZW5faWQlMjAlM0QlMjBwcm9jZXNzb3IudG9rZW5pemVyLmNsc190b2tlbl9pZCUwQW1vZGVsLmNvbmZpZy5wYWRfdG9rZW5faWQlMjAlM0QlMjBwcm9jZXNzb3IudG9rZW5pemVyLnBhZF90b2tlbl9pZCUwQW1vZGVsLmNvbmZpZy52b2NhYl9zaXplJTIwJTNEJTIwbW9kZWwuY29uZmlnLmRlY29kZXIudm9jYWJfc2l6ZSUwQSUwQWxhYmVscyUyMCUzRCUyMHByb2Nlc3Nvci50b2tlbml6ZXIodGV4dCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpLmlucHV0X2lkcyUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbChwaXhlbF92YWx1ZXMlMkMlMjBsYWJlbHMlM0RsYWJlbHMpJTBBbG9zcyUyMCUzRCUyMG91dHB1dHMubG9zcyUwQXJvdW5kKGxvc3MuaXRlbSgpJTJDJTIwMiklMEElMEElMjMlMjBpbmZlcmVuY2UlMEFnZW5lcmF0ZWRfaWRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUocGl4ZWxfdmFsdWVzKSUwQWdlbmVyYXRlZF90ZXh0JTIwJTNEJTIwcHJvY2Vzc29yLmJhdGNoX2RlY29kZShnZW5lcmF0ZWRfaWRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpJTVCMCU1RCUwQWdlbmVyYXRlZF90ZXh0",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> (
<span class="hljs-meta">... </span>    TrOCRConfig,
<span class="hljs-meta">... </span>    TrOCRProcessor,
<span class="hljs-meta">... </span>    TrOCRForCausalLM,
<span class="hljs-meta">... </span>    ViTConfig,
<span class="hljs-meta">... </span>    ViTModel,
<span class="hljs-meta">... </span>    VisionEncoderDecoderModel,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># TrOCR is a decoder model and should be used within a VisionEncoderDecoderModel</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># init vision2text model with random weights</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>encoder = ViTModel(ViTConfig())
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder = TrOCRForCausalLM(TrOCRConfig())
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel(encoder=encoder, decoder=decoder)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># If you want to start from the pretrained model, load the checkpoint with \`VisionEncoderDecoderModel\`</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = TrOCRProcessor.from_pretrained(<span class="hljs-string">&quot;microsoft/trocr-base-handwritten&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;microsoft/trocr-base-handwritten&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load image from the IAM dataset</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;https://fki.tic.heia-fr.ch/static/img/a01-122-02.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
<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>text = <span class="hljs-string">&quot;industry, &#x27; Mr. Brown commented icily. &#x27; Let us have a&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># training</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.decoder_start_token_id = processor.tokenizer.cls_token_id
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.pad_token_id = processor.tokenizer.pad_token_id
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.vocab_size = model.config.decoder.vocab_size

<span class="hljs-meta">&gt;&gt;&gt; </span>labels = processor.tokenizer(text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(pixel_values, labels=labels)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">round</span>(loss.item(), <span class="hljs-number">2</span>)
<span class="hljs-number">5.30</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># inference</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_ids = model.generate(pixel_values)
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_text = processor.batch_decode(generated_ids, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_text
<span class="hljs-string">&#x27;industry, &quot; Mr. Brown commented icily. &quot; Let us have a&#x27;</span>`}}),{c(){f=s("p"),E=r("Example:"),u=c(),T(g.$$.fragment)},l(p){f=n(p,"P",{});var _=l(f);E=a(_,"Example:"),_.forEach(o),u=h(p),v(g.$$.fragment,p)},m(p,_){m(p,f,_),e(f,E),m(p,u,_),b(g,p,_),k=!0},p:Li,i(p){k||(y(g.$$.fragment,p),k=!0)},o(p){w(g.$$.fragment,p),k=!1},d(p){p&&o(f),p&&o(u),C(g,p)}}}function Ki(S){let f,E,u,g,k,p,_,z,W,j,I,J,Z,D,$t,le,Sr,Vo,X,Dr,je,Xr,Gr,Je,qr,Yr,Bo,Ot,Qr,So,jt,no,Hr,Do,ie,cl,Xo,de,Kr,Jt,ea,ta,Go,ce,oa,lo,ra,aa,qo,G,sa,Ie,na,la,Ze,ia,da,Yo,It,ca,Qo,q,xe,ha,Ue,ma,pa,fa,L,ua,We,ga,_a,Pe,Ta,va,ze,ba,ya,wa,Fe,Ca,Zt,Ma,ka,Ho,K,he,io,Ae,Ra,co,Ea,Ko,xt,$a,er,Ne,tr,x,Le,Oa,Ve,ja,Ja,Ia,Be,Za,Se,xa,Ua,Wa,De,Pa,Xe,za,Fa,Aa,Ge,Na,qe,La,Va,Ba,Ye,Sa,Qe,Da,Xa,Ga,He,qa,Ke,Ya,Qa,or,et,rr,Ut,Wt,tt,Ha,Ka,ar,Pt,es,sr,zt,ot,ts,rt,os,rs,nr,ee,me,ho,at,as,mo,ss,lr,Y,ns,po,ls,is,Ft,ds,cs,ir,M,hs,fo,ms,ps,uo,fs,us,go,gs,_s,_o,Ts,vs,At,bs,ys,To,ws,Cs,vo,Ms,ks,bo,Rs,Es,yo,$s,Os,dr,Nt,wo,js,cr,st,hr,pe,Js,nt,Is,Zs,mr,te,fe,Co,lt,xs,Mo,Us,pr,F,it,Ws,oe,Ps,Lt,zs,Fs,dt,As,Ns,Ls,re,Vs,Vt,Bs,Ss,Bt,Ds,Xs,Gs,ue,fr,ae,ge,ko,ct,qs,Ro,Ys,ur,R,ht,Qs,Eo,Hs,Ks,O,St,en,tn,$o,on,rn,Oo,an,sn,jo,nn,ln,Jo,dn,cn,mt,Io,hn,mn,pn,Dt,fn,un,gn,_e,pt,_n,V,Tn,Zo,vn,bn,xo,yn,wn,Uo,Cn,Mn,kn,Q,ft,Rn,Wo,En,$n,Te,On,H,ut,jn,gt,Jn,Xt,In,Zn,xn,ve,Un,be,_t,Wn,Tt,Pn,Gt,zn,Fn,An,ye,vt,Nn,bt,Ln,qt,Vn,Bn,gr,se,we,Po,yt,Sn,zo,Dn,_r,A,wt,Xn,B,Gn,Yt,qn,Yn,Fo,Qn,Hn,Qt,Kn,el,tl,Ct,ol,Mt,rl,al,sl,Ce,kt,nl,Me,Tr;return p=new Et({}),D=new Et({}),Ae=new Et({}),Ne=new Ni({props:{pipeline:"text-classification"}}),et=new Ni({props:{pipeline:"text-generation"}}),at=new Et({}),st=new dl({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyT0NSUHJvY2Vzc29yJTJDJTIwVmlzaW9uRW5jb2RlckRlY29kZXJNb2RlbCUwQWltcG9ydCUyMHJlcXVlc3RzJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBJTBBcHJvY2Vzc29yJTIwJTNEJTIwVHJPQ1JQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3Jvc29mdCUyRnRyb2NyLWJhc2UtaGFuZHdyaXR0ZW4lMjIpJTBBbW9kZWwlMjAlM0QlMjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZ0cm9jci1iYXNlLWhhbmR3cml0dGVuJTIyKSUwQSUwQSUyMyUyMGxvYWQlMjBpbWFnZSUyMGZyb20lMjB0aGUlMjBJQU0lMjBkYXRhc2V0JTBBdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZma2kudGljLmhlaWEtZnIuY2glMkZzdGF0aWMlMkZpbWclMkZhMDEtMTIyLTAyLmpwZyUyMiUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQodXJsJTJDJTIwc3RyZWFtJTNEVHJ1ZSkucmF3KS5jb252ZXJ0KCUyMlJHQiUyMiklMEElMEFwaXhlbF92YWx1ZXMlMjAlM0QlMjBwcm9jZXNzb3IoaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS5waXhlbF92YWx1ZXMlMEFnZW5lcmF0ZWRfaWRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUocGl4ZWxfdmFsdWVzKSUwQSUwQWdlbmVyYXRlZF90ZXh0JTIwJTNEJTIwcHJvY2Vzc29yLmJhdGNoX2RlY29kZShnZW5lcmF0ZWRfaWRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpJTVCMCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrOCRProcessor, VisionEncoderDecoderModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = TrOCRProcessor.from_pretrained(<span class="hljs-string">&quot;microsoft/trocr-base-handwritten&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;microsoft/trocr-base-handwritten&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load image from the IAM dataset</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;https://fki.tic.heia-fr.ch/static/img/a01-122-02.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw).convert(<span class="hljs-string">&quot;RGB&quot;</span>)

<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>generated_ids = model.generate(pixel_values)

<span class="hljs-meta">&gt;&gt;&gt; </span>generated_text = processor.batch_decode(generated_ids, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]`}}),lt=new Et({}),it=new ne({props:{name:"class transformers.TrOCRConfig",anchor:"transformers.TrOCRConfig",parameters:[{name:"vocab_size",val:" = 50265"},{name:"d_model",val:" = 1024"},{name:"decoder_layers",val:" = 12"},{name:"decoder_attention_heads",val:" = 16"},{name:"decoder_ffn_dim",val:" = 4096"},{name:"activation_function",val:" = 'gelu'"},{name:"max_position_embeddings",val:" = 512"},{name:"dropout",val:" = 0.1"},{name:"attention_dropout",val:" = 0.0"},{name:"activation_dropout",val:" = 0.0"},{name:"decoder_start_token_id",val:" = 2"},{name:"init_std",val:" = 0.02"},{name:"decoder_layerdrop",val:" = 0.0"},{name:"use_cache",val:" = True"},{name:"scale_embedding",val:" = False"},{name:"use_learned_position_embeddings",val:" = True"},{name:"layernorm_embedding",val:" = True"},{name:"pad_token_id",val:" = 1"},{name:"bos_token_id",val:" = 0"},{name:"eos_token_id",val:" = 2"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TrOCRConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 50265) &#x2014;
Vocabulary size of the TrOCR model. Defines the number of different tokens that can be represented by the
<code>inputs_ids</code> passed when calling <a href="/docs/transformers/v4.33.0/en/model_doc/trocr#transformers.TrOCRForCausalLM">TrOCRForCausalLM</a>.`,name:"vocab_size"},{anchor:"transformers.TrOCRConfig.d_model",description:`<strong>d_model</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
Dimensionality of the layers and the pooler layer.`,name:"d_model"},{anchor:"transformers.TrOCRConfig.decoder_layers",description:`<strong>decoder_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of decoder layers.`,name:"decoder_layers"},{anchor:"transformers.TrOCRConfig.decoder_attention_heads",description:`<strong>decoder_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
Number of attention heads for each attention layer in the Transformer decoder.`,name:"decoder_attention_heads"},{anchor:"transformers.TrOCRConfig.decoder_ffn_dim",description:`<strong>decoder_ffn_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 4096) &#x2014;
Dimensionality of the &#x201C;intermediate&#x201D; (often named feed-forward) layer in decoder.`,name:"decoder_ffn_dim"},{anchor:"transformers.TrOCRConfig.activation_function",description:`<strong>activation_function</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 pooler. If string, <code>&quot;gelu&quot;</code>, <code>&quot;relu&quot;</code>,
<code>&quot;silu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"activation_function"},{anchor:"transformers.TrOCRConfig.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 512) &#x2014;
The maximum sequence length that this model might ever be used with. Typically set this to something large
just in case (e.g., 512 or 1024 or 2048).`,name:"max_position_embeddings"},{anchor:"transformers.TrOCRConfig.dropout",description:`<strong>dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probability for all fully connected layers in the embeddings, and pooler.`,name:"dropout"},{anchor:"transformers.TrOCRConfig.attention_dropout",description:`<strong>attention_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout ratio for the attention probabilities.`,name:"attention_dropout"},{anchor:"transformers.TrOCRConfig.activation_dropout",description:`<strong>activation_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout ratio for activations inside the fully connected layer.`,name:"activation_dropout"},{anchor:"transformers.TrOCRConfig.init_std",description:`<strong>init_std</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:"init_std"},{anchor:"transformers.TrOCRConfig.decoder_layerdrop",description:`<strong>decoder_layerdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The LayerDrop probability for the decoder. See the [LayerDrop paper](see <a href="https://arxiv.org/abs/1909.11556" rel="nofollow">https://arxiv.org/abs/1909.11556</a>)
for more details.`,name:"decoder_layerdrop"},{anchor:"transformers.TrOCRConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the model should return the last key/values attentions (not used by all models).`,name:"use_cache"},{anchor:"transformers.TrOCRConfig.scale_embedding",description:`<strong>scale_embedding</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to scale the word embeddings by sqrt(d_model).`,name:"scale_embedding"},{anchor:"transformers.TrOCRConfig.use_learned_position_embeddings",description:`<strong>use_learned_position_embeddings</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to use learned position embeddings. If not, sinusoidal position embeddings will be used.`,name:"use_learned_position_embeddings"},{anchor:"transformers.TrOCRConfig.layernorm_embedding",description:`<strong>layernorm_embedding</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to use a layernorm after the word + position embeddings.`,name:"layernorm_embedding"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/trocr/configuration_trocr.py#L31"}}),ue=new Ai({props:{anchor:"transformers.TrOCRConfig.example",$$slots:{default:[qi]},$$scope:{ctx:S}}}),ct=new Et({}),ht=new ne({props:{name:"class transformers.TrOCRProcessor",anchor:"transformers.TrOCRProcessor",parameters:[{name:"image_processor",val:" = None"},{name:"tokenizer",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TrOCRProcessor.image_processor",description:`<strong>image_processor</strong> ([<code>ViTImageProcessor</code>/<code>DeiTImageProcessor</code>]) &#x2014;
An instance of [<code>ViTImageProcessor</code>/<code>DeiTImageProcessor</code>]. The image processor is a required input.`,name:"image_processor"},{anchor:"transformers.TrOCRProcessor.tokenizer",description:`<strong>tokenizer</strong> ([<code>RobertaTokenizer</code>/<code>XLMRobertaTokenizer</code>]) &#x2014;
An instance of [<code>RobertaTokenizer</code>/<code>XLMRobertaTokenizer</code>]. The tokenizer is a required input.`,name:"tokenizer"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/trocr/processing_trocr.py#L24"}}),pt=new ne({props:{name:"__call__",anchor:"transformers.TrOCRProcessor.__call__",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/trocr/processing_trocr.py#L62"}}),ft=new ne({props:{name:"from_pretrained",anchor:"transformers.TrOCRProcessor.from_pretrained",parameters:[{name:"pretrained_model_name_or_path",val:": typing.Union[str, os.PathLike]"},{name:"cache_dir",val:": typing.Union[str, os.PathLike, NoneType] = None"},{name:"force_download",val:": bool = False"},{name:"local_files_only",val:": bool = False"},{name:"token",val:": typing.Union[bool, str, NoneType] = None"},{name:"revision",val:": str = 'main'"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TrOCRProcessor.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.33.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.33.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.33.0/src/transformers/processing_utils.py#L167"}}),Te=new Fi({props:{$$slots:{default:[Yi]},$$scope:{ctx:S}}}),ut=new ne({props:{name:"save_pretrained",anchor:"transformers.TrOCRProcessor.save_pretrained",parameters:[{name:"save_directory",val:""},{name:"push_to_hub",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TrOCRProcessor.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.TrOCRProcessor.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).`,name:"push_to_hub"},{anchor:"transformers.TrOCRProcessor.save_pretrained.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, Any]</code>, <em>optional</em>) &#x2014;
Additional key word arguments passed along to the <a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.push_to_hub">push_to_hub()</a> method.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/processing_utils.py#L93"}}),ve=new Fi({props:{$$slots:{default:[Qi]},$$scope:{ctx:S}}}),_t=new ne({props:{name:"batch_decode",anchor:"transformers.TrOCRProcessor.batch_decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/trocr/processing_trocr.py#L95"}}),vt=new ne({props:{name:"decode",anchor:"transformers.TrOCRProcessor.decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/trocr/processing_trocr.py#L102"}}),yt=new Et({}),wt=new ne({props:{name:"class transformers.TrOCRForCausalLM",anchor:"transformers.TrOCRForCausalLM",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.TrOCRForCausalLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/trocr#transformers.TrOCRConfig">TrOCRConfig</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.33.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.33.0/src/transformers/models/trocr/modeling_trocr.py#L790"}}),kt=new ne({props:{name:"forward",anchor:"transformers.TrOCRForCausalLM.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"encoder_hidden_states",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"cross_attn_head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = 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.TrOCRForCausalLM.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you
provide it.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.33.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.TrOCRForCausalLM.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TrOCRForCausalLM.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong>  (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention
if the model is configured as a decoder.`,name:"encoder_hidden_states"},{anchor:"transformers.TrOCRForCausalLM.forward.encoder_attention_mask",description:`<strong>encoder_attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on the padding token indices of the encoder input. This mask is used
in the cross-attention if the model is configured as a decoder. Mask values selected in <code>[0, 1]</code>:`,name:"encoder_attention_mask"},{anchor:"transformers.TrOCRForCausalLM.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.Tensor</code> of shape <code>(decoder_layers, decoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the 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.TrOCRForCausalLM.forward.cross_attn_head_mask",description:`<strong>cross_attn_head_mask</strong> (<code>torch.Tensor</code> of shape <code>(decoder_layers, decoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the cross-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:"cross_attn_head_mask"},{anchor:"transformers.TrOCRForCausalLM.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of
shape <code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and 2 additional tensors of
shape <code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>. The two additional
tensors are only required when the model is used as a decoder in a Sequence to Sequence model.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the
cross-attention blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those
that don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of
all <code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.TrOCRForCausalLM.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the masked language modeling loss. Indices should either be in <code>[0, ..., config.vocab_size]</code> or -100 (see <code>input_ids</code> docstring). Tokens with indices set to <code>-100</code> are ignored
(masked), the loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>.`,name:"labels"},{anchor:"transformers.TrOCRForCausalLM.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding
(see <code>past_key_values</code>).</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>`,name:"use_cache"},{anchor:"transformers.TrOCRForCausalLM.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.TrOCRForCausalLM.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.TrOCRForCausalLM.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.33.0/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.33.0/src/transformers/models/trocr/modeling_trocr.py#L823",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.33.0/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithCrossAttentions"
>transformers.modeling_outputs.CausalLMOutputWithCrossAttentions</a> 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.33.0/en/model_doc/trocr#transformers.TrOCRConfig"
>TrOCRConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Language modeling loss (for next-token prediction).</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</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, if the model has an embedding layer, +
one for the output of each layer) 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 optional 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 layer) 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>cross_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 layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Cross attentions weights after the attention softmax, used to compute the weighted average in the
cross-attention heads.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> tuples of length <code>config.n_layers</code>, with each tuple containing the cached key,
value states of the self-attention and the cross-attention layers if model is used in encoder-decoder
setting. Only relevant if <code>config.is_decoder = True</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.33.0/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithCrossAttentions"
>transformers.modeling_outputs.CausalLMOutputWithCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Me=new Ai({props:{anchor:"transformers.TrOCRForCausalLM.forward.example",$$slots:{default:[Hi]},$$scope:{ctx:S}}}),{c(){f=s("meta"),E=c(),u=s("h1"),g=s("a"),k=s("span"),T(p.$$.fragment),_=c(),z=s("span"),W=r("TrOCR"),j=c(),I=s("h2"),J=s("a"),Z=s("span"),T(D.$$.fragment),$t=c(),le=s("span"),Sr=r("Overview"),Vo=c(),X=s("p"),Dr=r("The TrOCR model was proposed in "),je=s("a"),Xr=r(`TrOCR: Transformer-based Optical Character Recognition with Pre-trained
Models`),Gr=r(` by Minghao Li, Tengchao Lv, Lei Cui, Yijuan Lu, Dinei Florencio, Cha Zhang,
Zhoujun Li, Furu Wei. TrOCR consists of an image Transformer encoder and an autoregressive text Transformer decoder to
perform `),Je=s("a"),qr=r("optical character recognition (OCR)"),Yr=r("."),Bo=c(),Ot=s("p"),Qr=r("The abstract from the paper is the following:"),So=c(),jt=s("p"),no=s("em"),Hr=r(`Text recognition is a long-standing research problem for document digitalization. Existing approaches for text recognition
are usually built based on CNN for image understanding and RNN for char-level text generation. In addition, another language
model is usually needed to improve the overall accuracy as a post-processing step. In this paper, we propose an end-to-end
text recognition approach with pre-trained image Transformer and text Transformer models, namely TrOCR, which leverages the
Transformer architecture for both image understanding and wordpiece-level text generation. The TrOCR model is simple but
effective, and can be pre-trained with large-scale synthetic data and fine-tuned with human-labeled datasets. Experiments
show that the TrOCR model outperforms the current state-of-the-art models on both printed and handwritten text recognition
tasks.`),Do=c(),ie=s("img"),Xo=c(),de=s("small"),Kr=r("TrOCR architecture. Taken from the "),Jt=s("a"),ea=r("original paper"),ta=r("."),Go=c(),ce=s("p"),oa=r("Please refer to the "),lo=s("code"),ra=r("VisionEncoderDecoder"),aa=r(" class on how to use this model."),qo=c(),G=s("p"),sa=r("This model was contributed by "),Ie=s("a"),na=r("nielsr"),la=r(`. The original code can be found
`),Ze=s("a"),ia=r("here"),da=r("."),Yo=c(),It=s("p"),ca=r("Tips:"),Qo=c(),q=s("ul"),xe=s("li"),ha=r("The quickest way to get started with TrOCR is by checking the "),Ue=s("a"),ma=r(`tutorial
notebooks`),pa=r(`, which show how to use the model
at inference time as well as fine-tuning on custom data.`),fa=c(),L=s("li"),ua=r(`TrOCR is pre-trained in 2 stages before being fine-tuned on downstream datasets. It achieves state-of-the-art results
on both printed (e.g. the `),We=s("a"),ga=r("SROIE dataset"),_a=r(" and handwritten (e.g. the "),Pe=s("a"),Ta=r(`IAM
Handwriting dataset`),va=r(` text recognition tasks. For more
information, see the `),ze=s("a"),ba=r("official models"),ya=r("."),wa=c(),Fe=s("li"),Ca=r("TrOCR is always used within the "),Zt=s("a"),Ma=r("VisionEncoderDecoder"),ka=r(" framework."),Ho=c(),K=s("h2"),he=s("a"),io=s("span"),T(Ae.$$.fragment),Ra=c(),co=s("span"),Ea=r("Resources"),Ko=c(),xt=s("p"),$a=r("A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started with TrOCR. If you\u2019re interested in submitting a resource to be included here, please feel free to open a Pull Request and we\u2019ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource."),er=c(),T(Ne.$$.fragment),tr=c(),x=s("ul"),Le=s("li"),Oa=r("A blog post on "),Ve=s("a"),ja=r("Accelerating Document AI"),Ja=r(" with TrOCR."),Ia=c(),Be=s("li"),Za=r("A blog post on how to "),Se=s("a"),xa=r("Document AI"),Ua=r(" with TrOCR."),Wa=c(),De=s("li"),Pa=r("A notebook on how to "),Xe=s("a"),za=r("finetune TrOCR on IAM Handwriting Database using Seq2SeqTrainer"),Fa=r("."),Aa=c(),Ge=s("li"),Na=r("A notebook on "),qe=s("a"),La=r("inference with TrOCR"),Va=r(" and Gradio demo."),Ba=c(),Ye=s("li"),Sa=r("A notebook on "),Qe=s("a"),Da=r("finetune TrOCR on the IAM Handwriting Database"),Xa=r(" using native PyTorch."),Ga=c(),He=s("li"),qa=r("A notebook on "),Ke=s("a"),Ya=r("evaluating TrOCR on the IAM test set"),Qa=r("."),or=c(),T(et.$$.fragment),rr=c(),Ut=s("ul"),Wt=s("li"),tt=s("a"),Ha=r("Casual language modeling"),Ka=r(" task guide."),ar=c(),Pt=s("p"),es=r("\u26A1\uFE0F Inference"),sr=c(),zt=s("ul"),ot=s("li"),ts=r("An interactive-demo on "),rt=s("a"),os=r("TrOCR handwritten character recognition"),rs=r("."),nr=c(),ee=s("h2"),me=s("a"),ho=s("span"),T(at.$$.fragment),as=c(),mo=s("span"),ss=r("Inference"),lr=c(),Y=s("p"),ns=r("TrOCR\u2019s "),po=s("code"),ls=r("VisionEncoderDecoder"),is=r(` model accepts images as input and makes use of
`),Ft=s("a"),ds=r("generate()"),cs=r(" to autoregressively generate text given the input image."),ir=c(),M=s("p"),hs=r("The ["),fo=s("code"),ms=r("ViTImageProcessor"),ps=r("/"),uo=s("code"),fs=r("DeiTImageProcessor"),us=r(`] class is responsible for preprocessing the input image and
[`),go=s("code"),gs=r("RobertaTokenizer"),_s=r("/"),_o=s("code"),Ts=r("XLMRobertaTokenizer"),vs=r(`] decodes the generated target tokens to the target string. The
`),At=s("a"),bs=r("TrOCRProcessor"),ys=r(" wraps ["),To=s("code"),ws=r("ViTImageProcessor"),Cs=r("/"),vo=s("code"),Ms=r("DeiTImageProcessor"),ks=r("] and ["),bo=s("code"),Rs=r("RobertaTokenizer"),Es=r("/"),yo=s("code"),$s=r("XLMRobertaTokenizer"),Os=r(`]
into a single instance to both extract the input features and decode the predicted token ids.`),dr=c(),Nt=s("ul"),wo=s("li"),js=r("Step-by-step Optical Character Recognition (OCR)"),cr=c(),T(st.$$.fragment),hr=c(),pe=s("p"),Js=r("See the "),nt=s("a"),Is=r("model hub"),Zs=r(" to look for TrOCR checkpoints."),mr=c(),te=s("h2"),fe=s("a"),Co=s("span"),T(lt.$$.fragment),xs=c(),Mo=s("span"),Us=r("TrOCRConfig"),pr=c(),F=s("div"),T(it.$$.fragment),Ws=c(),oe=s("p"),Ps=r("This is the configuration class to store the configuration of a "),Lt=s("a"),zs=r("TrOCRForCausalLM"),Fs=r(`. It is used to instantiate an
TrOCR 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 TrOCR
`),dt=s("a"),As=r("microsoft/trocr-base-handwritten"),Ns=r(" architecture."),Ls=c(),re=s("p"),Vs=r("Configuration objects inherit from "),Vt=s("a"),Bs=r("PretrainedConfig"),Ss=r(` and can be used to control the model outputs. Read the
documentation from `),Bt=s("a"),Ds=r("PretrainedConfig"),Xs=r(" for more information."),Gs=c(),T(ue.$$.fragment),fr=c(),ae=s("h2"),ge=s("a"),ko=s("span"),T(ct.$$.fragment),qs=c(),Ro=s("span"),Ys=r("TrOCRProcessor"),ur=c(),R=s("div"),T(ht.$$.fragment),Qs=c(),Eo=s("p"),Hs=r("Constructs a TrOCR processor which wraps a vision image processor and a TrOCR tokenizer into a single processor."),Ks=c(),O=s("p"),St=s("a"),en=r("TrOCRProcessor"),tn=r(" offers all the functionalities of ["),$o=s("code"),on=r("ViTImageProcessor"),rn=r("/"),Oo=s("code"),an=r("DeiTImageProcessor"),sn=r(`] and
[`),jo=s("code"),nn=r("RobertaTokenizer"),ln=r("/"),Jo=s("code"),dn=r("XLMRobertaTokenizer"),cn=r("]. See the "),mt=s("a"),Io=s("strong"),hn=r("call"),mn=r("()"),pn=r(" and "),Dt=s("a"),fn=r("decode()"),un=r(` for
more information.`),gn=c(),_e=s("div"),T(pt.$$.fragment),_n=c(),V=s("p"),Tn=r(`When used in normal mode, this method forwards all its arguments to AutoImageProcessor\u2019s
`),Zo=s("code"),vn=r("__call__()"),bn=r(` and returns its output. If used in the context
`),xo=s("code"),yn=r("as_target_processor()"),wn=r(` this method forwards all its arguments to TrOCRTokenizer\u2019s
`),Uo=s("code"),Cn=r("~TrOCRTokenizer.__call__"),Mn=r(". Please refer to the doctsring of the above two methods for more information."),kn=c(),Q=s("div"),T(ft.$$.fragment),Rn=c(),Wo=s("p"),En=r("Instantiate a processor associated with a pretrained model."),$n=c(),T(Te.$$.fragment),On=c(),H=s("div"),T(ut.$$.fragment),jn=c(),gt=s("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 `),Xt=s("a"),In=r("from_pretrained()"),Zn=r(" method."),xn=c(),T(ve.$$.fragment),Un=c(),be=s("div"),T(_t.$$.fragment),Wn=c(),Tt=s("p"),Pn=r("This method forwards all its arguments to TrOCRTokenizer\u2019s "),Gt=s("a"),zn=r("batch_decode()"),Fn=r(`. Please refer
to the docstring of this method for more information.`),An=c(),ye=s("div"),T(vt.$$.fragment),Nn=c(),bt=s("p"),Ln=r("This method forwards all its arguments to TrOCRTokenizer\u2019s "),qt=s("a"),Vn=r("decode()"),Bn=r(`. Please refer to the
docstring of this method for more information.`),gr=c(),se=s("h2"),we=s("a"),Po=s("span"),T(yt.$$.fragment),Sn=c(),zo=s("span"),Dn=r("TrOCRForCausalLM"),_r=c(),A=s("div"),T(wt.$$.fragment),Xn=c(),B=s("p"),Gn=r("The TrOCR Decoder with a language modeling head. Can be used as the decoder part of "),Yt=s("a"),qn=r("EncoderDecoderModel"),Yn=r(" and "),Fo=s("code"),Qn=r("VisionEncoderDecoder"),Hn=r(`.
This model inherits from `),Qt=s("a"),Kn=r("PreTrainedModel"),el=r(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),tl=c(),Ct=s("p"),ol=r("This model is also a PyTorch "),Mt=s("a"),rl=r("torch.nn.Module"),al=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),sl=c(),Ce=s("div"),T(kt.$$.fragment),nl=c(),T(Me.$$.fragment),this.h()},l(t){const d=Di('[data-svelte="svelte-1phssyn"]',document.head);f=n(d,"META",{name:!0,content:!0}),d.forEach(o),E=h(t),u=n(t,"H1",{class:!0});var Rt=l(u);g=n(Rt,"A",{id:!0,class:!0,href:!0});var Ao=l(g);k=n(Ao,"SPAN",{});var No=l(k);v(p.$$.fragment,No),No.forEach(o),Ao.forEach(o),_=h(Rt),z=n(Rt,"SPAN",{});var Lo=l(z);W=a(Lo,"TrOCR"),Lo.forEach(o),Rt.forEach(o),j=h(t),I=n(t,"H2",{class:!0});var vr=l(I);J=n(vr,"A",{id:!0,class:!0,href:!0});var hl=l(J);Z=n(hl,"SPAN",{});var ml=l(Z);v(D.$$.fragment,ml),ml.forEach(o),hl.forEach(o),$t=h(vr),le=n(vr,"SPAN",{});var pl=l(le);Sr=a(pl,"Overview"),pl.forEach(o),vr.forEach(o),Vo=h(t),X=n(t,"P",{});var Ht=l(X);Dr=a(Ht,"The TrOCR model was proposed in "),je=n(Ht,"A",{href:!0,rel:!0});var fl=l(je);Xr=a(fl,`TrOCR: Transformer-based Optical Character Recognition with Pre-trained
Models`),fl.forEach(o),Gr=a(Ht,` by Minghao Li, Tengchao Lv, Lei Cui, Yijuan Lu, Dinei Florencio, Cha Zhang,
Zhoujun Li, Furu Wei. TrOCR consists of an image Transformer encoder and an autoregressive text Transformer decoder to
perform `),Je=n(Ht,"A",{href:!0,rel:!0});var ul=l(Je);qr=a(ul,"optical character recognition (OCR)"),ul.forEach(o),Yr=a(Ht,"."),Ht.forEach(o),Bo=h(t),Ot=n(t,"P",{});var gl=l(Ot);Qr=a(gl,"The abstract from the paper is the following:"),gl.forEach(o),So=h(t),jt=n(t,"P",{});var _l=l(jt);no=n(_l,"EM",{});var Tl=l(no);Hr=a(Tl,`Text recognition is a long-standing research problem for document digitalization. Existing approaches for text recognition
are usually built based on CNN for image understanding and RNN for char-level text generation. In addition, another language
model is usually needed to improve the overall accuracy as a post-processing step. In this paper, we propose an end-to-end
text recognition approach with pre-trained image Transformer and text Transformer models, namely TrOCR, which leverages the
Transformer architecture for both image understanding and wordpiece-level text generation. The TrOCR model is simple but
effective, and can be pre-trained with large-scale synthetic data and fine-tuned with human-labeled datasets. Experiments
show that the TrOCR model outperforms the current state-of-the-art models on both printed and handwritten text recognition
tasks.`),Tl.forEach(o),_l.forEach(o),Do=h(t),ie=n(t,"IMG",{src:!0,alt:!0,width:!0}),Xo=h(t),de=n(t,"SMALL",{});var br=l(de);Kr=a(br,"TrOCR architecture. Taken from the "),Jt=n(br,"A",{href:!0});var vl=l(Jt);ea=a(vl,"original paper"),vl.forEach(o),ta=a(br,"."),br.forEach(o),Go=h(t),ce=n(t,"P",{});var yr=l(ce);oa=a(yr,"Please refer to the "),lo=n(yr,"CODE",{});var bl=l(lo);ra=a(bl,"VisionEncoderDecoder"),bl.forEach(o),aa=a(yr," class on how to use this model."),yr.forEach(o),qo=h(t),G=n(t,"P",{});var Kt=l(G);sa=a(Kt,"This model was contributed by "),Ie=n(Kt,"A",{href:!0,rel:!0});var yl=l(Ie);na=a(yl,"nielsr"),yl.forEach(o),la=a(Kt,`. The original code can be found
`),Ze=n(Kt,"A",{href:!0,rel:!0});var wl=l(Ze);ia=a(wl,"here"),wl.forEach(o),da=a(Kt,"."),Kt.forEach(o),Yo=h(t),It=n(t,"P",{});var Cl=l(It);ca=a(Cl,"Tips:"),Cl.forEach(o),Qo=h(t),q=n(t,"UL",{});var eo=l(q);xe=n(eo,"LI",{});var wr=l(xe);ha=a(wr,"The quickest way to get started with TrOCR is by checking the "),Ue=n(wr,"A",{href:!0,rel:!0});var Ml=l(Ue);ma=a(Ml,`tutorial
notebooks`),Ml.forEach(o),pa=a(wr,`, which show how to use the model
at inference time as well as fine-tuning on custom data.`),wr.forEach(o),fa=h(eo),L=n(eo,"LI",{});var ke=l(L);ua=a(ke,`TrOCR is pre-trained in 2 stages before being fine-tuned on downstream datasets. It achieves state-of-the-art results
on both printed (e.g. the `),We=n(ke,"A",{href:!0,rel:!0});var kl=l(We);ga=a(kl,"SROIE dataset"),kl.forEach(o),_a=a(ke," and handwritten (e.g. the "),Pe=n(ke,"A",{href:!0,rel:!0});var Rl=l(Pe);Ta=a(Rl,`IAM
Handwriting dataset`),Rl.forEach(o),va=a(ke,` text recognition tasks. For more
information, see the `),ze=n(ke,"A",{href:!0,rel:!0});var El=l(ze);ba=a(El,"official models"),El.forEach(o),ya=a(ke,"."),ke.forEach(o),wa=h(eo),Fe=n(eo,"LI",{});var Cr=l(Fe);Ca=a(Cr,"TrOCR is always used within the "),Zt=n(Cr,"A",{href:!0});var $l=l(Zt);Ma=a($l,"VisionEncoderDecoder"),$l.forEach(o),ka=a(Cr," framework."),Cr.forEach(o),eo.forEach(o),Ho=h(t),K=n(t,"H2",{class:!0});var Mr=l(K);he=n(Mr,"A",{id:!0,class:!0,href:!0});var Ol=l(he);io=n(Ol,"SPAN",{});var jl=l(io);v(Ae.$$.fragment,jl),jl.forEach(o),Ol.forEach(o),Ra=h(Mr),co=n(Mr,"SPAN",{});var Jl=l(co);Ea=a(Jl,"Resources"),Jl.forEach(o),Mr.forEach(o),Ko=h(t),xt=n(t,"P",{});var Il=l(xt);$a=a(Il,"A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started with TrOCR. If you\u2019re interested in submitting a resource to be included here, please feel free to open a Pull Request and we\u2019ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource."),Il.forEach(o),er=h(t),v(Ne.$$.fragment,t),tr=h(t),x=n(t,"UL",{});var N=l(x);Le=n(N,"LI",{});var kr=l(Le);Oa=a(kr,"A blog post on "),Ve=n(kr,"A",{href:!0,rel:!0});var Zl=l(Ve);ja=a(Zl,"Accelerating Document AI"),Zl.forEach(o),Ja=a(kr," with TrOCR."),kr.forEach(o),Ia=h(N),Be=n(N,"LI",{});var Rr=l(Be);Za=a(Rr,"A blog post on how to "),Se=n(Rr,"A",{href:!0,rel:!0});var xl=l(Se);xa=a(xl,"Document AI"),xl.forEach(o),Ua=a(Rr," with TrOCR."),Rr.forEach(o),Wa=h(N),De=n(N,"LI",{});var Er=l(De);Pa=a(Er,"A notebook on how to "),Xe=n(Er,"A",{href:!0,rel:!0});var Ul=l(Xe);za=a(Ul,"finetune TrOCR on IAM Handwriting Database using Seq2SeqTrainer"),Ul.forEach(o),Fa=a(Er,"."),Er.forEach(o),Aa=h(N),Ge=n(N,"LI",{});var $r=l(Ge);Na=a($r,"A notebook on "),qe=n($r,"A",{href:!0,rel:!0});var Wl=l(qe);La=a(Wl,"inference with TrOCR"),Wl.forEach(o),Va=a($r," and Gradio demo."),$r.forEach(o),Ba=h(N),Ye=n(N,"LI",{});var Or=l(Ye);Sa=a(Or,"A notebook on "),Qe=n(Or,"A",{href:!0,rel:!0});var Pl=l(Qe);Da=a(Pl,"finetune TrOCR on the IAM Handwriting Database"),Pl.forEach(o),Xa=a(Or," using native PyTorch."),Or.forEach(o),Ga=h(N),He=n(N,"LI",{});var jr=l(He);qa=a(jr,"A notebook on "),Ke=n(jr,"A",{href:!0,rel:!0});var zl=l(Ke);Ya=a(zl,"evaluating TrOCR on the IAM test set"),zl.forEach(o),Qa=a(jr,"."),jr.forEach(o),N.forEach(o),or=h(t),v(et.$$.fragment,t),rr=h(t),Ut=n(t,"UL",{});var Fl=l(Ut);Wt=n(Fl,"LI",{});var ll=l(Wt);tt=n(ll,"A",{href:!0,rel:!0});var Al=l(tt);Ha=a(Al,"Casual language modeling"),Al.forEach(o),Ka=a(ll," task guide."),ll.forEach(o),Fl.forEach(o),ar=h(t),Pt=n(t,"P",{});var Nl=l(Pt);es=a(Nl,"\u26A1\uFE0F Inference"),Nl.forEach(o),sr=h(t),zt=n(t,"UL",{});var Ll=l(zt);ot=n(Ll,"LI",{});var Jr=l(ot);ts=a(Jr,"An interactive-demo on "),rt=n(Jr,"A",{href:!0,rel:!0});var Vl=l(rt);os=a(Vl,"TrOCR handwritten character recognition"),Vl.forEach(o),rs=a(Jr,"."),Jr.forEach(o),Ll.forEach(o),nr=h(t),ee=n(t,"H2",{class:!0});var Ir=l(ee);me=n(Ir,"A",{id:!0,class:!0,href:!0});var Bl=l(me);ho=n(Bl,"SPAN",{});var Sl=l(ho);v(at.$$.fragment,Sl),Sl.forEach(o),Bl.forEach(o),as=h(Ir),mo=n(Ir,"SPAN",{});var Dl=l(mo);ss=a(Dl,"Inference"),Dl.forEach(o),Ir.forEach(o),lr=h(t),Y=n(t,"P",{});var to=l(Y);ns=a(to,"TrOCR\u2019s "),po=n(to,"CODE",{});var Xl=l(po);ls=a(Xl,"VisionEncoderDecoder"),Xl.forEach(o),is=a(to,` model accepts images as input and makes use of
`),Ft=n(to,"A",{href:!0});var Gl=l(Ft);ds=a(Gl,"generate()"),Gl.forEach(o),cs=a(to," to autoregressively generate text given the input image."),to.forEach(o),ir=h(t),M=n(t,"P",{});var $=l(M);hs=a($,"The ["),fo=n($,"CODE",{});var ql=l(fo);ms=a(ql,"ViTImageProcessor"),ql.forEach(o),ps=a($,"/"),uo=n($,"CODE",{});var Yl=l(uo);fs=a(Yl,"DeiTImageProcessor"),Yl.forEach(o),us=a($,`] class is responsible for preprocessing the input image and
[`),go=n($,"CODE",{});var Ql=l(go);gs=a(Ql,"RobertaTokenizer"),Ql.forEach(o),_s=a($,"/"),_o=n($,"CODE",{});var Hl=l(_o);Ts=a(Hl,"XLMRobertaTokenizer"),Hl.forEach(o),vs=a($,`] decodes the generated target tokens to the target string. The
`),At=n($,"A",{href:!0});var Kl=l(At);bs=a(Kl,"TrOCRProcessor"),Kl.forEach(o),ys=a($," wraps ["),To=n($,"CODE",{});var ei=l(To);ws=a(ei,"ViTImageProcessor"),ei.forEach(o),Cs=a($,"/"),vo=n($,"CODE",{});var ti=l(vo);Ms=a(ti,"DeiTImageProcessor"),ti.forEach(o),ks=a($,"] and ["),bo=n($,"CODE",{});var oi=l(bo);Rs=a(oi,"RobertaTokenizer"),oi.forEach(o),Es=a($,"/"),yo=n($,"CODE",{});var ri=l(yo);$s=a(ri,"XLMRobertaTokenizer"),ri.forEach(o),Os=a($,`]
into a single instance to both extract the input features and decode the predicted token ids.`),$.forEach(o),dr=h(t),Nt=n(t,"UL",{});var ai=l(Nt);wo=n(ai,"LI",{});var si=l(wo);js=a(si,"Step-by-step Optical Character Recognition (OCR)"),si.forEach(o),ai.forEach(o),cr=h(t),v(st.$$.fragment,t),hr=h(t),pe=n(t,"P",{});var Zr=l(pe);Js=a(Zr,"See the "),nt=n(Zr,"A",{href:!0,rel:!0});var ni=l(nt);Is=a(ni,"model hub"),ni.forEach(o),Zs=a(Zr," to look for TrOCR checkpoints."),Zr.forEach(o),mr=h(t),te=n(t,"H2",{class:!0});var xr=l(te);fe=n(xr,"A",{id:!0,class:!0,href:!0});var li=l(fe);Co=n(li,"SPAN",{});var ii=l(Co);v(lt.$$.fragment,ii),ii.forEach(o),li.forEach(o),xs=h(xr),Mo=n(xr,"SPAN",{});var di=l(Mo);Us=a(di,"TrOCRConfig"),di.forEach(o),xr.forEach(o),pr=h(t),F=n(t,"DIV",{class:!0});var Re=l(F);v(it.$$.fragment,Re),Ws=h(Re),oe=n(Re,"P",{});var oo=l(oe);Ps=a(oo,"This is the configuration class to store the configuration of a "),Lt=n(oo,"A",{href:!0});var ci=l(Lt);zs=a(ci,"TrOCRForCausalLM"),ci.forEach(o),Fs=a(oo,`. It is used to instantiate an
TrOCR 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 TrOCR
`),dt=n(oo,"A",{href:!0,rel:!0});var hi=l(dt);As=a(hi,"microsoft/trocr-base-handwritten"),hi.forEach(o),Ns=a(oo," architecture."),oo.forEach(o),Ls=h(Re),re=n(Re,"P",{});var ro=l(re);Vs=a(ro,"Configuration objects inherit from "),Vt=n(ro,"A",{href:!0});var mi=l(Vt);Bs=a(mi,"PretrainedConfig"),mi.forEach(o),Ss=a(ro,` and can be used to control the model outputs. Read the
documentation from `),Bt=n(ro,"A",{href:!0});var pi=l(Bt);Ds=a(pi,"PretrainedConfig"),pi.forEach(o),Xs=a(ro," for more information."),ro.forEach(o),Gs=h(Re),v(ue.$$.fragment,Re),Re.forEach(o),fr=h(t),ae=n(t,"H2",{class:!0});var Ur=l(ae);ge=n(Ur,"A",{id:!0,class:!0,href:!0});var fi=l(ge);ko=n(fi,"SPAN",{});var ui=l(ko);v(ct.$$.fragment,ui),ui.forEach(o),fi.forEach(o),qs=h(Ur),Ro=n(Ur,"SPAN",{});var gi=l(Ro);Ys=a(gi,"TrOCRProcessor"),gi.forEach(o),Ur.forEach(o),ur=h(t),R=n(t,"DIV",{class:!0});var U=l(R);v(ht.$$.fragment,U),Qs=h(U),Eo=n(U,"P",{});var _i=l(Eo);Hs=a(_i,"Constructs a TrOCR processor which wraps a vision image processor and a TrOCR tokenizer into a single processor."),_i.forEach(o),Ks=h(U),O=n(U,"P",{});var P=l(O);St=n(P,"A",{href:!0});var Ti=l(St);en=a(Ti,"TrOCRProcessor"),Ti.forEach(o),tn=a(P," offers all the functionalities of ["),$o=n(P,"CODE",{});var vi=l($o);on=a(vi,"ViTImageProcessor"),vi.forEach(o),rn=a(P,"/"),Oo=n(P,"CODE",{});var bi=l(Oo);an=a(bi,"DeiTImageProcessor"),bi.forEach(o),sn=a(P,`] and
[`),jo=n(P,"CODE",{});var yi=l(jo);nn=a(yi,"RobertaTokenizer"),yi.forEach(o),ln=a(P,"/"),Jo=n(P,"CODE",{});var wi=l(Jo);dn=a(wi,"XLMRobertaTokenizer"),wi.forEach(o),cn=a(P,"]. See the "),mt=n(P,"A",{href:!0});var il=l(mt);Io=n(il,"STRONG",{});var Ci=l(Io);hn=a(Ci,"call"),Ci.forEach(o),mn=a(il,"()"),il.forEach(o),pn=a(P," and "),Dt=n(P,"A",{href:!0});var Mi=l(Dt);fn=a(Mi,"decode()"),Mi.forEach(o),un=a(P,` for
more information.`),P.forEach(o),gn=h(U),_e=n(U,"DIV",{class:!0});var Wr=l(_e);v(pt.$$.fragment,Wr),_n=h(Wr),V=n(Wr,"P",{});var Ee=l(V);Tn=a(Ee,`When used in normal mode, this method forwards all its arguments to AutoImageProcessor\u2019s
`),Zo=n(Ee,"CODE",{});var ki=l(Zo);vn=a(ki,"__call__()"),ki.forEach(o),bn=a(Ee,` and returns its output. If used in the context
`),xo=n(Ee,"CODE",{});var Ri=l(xo);yn=a(Ri,"as_target_processor()"),Ri.forEach(o),wn=a(Ee,` this method forwards all its arguments to TrOCRTokenizer\u2019s
`),Uo=n(Ee,"CODE",{});var Ei=l(Uo);Cn=a(Ei,"~TrOCRTokenizer.__call__"),Ei.forEach(o),Mn=a(Ee,". Please refer to the doctsring of the above two methods for more information."),Ee.forEach(o),Wr.forEach(o),kn=h(U),Q=n(U,"DIV",{class:!0});var ao=l(Q);v(ft.$$.fragment,ao),Rn=h(ao),Wo=n(ao,"P",{});var $i=l(Wo);En=a($i,"Instantiate a processor associated with a pretrained model."),$i.forEach(o),$n=h(ao),v(Te.$$.fragment,ao),ao.forEach(o),On=h(U),H=n(U,"DIV",{class:!0});var so=l(H);v(ut.$$.fragment,so),jn=h(so),gt=n(so,"P",{});var Pr=l(gt);Jn=a(Pr,`Saves the attributes of this processor (feature extractor, tokenizer\u2026) in the specified directory so that it
can be reloaded using the `),Xt=n(Pr,"A",{href:!0});var Oi=l(Xt);In=a(Oi,"from_pretrained()"),Oi.forEach(o),Zn=a(Pr," method."),Pr.forEach(o),xn=h(so),v(ve.$$.fragment,so),so.forEach(o),Un=h(U),be=n(U,"DIV",{class:!0});var zr=l(be);v(_t.$$.fragment,zr),Wn=h(zr),Tt=n(zr,"P",{});var Fr=l(Tt);Pn=a(Fr,"This method forwards all its arguments to TrOCRTokenizer\u2019s "),Gt=n(Fr,"A",{href:!0});var ji=l(Gt);zn=a(ji,"batch_decode()"),ji.forEach(o),Fn=a(Fr,`. Please refer
to the docstring of this method for more information.`),Fr.forEach(o),zr.forEach(o),An=h(U),ye=n(U,"DIV",{class:!0});var Ar=l(ye);v(vt.$$.fragment,Ar),Nn=h(Ar),bt=n(Ar,"P",{});var Nr=l(bt);Ln=a(Nr,"This method forwards all its arguments to TrOCRTokenizer\u2019s "),qt=n(Nr,"A",{href:!0});var Ji=l(qt);Vn=a(Ji,"decode()"),Ji.forEach(o),Bn=a(Nr,`. Please refer to the
docstring of this method for more information.`),Nr.forEach(o),Ar.forEach(o),U.forEach(o),gr=h(t),se=n(t,"H2",{class:!0});var Lr=l(se);we=n(Lr,"A",{id:!0,class:!0,href:!0});var Ii=l(we);Po=n(Ii,"SPAN",{});var Zi=l(Po);v(yt.$$.fragment,Zi),Zi.forEach(o),Ii.forEach(o),Sn=h(Lr),zo=n(Lr,"SPAN",{});var xi=l(zo);Dn=a(xi,"TrOCRForCausalLM"),xi.forEach(o),Lr.forEach(o),_r=h(t),A=n(t,"DIV",{class:!0});var $e=l(A);v(wt.$$.fragment,$e),Xn=h($e),B=n($e,"P",{});var Oe=l(B);Gn=a(Oe,"The TrOCR Decoder with a language modeling head. Can be used as the decoder part of "),Yt=n(Oe,"A",{href:!0});var Ui=l(Yt);qn=a(Ui,"EncoderDecoderModel"),Ui.forEach(o),Yn=a(Oe," and "),Fo=n(Oe,"CODE",{});var Wi=l(Fo);Qn=a(Wi,"VisionEncoderDecoder"),Wi.forEach(o),Hn=a(Oe,`.
This model inherits from `),Qt=n(Oe,"A",{href:!0});var Pi=l(Qt);Kn=a(Pi,"PreTrainedModel"),Pi.forEach(o),el=a(Oe,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Oe.forEach(o),tl=h($e),Ct=n($e,"P",{});var Vr=l(Ct);ol=a(Vr,"This model is also a PyTorch "),Mt=n(Vr,"A",{href:!0,rel:!0});var zi=l(Mt);rl=a(zi,"torch.nn.Module"),zi.forEach(o),al=a(Vr,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Vr.forEach(o),sl=h($e),Ce=n($e,"DIV",{class:!0});var Br=l(Ce);v(kt.$$.fragment,Br),nl=h(Br),v(Me.$$.fragment,Br),Br.forEach(o),$e.forEach(o),this.h()},h(){i(f,"name","hf:doc:metadata"),i(f,"content",JSON.stringify(ed)),i(g,"id","trocr"),i(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"),i(g,"href","#trocr"),i(u,"class","relative group"),i(J,"id","overview"),i(J,"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"),i(J,"href","#overview"),i(I,"class","relative group"),i(je,"href","https://arxiv.org/abs/2109.10282"),i(je,"rel","nofollow"),i(Je,"href","https://en.wikipedia.org/wiki/Optical_character_recognition"),i(Je,"rel","nofollow"),Xi(ie.src,cl="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/trocr_architecture.jpg")||i(ie,"src",cl),i(ie,"alt","drawing"),i(ie,"width","600"),i(Jt,"href","https://arxiv.org/abs/2109.10282"),i(Ie,"href","https://huggingface.co/nielsr"),i(Ie,"rel","nofollow"),i(Ze,"href","https://github.com/microsoft/unilm/tree/6f60612e7cc86a2a1ae85c47231507a587ab4e01/trocr"),i(Ze,"rel","nofollow"),i(Ue,"href","https://github.com/NielsRogge/Transformers-Tutorials/tree/master/TrOCR"),i(Ue,"rel","nofollow"),i(We,"href","https://paperswithcode.com/dataset/sroie"),i(We,"rel","nofollow"),i(Pe,"href","https://fki.tic.heia-fr.ch/databases/iam-handwriting-database%3E"),i(Pe,"rel","nofollow"),i(ze,"href","https://huggingface.co/models?other=trocr%3E"),i(ze,"rel","nofollow"),i(Zt,"href","vision-encoder-decoder"),i(he,"id","resources"),i(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"),i(he,"href","#resources"),i(K,"class","relative group"),i(Ve,"href","https://huggingface.co/blog/document-ai"),i(Ve,"rel","nofollow"),i(Se,"href","https://github.com/philschmid/document-ai-transformers"),i(Se,"rel","nofollow"),i(Xe,"href","https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/TrOCR/Fine_tune_TrOCR_on_IAM_Handwriting_Database_using_Seq2SeqTrainer.ipynb"),i(Xe,"rel","nofollow"),i(qe,"href","https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/TrOCR/Inference_with_TrOCR_%2B_Gradio_demo.ipynb"),i(qe,"rel","nofollow"),i(Qe,"href","https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/TrOCR/Fine_tune_TrOCR_on_IAM_Handwriting_Database_using_native_PyTorch.ipynb"),i(Qe,"rel","nofollow"),i(Ke,"href","https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/TrOCR/Evaluating_TrOCR_base_handwritten_on_the_IAM_test_set.ipynb"),i(Ke,"rel","nofollow"),i(tt,"href","https://huggingface.co/docs/transformers/tasks/language_modeling"),i(tt,"rel","nofollow"),i(rt,"href","https://huggingface.co/spaces/nielsr/TrOCR-handwritten"),i(rt,"rel","nofollow"),i(me,"id","inference"),i(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"),i(me,"href","#inference"),i(ee,"class","relative group"),i(Ft,"href","/docs/transformers/v4.33.0/en/main_classes/text_generation#transformers.GenerationMixin.generate"),i(At,"href","/docs/transformers/v4.33.0/en/model_doc/trocr#transformers.TrOCRProcessor"),i(nt,"href","https://huggingface.co/models?filter=trocr"),i(nt,"rel","nofollow"),i(fe,"id","transformers.TrOCRConfig"),i(fe,"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"),i(fe,"href","#transformers.TrOCRConfig"),i(te,"class","relative group"),i(Lt,"href","/docs/transformers/v4.33.0/en/model_doc/trocr#transformers.TrOCRForCausalLM"),i(dt,"href","https://huggingface.co/microsoft/trocr-base-handwritten"),i(dt,"rel","nofollow"),i(Vt,"href","/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig"),i(Bt,"href","/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig"),i(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(ge,"id","transformers.TrOCRProcessor"),i(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"),i(ge,"href","#transformers.TrOCRProcessor"),i(ae,"class","relative group"),i(St,"href","/docs/transformers/v4.33.0/en/model_doc/trocr#transformers.TrOCRProcessor"),i(mt,"href","/docs/transformers/v4.33.0/en/model_doc/trocr#transformers.TrOCRProcessor.__call__"),i(Dt,"href","/docs/transformers/v4.33.0/en/model_doc/trocr#transformers.TrOCRProcessor.decode"),i(_e,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Xt,"href","/docs/transformers/v4.33.0/en/model_doc/donut#transformers.DonutProcessor.from_pretrained"),i(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Gt,"href","/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.batch_decode"),i(be,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(qt,"href","/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.decode"),i(ye,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(we,"id","transformers.TrOCRForCausalLM"),i(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"),i(we,"href","#transformers.TrOCRForCausalLM"),i(se,"class","relative group"),i(Yt,"href","/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),i(Qt,"href","/docs/transformers/v4.33.0/en/main_classes/model#transformers.PreTrainedModel"),i(Mt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),i(Mt,"rel","nofollow"),i(Ce,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(A,"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,f),m(t,E,d),m(t,u,d),e(u,g),e(g,k),b(p,k,null),e(u,_),e(u,z),e(z,W),m(t,j,d),m(t,I,d),e(I,J),e(J,Z),b(D,Z,null),e(I,$t),e(I,le),e(le,Sr),m(t,Vo,d),m(t,X,d),e(X,Dr),e(X,je),e(je,Xr),e(X,Gr),e(X,Je),e(Je,qr),e(X,Yr),m(t,Bo,d),m(t,Ot,d),e(Ot,Qr),m(t,So,d),m(t,jt,d),e(jt,no),e(no,Hr),m(t,Do,d),m(t,ie,d),m(t,Xo,d),m(t,de,d),e(de,Kr),e(de,Jt),e(Jt,ea),e(de,ta),m(t,Go,d),m(t,ce,d),e(ce,oa),e(ce,lo),e(lo,ra),e(ce,aa),m(t,qo,d),m(t,G,d),e(G,sa),e(G,Ie),e(Ie,na),e(G,la),e(G,Ze),e(Ze,ia),e(G,da),m(t,Yo,d),m(t,It,d),e(It,ca),m(t,Qo,d),m(t,q,d),e(q,xe),e(xe,ha),e(xe,Ue),e(Ue,ma),e(xe,pa),e(q,fa),e(q,L),e(L,ua),e(L,We),e(We,ga),e(L,_a),e(L,Pe),e(Pe,Ta),e(L,va),e(L,ze),e(ze,ba),e(L,ya),e(q,wa),e(q,Fe),e(Fe,Ca),e(Fe,Zt),e(Zt,Ma),e(Fe,ka),m(t,Ho,d),m(t,K,d),e(K,he),e(he,io),b(Ae,io,null),e(K,Ra),e(K,co),e(co,Ea),m(t,Ko,d),m(t,xt,d),e(xt,$a),m(t,er,d),b(Ne,t,d),m(t,tr,d),m(t,x,d),e(x,Le),e(Le,Oa),e(Le,Ve),e(Ve,ja),e(Le,Ja),e(x,Ia),e(x,Be),e(Be,Za),e(Be,Se),e(Se,xa),e(Be,Ua),e(x,Wa),e(x,De),e(De,Pa),e(De,Xe),e(Xe,za),e(De,Fa),e(x,Aa),e(x,Ge),e(Ge,Na),e(Ge,qe),e(qe,La),e(Ge,Va),e(x,Ba),e(x,Ye),e(Ye,Sa),e(Ye,Qe),e(Qe,Da),e(Ye,Xa),e(x,Ga),e(x,He),e(He,qa),e(He,Ke),e(Ke,Ya),e(He,Qa),m(t,or,d),b(et,t,d),m(t,rr,d),m(t,Ut,d),e(Ut,Wt),e(Wt,tt),e(tt,Ha),e(Wt,Ka),m(t,ar,d),m(t,Pt,d),e(Pt,es),m(t,sr,d),m(t,zt,d),e(zt,ot),e(ot,ts),e(ot,rt),e(rt,os),e(ot,rs),m(t,nr,d),m(t,ee,d),e(ee,me),e(me,ho),b(at,ho,null),e(ee,as),e(ee,mo),e(mo,ss),m(t,lr,d),m(t,Y,d),e(Y,ns),e(Y,po),e(po,ls),e(Y,is),e(Y,Ft),e(Ft,ds),e(Y,cs),m(t,ir,d),m(t,M,d),e(M,hs),e(M,fo),e(fo,ms),e(M,ps),e(M,uo),e(uo,fs),e(M,us),e(M,go),e(go,gs),e(M,_s),e(M,_o),e(_o,Ts),e(M,vs),e(M,At),e(At,bs),e(M,ys),e(M,To),e(To,ws),e(M,Cs),e(M,vo),e(vo,Ms),e(M,ks),e(M,bo),e(bo,Rs),e(M,Es),e(M,yo),e(yo,$s),e(M,Os),m(t,dr,d),m(t,Nt,d),e(Nt,wo),e(wo,js),m(t,cr,d),b(st,t,d),m(t,hr,d),m(t,pe,d),e(pe,Js),e(pe,nt),e(nt,Is),e(pe,Zs),m(t,mr,d),m(t,te,d),e(te,fe),e(fe,Co),b(lt,Co,null),e(te,xs),e(te,Mo),e(Mo,Us),m(t,pr,d),m(t,F,d),b(it,F,null),e(F,Ws),e(F,oe),e(oe,Ps),e(oe,Lt),e(Lt,zs),e(oe,Fs),e(oe,dt),e(dt,As),e(oe,Ns),e(F,Ls),e(F,re),e(re,Vs),e(re,Vt),e(Vt,Bs),e(re,Ss),e(re,Bt),e(Bt,Ds),e(re,Xs),e(F,Gs),b(ue,F,null),m(t,fr,d),m(t,ae,d),e(ae,ge),e(ge,ko),b(ct,ko,null),e(ae,qs),e(ae,Ro),e(Ro,Ys),m(t,ur,d),m(t,R,d),b(ht,R,null),e(R,Qs),e(R,Eo),e(Eo,Hs),e(R,Ks),e(R,O),e(O,St),e(St,en),e(O,tn),e(O,$o),e($o,on),e(O,rn),e(O,Oo),e(Oo,an),e(O,sn),e(O,jo),e(jo,nn),e(O,ln),e(O,Jo),e(Jo,dn),e(O,cn),e(O,mt),e(mt,Io),e(Io,hn),e(mt,mn),e(O,pn),e(O,Dt),e(Dt,fn),e(O,un),e(R,gn),e(R,_e),b(pt,_e,null),e(_e,_n),e(_e,V),e(V,Tn),e(V,Zo),e(Zo,vn),e(V,bn),e(V,xo),e(xo,yn),e(V,wn),e(V,Uo),e(Uo,Cn),e(V,Mn),e(R,kn),e(R,Q),b(ft,Q,null),e(Q,Rn),e(Q,Wo),e(Wo,En),e(Q,$n),b(Te,Q,null),e(R,On),e(R,H),b(ut,H,null),e(H,jn),e(H,gt),e(gt,Jn),e(gt,Xt),e(Xt,In),e(gt,Zn),e(H,xn),b(ve,H,null),e(R,Un),e(R,be),b(_t,be,null),e(be,Wn),e(be,Tt),e(Tt,Pn),e(Tt,Gt),e(Gt,zn),e(Tt,Fn),e(R,An),e(R,ye),b(vt,ye,null),e(ye,Nn),e(ye,bt),e(bt,Ln),e(bt,qt),e(qt,Vn),e(bt,Bn),m(t,gr,d),m(t,se,d),e(se,we),e(we,Po),b(yt,Po,null),e(se,Sn),e(se,zo),e(zo,Dn),m(t,_r,d),m(t,A,d),b(wt,A,null),e(A,Xn),e(A,B),e(B,Gn),e(B,Yt),e(Yt,qn),e(B,Yn),e(B,Fo),e(Fo,Qn),e(B,Hn),e(B,Qt),e(Qt,Kn),e(B,el),e(A,tl),e(A,Ct),e(Ct,ol),e(Ct,Mt),e(Mt,rl),e(Ct,al),e(A,sl),e(A,Ce),b(kt,Ce,null),e(Ce,nl),b(Me,Ce,null),Tr=!0},p(t,[d]){const Rt={};d&2&&(Rt.$$scope={dirty:d,ctx:t}),ue.$set(Rt);const Ao={};d&2&&(Ao.$$scope={dirty:d,ctx:t}),Te.$set(Ao);const No={};d&2&&(No.$$scope={dirty:d,ctx:t}),ve.$set(No);const Lo={};d&2&&(Lo.$$scope={dirty:d,ctx:t}),Me.$set(Lo)},i(t){Tr||(y(p.$$.fragment,t),y(D.$$.fragment,t),y(Ae.$$.fragment,t),y(Ne.$$.fragment,t),y(et.$$.fragment,t),y(at.$$.fragment,t),y(st.$$.fragment,t),y(lt.$$.fragment,t),y(it.$$.fragment,t),y(ue.$$.fragment,t),y(ct.$$.fragment,t),y(ht.$$.fragment,t),y(pt.$$.fragment,t),y(ft.$$.fragment,t),y(Te.$$.fragment,t),y(ut.$$.fragment,t),y(ve.$$.fragment,t),y(_t.$$.fragment,t),y(vt.$$.fragment,t),y(yt.$$.fragment,t),y(wt.$$.fragment,t),y(kt.$$.fragment,t),y(Me.$$.fragment,t),Tr=!0)},o(t){w(p.$$.fragment,t),w(D.$$.fragment,t),w(Ae.$$.fragment,t),w(Ne.$$.fragment,t),w(et.$$.fragment,t),w(at.$$.fragment,t),w(st.$$.fragment,t),w(lt.$$.fragment,t),w(it.$$.fragment,t),w(ue.$$.fragment,t),w(ct.$$.fragment,t),w(ht.$$.fragment,t),w(pt.$$.fragment,t),w(ft.$$.fragment,t),w(Te.$$.fragment,t),w(ut.$$.fragment,t),w(ve.$$.fragment,t),w(_t.$$.fragment,t),w(vt.$$.fragment,t),w(yt.$$.fragment,t),w(wt.$$.fragment,t),w(kt.$$.fragment,t),w(Me.$$.fragment,t),Tr=!1},d(t){o(f),t&&o(E),t&&o(u),C(p),t&&o(j),t&&o(I),C(D),t&&o(Vo),t&&o(X),t&&o(Bo),t&&o(Ot),t&&o(So),t&&o(jt),t&&o(Do),t&&o(ie),t&&o(Xo),t&&o(de),t&&o(Go),t&&o(ce),t&&o(qo),t&&o(G),t&&o(Yo),t&&o(It),t&&o(Qo),t&&o(q),t&&o(Ho),t&&o(K),C(Ae),t&&o(Ko),t&&o(xt),t&&o(er),C(Ne,t),t&&o(tr),t&&o(x),t&&o(or),C(et,t),t&&o(rr),t&&o(Ut),t&&o(ar),t&&o(Pt),t&&o(sr),t&&o(zt),t&&o(nr),t&&o(ee),C(at),t&&o(lr),t&&o(Y),t&&o(ir),t&&o(M),t&&o(dr),t&&o(Nt),t&&o(cr),C(st,t),t&&o(hr),t&&o(pe),t&&o(mr),t&&o(te),C(lt),t&&o(pr),t&&o(F),C(it),C(ue),t&&o(fr),t&&o(ae),C(ct),t&&o(ur),t&&o(R),C(ht),C(pt),C(ft),C(Te),C(ut),C(ve),C(_t),C(vt),t&&o(gr),t&&o(se),C(yt),t&&o(_r),t&&o(A),C(wt),C(kt),C(Me)}}}const ed={local:"trocr",sections:[{local:"overview",title:"Overview"},{local:"resources",title:"Resources"},{local:"inference",title:"Inference"},{local:"transformers.TrOCRConfig",title:"TrOCRConfig"},{local:"transformers.TrOCRProcessor",title:"TrOCRProcessor"},{local:"transformers.TrOCRForCausalLM",title:"TrOCRForCausalLM"}],title:"TrOCR"};function td(S){return Gi(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class dd extends Vi{constructor(f){super();Bi(this,f,td,Ki,Si,{})}}export{dd as default,ed as metadata};
