import{S as Vi,i as Si,s as Bi,e as n,k as d,w as T,t as r,M as Di,c as s,d as o,m,a as l,x as b,h as a,b as i,N as Xi,G as e,g as h,y as v,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 zi}from"../../chunks/Tip-hf-doc-builder.js";import{D as se}from"../../chunks/Docstring-hf-doc-builder.js";import{C as cl}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(B){let f,E,u,g,k;return g=new cl({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=n("p"),E=r("Example:"),u=d(),T(g.$$.fragment)},l(p){f=s(p,"P",{});var _=l(f);E=a(_,"Example:"),_.forEach(o),u=m(p),b(g.$$.fragment,p)},m(p,_){h(p,f,_),e(f,E),h(p,u,_),v(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(B){let f,E,u,g,k,p,_,F,W,j,I;return{c(){f=n("p"),E=r(`This class method is simply calling the feature extractor
`),u=n("a"),g=r("from_pretrained()"),k=r(`, image processor
`),p=n("a"),_=r("ImageProcessingMixin"),F=r(` and the tokenizer
`),W=n("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=s(J,"P",{});var Z=l(f);E=a(Z,`This class method is simply calling the feature extractor
`),u=s(Z,"A",{href:!0});var D=l(u);g=a(D,"from_pretrained()"),D.forEach(o),k=a(Z,`, image processor
`),p=s(Z,"A",{href:!0});var $t=l(p);_=a($t,"ImageProcessingMixin"),$t.forEach(o),F=a(Z,` and the tokenizer
`),W=s(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/main/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin.from_pretrained"),i(p,"href","/docs/transformers/main/en/main_classes/image_processor#transformers.ImageProcessingMixin")},m(J,Z){h(J,f,Z),e(f,E),e(f,u),e(u,g),e(f,k),e(f,p),e(p,_),e(f,F),e(f,W),e(W,j),e(f,I)},d(J){J&&o(f)}}}function Qi(B){let f,E,u,g,k,p,_,F;return{c(){f=n("p"),E=r("This class method is simply calling "),u=n("a"),g=r("save_pretrained()"),k=r(` and
`),p=n("a"),_=r("save_pretrained()"),F=r(`. Please refer to the docstrings of the
methods above for more information.`),this.h()},l(W){f=s(W,"P",{});var j=l(f);E=a(j,"This class method is simply calling "),u=s(j,"A",{href:!0});var I=l(u);g=a(I,"save_pretrained()"),I.forEach(o),k=a(j,` and
`),p=s(j,"A",{href:!0});var J=l(p);_=a(J,"save_pretrained()"),J.forEach(o),F=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/main/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin.save_pretrained"),i(p,"href","/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.save_pretrained")},m(W,j){h(W,f,j),e(f,E),e(f,u),e(u,g),e(f,k),e(f,p),e(p,_),e(f,F)},d(W){W&&o(f)}}}function Hi(B){let f,E,u,g,k;return g=new cl({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=n("p"),E=r("Example:"),u=d(),T(g.$$.fragment)},l(p){f=s(p,"P",{});var _=l(f);E=a(_,"Example:"),_.forEach(o),u=m(p),b(g.$$.fragment,p)},m(p,_){h(p,f,_),e(f,E),h(p,u,_),v(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(B){let f,E,u,g,k,p,_,F,W,j,I,J,Z,D,$t,le,Br,Vo,X,Dr,je,Xr,Gr,Je,qr,Yr,So,Ot,Qr,Bo,jt,so,Hr,Do,ie,dl,Xo,ce,Kr,Jt,ea,ta,Go,de,oa,lo,ra,aa,qo,G,na,Ie,sa,la,Ze,ia,ca,Yo,It,da,Qo,q,xe,ma,Ue,ha,pa,fa,L,ua,We,ga,_a,Pe,Ta,ba,Fe,va,ya,wa,ze,Ca,Zt,Ma,ka,Ho,K,me,io,Ae,Ra,co,Ea,Ko,xt,$a,er,Ne,tr,x,Le,Oa,Ve,ja,Ja,Ia,Se,Za,Be,xa,Ua,Wa,De,Pa,Xe,Fa,za,Aa,Ge,Na,qe,La,Va,Sa,Ye,Ba,Qe,Da,Xa,Ga,He,qa,Ke,Ya,Qa,or,et,rr,Ut,Wt,tt,Ha,Ka,ar,Pt,en,nr,Ft,ot,tn,rt,on,rn,sr,ee,he,mo,at,an,ho,nn,lr,Y,sn,po,ln,cn,zt,dn,mn,ir,M,hn,fo,pn,fn,uo,un,gn,go,_n,Tn,_o,bn,vn,At,yn,wn,To,Cn,Mn,bo,kn,Rn,vo,En,$n,yo,On,jn,cr,Nt,wo,Jn,dr,nt,mr,pe,In,st,Zn,xn,hr,te,fe,Co,lt,Un,Mo,Wn,pr,z,it,Pn,oe,Fn,Lt,zn,An,ct,Nn,Ln,Vn,re,Sn,Vt,Bn,Dn,St,Xn,Gn,qn,ue,fr,ae,ge,ko,dt,Yn,Ro,Qn,ur,R,mt,Hn,Eo,Kn,es,O,Bt,ts,os,$o,rs,as,Oo,ns,ss,jo,ls,is,Jo,cs,ds,ht,Io,ms,hs,ps,Dt,fs,us,gs,_e,pt,_s,V,Ts,Zo,bs,vs,xo,ys,ws,Uo,Cs,Ms,ks,Q,ft,Rs,Wo,Es,$s,Te,Os,H,ut,js,gt,Js,Xt,Is,Zs,xs,be,Us,ve,_t,Ws,Tt,Ps,Gt,Fs,zs,As,ye,bt,Ns,vt,Ls,qt,Vs,Ss,gr,ne,we,Po,yt,Bs,Fo,Ds,_r,A,wt,Xs,S,Gs,Yt,qs,Ys,zo,Qs,Hs,Qt,Ks,el,tl,Ct,ol,Mt,rl,al,nl,Ce,kt,sl,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({}),nt=new cl({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 se({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/main/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/main/src/transformers/models/trocr/configuration_trocr.py#L31"}}),ue=new Ai({props:{anchor:"transformers.TrOCRConfig.example",$$slots:{default:[qi]},$$scope:{ctx:B}}}),dt=new Et({}),mt=new se({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/main/src/transformers/models/trocr/processing_trocr.py#L24"}}),pt=new se({props:{name:"__call__",anchor:"transformers.TrOCRProcessor.__call__",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/trocr/processing_trocr.py#L62"}}),ft=new se({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/main/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/main/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/main/src/transformers/processing_utils.py#L167"}}),Te=new zi({props:{$$slots:{default:[Yi]},$$scope:{ctx:B}}}),ut=new se({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/main/en/main_classes/configuration#transformers.PretrainedConfig.push_to_hub">push_to_hub()</a> method.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/processing_utils.py#L93"}}),be=new zi({props:{$$slots:{default:[Qi]},$$scope:{ctx:B}}}),_t=new se({props:{name:"batch_decode",anchor:"transformers.TrOCRProcessor.batch_decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/trocr/processing_trocr.py#L95"}}),bt=new se({props:{name:"decode",anchor:"transformers.TrOCRProcessor.decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/trocr/processing_trocr.py#L102"}}),yt=new Et({}),wt=new se({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/main/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/main/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/main/src/transformers/models/trocr/modeling_trocr.py#L790"}}),kt=new se({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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/model_doc/perceiver#transformers.PerceiverTokenizer.__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/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/trocr/modeling_trocr.py#L823",returnDescription:`
<p>A <a
  href="/docs/transformers/main/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/main/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/main/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:B}}}),{c(){f=n("meta"),E=d(),u=n("h1"),g=n("a"),k=n("span"),T(p.$$.fragment),_=d(),F=n("span"),W=r("TrOCR"),j=d(),I=n("h2"),J=n("a"),Z=n("span"),T(D.$$.fragment),$t=d(),le=n("span"),Br=r("Overview"),Vo=d(),X=n("p"),Dr=r("The TrOCR model was proposed in "),je=n("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=n("a"),qr=r("optical character recognition (OCR)"),Yr=r("."),So=d(),Ot=n("p"),Qr=r("The abstract from the paper is the following:"),Bo=d(),jt=n("p"),so=n("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=d(),ie=n("img"),Xo=d(),ce=n("small"),Kr=r("TrOCR architecture. Taken from the "),Jt=n("a"),ea=r("original paper"),ta=r("."),Go=d(),de=n("p"),oa=r("Please refer to the "),lo=n("code"),ra=r("VisionEncoderDecoder"),aa=r(" class on how to use this model."),qo=d(),G=n("p"),na=r("This model was contributed by "),Ie=n("a"),sa=r("nielsr"),la=r(`. The original code can be found
`),Ze=n("a"),ia=r("here"),ca=r("."),Yo=d(),It=n("p"),da=r("Tips:"),Qo=d(),q=n("ul"),xe=n("li"),ma=r("The quickest way to get started with TrOCR is by checking the "),Ue=n("a"),ha=r(`tutorial
notebooks`),pa=r(`, which show how to use the model
at inference time as well as fine-tuning on custom data.`),fa=d(),L=n("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=n("a"),ga=r("SROIE dataset"),_a=r(" and handwritten (e.g. the "),Pe=n("a"),Ta=r(`IAM
Handwriting dataset`),ba=r(` text recognition tasks. For more
information, see the `),Fe=n("a"),va=r("official models"),ya=r("."),wa=d(),ze=n("li"),Ca=r("TrOCR is always used within the "),Zt=n("a"),Ma=r("VisionEncoderDecoder"),ka=r(" framework."),Ho=d(),K=n("h2"),me=n("a"),io=n("span"),T(Ae.$$.fragment),Ra=d(),co=n("span"),Ea=r("Resources"),Ko=d(),xt=n("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=d(),T(Ne.$$.fragment),tr=d(),x=n("ul"),Le=n("li"),Oa=r("A blog post on "),Ve=n("a"),ja=r("Accelerating Document AI"),Ja=r(" with TrOCR."),Ia=d(),Se=n("li"),Za=r("A blog post on how to "),Be=n("a"),xa=r("Document AI"),Ua=r(" with TrOCR."),Wa=d(),De=n("li"),Pa=r("A notebook on how to "),Xe=n("a"),Fa=r("finetune TrOCR on IAM Handwriting Database using Seq2SeqTrainer"),za=r("."),Aa=d(),Ge=n("li"),Na=r("A notebook on "),qe=n("a"),La=r("inference with TrOCR"),Va=r(" and Gradio demo."),Sa=d(),Ye=n("li"),Ba=r("A notebook on "),Qe=n("a"),Da=r("finetune TrOCR on the IAM Handwriting Database"),Xa=r(" using native PyTorch."),Ga=d(),He=n("li"),qa=r("A notebook on "),Ke=n("a"),Ya=r("evaluating TrOCR on the IAM test set"),Qa=r("."),or=d(),T(et.$$.fragment),rr=d(),Ut=n("ul"),Wt=n("li"),tt=n("a"),Ha=r("Casual language modeling"),Ka=r(" task guide."),ar=d(),Pt=n("p"),en=r("\u26A1\uFE0F Inference"),nr=d(),Ft=n("ul"),ot=n("li"),tn=r("An interactive-demo on "),rt=n("a"),on=r("TrOCR handwritten character recognition"),rn=r("."),sr=d(),ee=n("h2"),he=n("a"),mo=n("span"),T(at.$$.fragment),an=d(),ho=n("span"),nn=r("Inference"),lr=d(),Y=n("p"),sn=r("TrOCR\u2019s "),po=n("code"),ln=r("VisionEncoderDecoder"),cn=r(` model accepts images as input and makes use of
`),zt=n("a"),dn=r("generate()"),mn=r(" to autoregressively generate text given the input image."),ir=d(),M=n("p"),hn=r("The ["),fo=n("code"),pn=r("ViTImageProcessor"),fn=r("/"),uo=n("code"),un=r("DeiTImageProcessor"),gn=r(`] class is responsible for preprocessing the input image and
[`),go=n("code"),_n=r("RobertaTokenizer"),Tn=r("/"),_o=n("code"),bn=r("XLMRobertaTokenizer"),vn=r(`] decodes the generated target tokens to the target string. The
`),At=n("a"),yn=r("TrOCRProcessor"),wn=r(" wraps ["),To=n("code"),Cn=r("ViTImageProcessor"),Mn=r("/"),bo=n("code"),kn=r("DeiTImageProcessor"),Rn=r("] and ["),vo=n("code"),En=r("RobertaTokenizer"),$n=r("/"),yo=n("code"),On=r("XLMRobertaTokenizer"),jn=r(`]
into a single instance to both extract the input features and decode the predicted token ids.`),cr=d(),Nt=n("ul"),wo=n("li"),Jn=r("Step-by-step Optical Character Recognition (OCR)"),dr=d(),T(nt.$$.fragment),mr=d(),pe=n("p"),In=r("See the "),st=n("a"),Zn=r("model hub"),xn=r(" to look for TrOCR checkpoints."),hr=d(),te=n("h2"),fe=n("a"),Co=n("span"),T(lt.$$.fragment),Un=d(),Mo=n("span"),Wn=r("TrOCRConfig"),pr=d(),z=n("div"),T(it.$$.fragment),Pn=d(),oe=n("p"),Fn=r("This is the configuration class to store the configuration of a "),Lt=n("a"),zn=r("TrOCRForCausalLM"),An=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
`),ct=n("a"),Nn=r("microsoft/trocr-base-handwritten"),Ln=r(" architecture."),Vn=d(),re=n("p"),Sn=r("Configuration objects inherit from "),Vt=n("a"),Bn=r("PretrainedConfig"),Dn=r(` and can be used to control the model outputs. Read the
documentation from `),St=n("a"),Xn=r("PretrainedConfig"),Gn=r(" for more information."),qn=d(),T(ue.$$.fragment),fr=d(),ae=n("h2"),ge=n("a"),ko=n("span"),T(dt.$$.fragment),Yn=d(),Ro=n("span"),Qn=r("TrOCRProcessor"),ur=d(),R=n("div"),T(mt.$$.fragment),Hn=d(),Eo=n("p"),Kn=r("Constructs a TrOCR processor which wraps a vision image processor and a TrOCR tokenizer into a single processor."),es=d(),O=n("p"),Bt=n("a"),ts=r("TrOCRProcessor"),os=r(" offers all the functionalities of ["),$o=n("code"),rs=r("ViTImageProcessor"),as=r("/"),Oo=n("code"),ns=r("DeiTImageProcessor"),ss=r(`] and
[`),jo=n("code"),ls=r("RobertaTokenizer"),is=r("/"),Jo=n("code"),cs=r("XLMRobertaTokenizer"),ds=r("]. See the "),ht=n("a"),Io=n("strong"),ms=r("call"),hs=r("()"),ps=r(" and "),Dt=n("a"),fs=r("decode()"),us=r(` for
more information.`),gs=d(),_e=n("div"),T(pt.$$.fragment),_s=d(),V=n("p"),Ts=r(`When used in normal mode, this method forwards all its arguments to AutoImageProcessor\u2019s
`),Zo=n("code"),bs=r("__call__()"),vs=r(` and returns its output. If used in the context
`),xo=n("code"),ys=r("as_target_processor()"),ws=r(` this method forwards all its arguments to TrOCRTokenizer\u2019s
`),Uo=n("code"),Cs=r("~TrOCRTokenizer.__call__"),Ms=r(". Please refer to the doctsring of the above two methods for more information."),ks=d(),Q=n("div"),T(ft.$$.fragment),Rs=d(),Wo=n("p"),Es=r("Instantiate a processor associated with a pretrained model."),$s=d(),T(Te.$$.fragment),Os=d(),H=n("div"),T(ut.$$.fragment),js=d(),gt=n("p"),Js=r(`Saves the attributes of this processor (feature extractor, tokenizer\u2026) in the specified directory so that it
can be reloaded using the `),Xt=n("a"),Is=r("from_pretrained()"),Zs=r(" method."),xs=d(),T(be.$$.fragment),Us=d(),ve=n("div"),T(_t.$$.fragment),Ws=d(),Tt=n("p"),Ps=r("This method forwards all its arguments to TrOCRTokenizer\u2019s "),Gt=n("a"),Fs=r("batch_decode()"),zs=r(`. Please refer
to the docstring of this method for more information.`),As=d(),ye=n("div"),T(bt.$$.fragment),Ns=d(),vt=n("p"),Ls=r("This method forwards all its arguments to TrOCRTokenizer\u2019s "),qt=n("a"),Vs=r("decode()"),Ss=r(`. Please refer to the
docstring of this method for more information.`),gr=d(),ne=n("h2"),we=n("a"),Po=n("span"),T(yt.$$.fragment),Bs=d(),Fo=n("span"),Ds=r("TrOCRForCausalLM"),_r=d(),A=n("div"),T(wt.$$.fragment),Xs=d(),S=n("p"),Gs=r("The TrOCR Decoder with a language modeling head. Can be used as the decoder part of "),Yt=n("a"),qs=r("EncoderDecoderModel"),Ys=r(" and "),zo=n("code"),Qs=r("VisionEncoderDecoder"),Hs=r(`.
This model inherits from `),Qt=n("a"),Ks=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=d(),Ct=n("p"),ol=r("This model is also a PyTorch "),Mt=n("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.`),nl=d(),Ce=n("div"),T(kt.$$.fragment),sl=d(),T(Me.$$.fragment),this.h()},l(t){const c=Di('[data-svelte="svelte-1phssyn"]',document.head);f=s(c,"META",{name:!0,content:!0}),c.forEach(o),E=m(t),u=s(t,"H1",{class:!0});var Rt=l(u);g=s(Rt,"A",{id:!0,class:!0,href:!0});var Ao=l(g);k=s(Ao,"SPAN",{});var No=l(k);b(p.$$.fragment,No),No.forEach(o),Ao.forEach(o),_=m(Rt),F=s(Rt,"SPAN",{});var Lo=l(F);W=a(Lo,"TrOCR"),Lo.forEach(o),Rt.forEach(o),j=m(t),I=s(t,"H2",{class:!0});var br=l(I);J=s(br,"A",{id:!0,class:!0,href:!0});var ml=l(J);Z=s(ml,"SPAN",{});var hl=l(Z);b(D.$$.fragment,hl),hl.forEach(o),ml.forEach(o),$t=m(br),le=s(br,"SPAN",{});var pl=l(le);Br=a(pl,"Overview"),pl.forEach(o),br.forEach(o),Vo=m(t),X=s(t,"P",{});var Ht=l(X);Dr=a(Ht,"The TrOCR model was proposed in "),je=s(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=s(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),So=m(t),Ot=s(t,"P",{});var gl=l(Ot);Qr=a(gl,"The abstract from the paper is the following:"),gl.forEach(o),Bo=m(t),jt=s(t,"P",{});var _l=l(jt);so=s(_l,"EM",{});var Tl=l(so);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=m(t),ie=s(t,"IMG",{src:!0,alt:!0,width:!0}),Xo=m(t),ce=s(t,"SMALL",{});var vr=l(ce);Kr=a(vr,"TrOCR architecture. Taken from the "),Jt=s(vr,"A",{href:!0});var bl=l(Jt);ea=a(bl,"original paper"),bl.forEach(o),ta=a(vr,"."),vr.forEach(o),Go=m(t),de=s(t,"P",{});var yr=l(de);oa=a(yr,"Please refer to the "),lo=s(yr,"CODE",{});var vl=l(lo);ra=a(vl,"VisionEncoderDecoder"),vl.forEach(o),aa=a(yr," class on how to use this model."),yr.forEach(o),qo=m(t),G=s(t,"P",{});var Kt=l(G);na=a(Kt,"This model was contributed by "),Ie=s(Kt,"A",{href:!0,rel:!0});var yl=l(Ie);sa=a(yl,"nielsr"),yl.forEach(o),la=a(Kt,`. The original code can be found
`),Ze=s(Kt,"A",{href:!0,rel:!0});var wl=l(Ze);ia=a(wl,"here"),wl.forEach(o),ca=a(Kt,"."),Kt.forEach(o),Yo=m(t),It=s(t,"P",{});var Cl=l(It);da=a(Cl,"Tips:"),Cl.forEach(o),Qo=m(t),q=s(t,"UL",{});var eo=l(q);xe=s(eo,"LI",{});var wr=l(xe);ma=a(wr,"The quickest way to get started with TrOCR is by checking the "),Ue=s(wr,"A",{href:!0,rel:!0});var Ml=l(Ue);ha=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=m(eo),L=s(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=s(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=s(ke,"A",{href:!0,rel:!0});var Rl=l(Pe);Ta=a(Rl,`IAM
Handwriting dataset`),Rl.forEach(o),ba=a(ke,` text recognition tasks. For more
information, see the `),Fe=s(ke,"A",{href:!0,rel:!0});var El=l(Fe);va=a(El,"official models"),El.forEach(o),ya=a(ke,"."),ke.forEach(o),wa=m(eo),ze=s(eo,"LI",{});var Cr=l(ze);Ca=a(Cr,"TrOCR is always used within the "),Zt=s(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=m(t),K=s(t,"H2",{class:!0});var Mr=l(K);me=s(Mr,"A",{id:!0,class:!0,href:!0});var Ol=l(me);io=s(Ol,"SPAN",{});var jl=l(io);b(Ae.$$.fragment,jl),jl.forEach(o),Ol.forEach(o),Ra=m(Mr),co=s(Mr,"SPAN",{});var Jl=l(co);Ea=a(Jl,"Resources"),Jl.forEach(o),Mr.forEach(o),Ko=m(t),xt=s(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=m(t),b(Ne.$$.fragment,t),tr=m(t),x=s(t,"UL",{});var N=l(x);Le=s(N,"LI",{});var kr=l(Le);Oa=a(kr,"A blog post on "),Ve=s(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=m(N),Se=s(N,"LI",{});var Rr=l(Se);Za=a(Rr,"A blog post on how to "),Be=s(Rr,"A",{href:!0,rel:!0});var xl=l(Be);xa=a(xl,"Document AI"),xl.forEach(o),Ua=a(Rr," with TrOCR."),Rr.forEach(o),Wa=m(N),De=s(N,"LI",{});var Er=l(De);Pa=a(Er,"A notebook on how to "),Xe=s(Er,"A",{href:!0,rel:!0});var Ul=l(Xe);Fa=a(Ul,"finetune TrOCR on IAM Handwriting Database using Seq2SeqTrainer"),Ul.forEach(o),za=a(Er,"."),Er.forEach(o),Aa=m(N),Ge=s(N,"LI",{});var $r=l(Ge);Na=a($r,"A notebook on "),qe=s($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),Sa=m(N),Ye=s(N,"LI",{});var Or=l(Ye);Ba=a(Or,"A notebook on "),Qe=s(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=m(N),He=s(N,"LI",{});var jr=l(He);qa=a(jr,"A notebook on "),Ke=s(jr,"A",{href:!0,rel:!0});var Fl=l(Ke);Ya=a(Fl,"evaluating TrOCR on the IAM test set"),Fl.forEach(o),Qa=a(jr,"."),jr.forEach(o),N.forEach(o),or=m(t),b(et.$$.fragment,t),rr=m(t),Ut=s(t,"UL",{});var zl=l(Ut);Wt=s(zl,"LI",{});var ll=l(Wt);tt=s(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),zl.forEach(o),ar=m(t),Pt=s(t,"P",{});var Nl=l(Pt);en=a(Nl,"\u26A1\uFE0F Inference"),Nl.forEach(o),nr=m(t),Ft=s(t,"UL",{});var Ll=l(Ft);ot=s(Ll,"LI",{});var Jr=l(ot);tn=a(Jr,"An interactive-demo on "),rt=s(Jr,"A",{href:!0,rel:!0});var Vl=l(rt);on=a(Vl,"TrOCR handwritten character recognition"),Vl.forEach(o),rn=a(Jr,"."),Jr.forEach(o),Ll.forEach(o),sr=m(t),ee=s(t,"H2",{class:!0});var Ir=l(ee);he=s(Ir,"A",{id:!0,class:!0,href:!0});var Sl=l(he);mo=s(Sl,"SPAN",{});var Bl=l(mo);b(at.$$.fragment,Bl),Bl.forEach(o),Sl.forEach(o),an=m(Ir),ho=s(Ir,"SPAN",{});var Dl=l(ho);nn=a(Dl,"Inference"),Dl.forEach(o),Ir.forEach(o),lr=m(t),Y=s(t,"P",{});var to=l(Y);sn=a(to,"TrOCR\u2019s "),po=s(to,"CODE",{});var Xl=l(po);ln=a(Xl,"VisionEncoderDecoder"),Xl.forEach(o),cn=a(to,` model accepts images as input and makes use of
`),zt=s(to,"A",{href:!0});var Gl=l(zt);dn=a(Gl,"generate()"),Gl.forEach(o),mn=a(to," to autoregressively generate text given the input image."),to.forEach(o),ir=m(t),M=s(t,"P",{});var $=l(M);hn=a($,"The ["),fo=s($,"CODE",{});var ql=l(fo);pn=a(ql,"ViTImageProcessor"),ql.forEach(o),fn=a($,"/"),uo=s($,"CODE",{});var Yl=l(uo);un=a(Yl,"DeiTImageProcessor"),Yl.forEach(o),gn=a($,`] class is responsible for preprocessing the input image and
[`),go=s($,"CODE",{});var Ql=l(go);_n=a(Ql,"RobertaTokenizer"),Ql.forEach(o),Tn=a($,"/"),_o=s($,"CODE",{});var Hl=l(_o);bn=a(Hl,"XLMRobertaTokenizer"),Hl.forEach(o),vn=a($,`] decodes the generated target tokens to the target string. The
`),At=s($,"A",{href:!0});var Kl=l(At);yn=a(Kl,"TrOCRProcessor"),Kl.forEach(o),wn=a($," wraps ["),To=s($,"CODE",{});var ei=l(To);Cn=a(ei,"ViTImageProcessor"),ei.forEach(o),Mn=a($,"/"),bo=s($,"CODE",{});var ti=l(bo);kn=a(ti,"DeiTImageProcessor"),ti.forEach(o),Rn=a($,"] and ["),vo=s($,"CODE",{});var oi=l(vo);En=a(oi,"RobertaTokenizer"),oi.forEach(o),$n=a($,"/"),yo=s($,"CODE",{});var ri=l(yo);On=a(ri,"XLMRobertaTokenizer"),ri.forEach(o),jn=a($,`]
into a single instance to both extract the input features and decode the predicted token ids.`),$.forEach(o),cr=m(t),Nt=s(t,"UL",{});var ai=l(Nt);wo=s(ai,"LI",{});var ni=l(wo);Jn=a(ni,"Step-by-step Optical Character Recognition (OCR)"),ni.forEach(o),ai.forEach(o),dr=m(t),b(nt.$$.fragment,t),mr=m(t),pe=s(t,"P",{});var Zr=l(pe);In=a(Zr,"See the "),st=s(Zr,"A",{href:!0,rel:!0});var si=l(st);Zn=a(si,"model hub"),si.forEach(o),xn=a(Zr," to look for TrOCR checkpoints."),Zr.forEach(o),hr=m(t),te=s(t,"H2",{class:!0});var xr=l(te);fe=s(xr,"A",{id:!0,class:!0,href:!0});var li=l(fe);Co=s(li,"SPAN",{});var ii=l(Co);b(lt.$$.fragment,ii),ii.forEach(o),li.forEach(o),Un=m(xr),Mo=s(xr,"SPAN",{});var ci=l(Mo);Wn=a(ci,"TrOCRConfig"),ci.forEach(o),xr.forEach(o),pr=m(t),z=s(t,"DIV",{class:!0});var Re=l(z);b(it.$$.fragment,Re),Pn=m(Re),oe=s(Re,"P",{});var oo=l(oe);Fn=a(oo,"This is the configuration class to store the configuration of a "),Lt=s(oo,"A",{href:!0});var di=l(Lt);zn=a(di,"TrOCRForCausalLM"),di.forEach(o),An=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
`),ct=s(oo,"A",{href:!0,rel:!0});var mi=l(ct);Nn=a(mi,"microsoft/trocr-base-handwritten"),mi.forEach(o),Ln=a(oo," architecture."),oo.forEach(o),Vn=m(Re),re=s(Re,"P",{});var ro=l(re);Sn=a(ro,"Configuration objects inherit from "),Vt=s(ro,"A",{href:!0});var hi=l(Vt);Bn=a(hi,"PretrainedConfig"),hi.forEach(o),Dn=a(ro,` and can be used to control the model outputs. Read the
documentation from `),St=s(ro,"A",{href:!0});var pi=l(St);Xn=a(pi,"PretrainedConfig"),pi.forEach(o),Gn=a(ro," for more information."),ro.forEach(o),qn=m(Re),b(ue.$$.fragment,Re),Re.forEach(o),fr=m(t),ae=s(t,"H2",{class:!0});var Ur=l(ae);ge=s(Ur,"A",{id:!0,class:!0,href:!0});var fi=l(ge);ko=s(fi,"SPAN",{});var ui=l(ko);b(dt.$$.fragment,ui),ui.forEach(o),fi.forEach(o),Yn=m(Ur),Ro=s(Ur,"SPAN",{});var gi=l(Ro);Qn=a(gi,"TrOCRProcessor"),gi.forEach(o),Ur.forEach(o),ur=m(t),R=s(t,"DIV",{class:!0});var U=l(R);b(mt.$$.fragment,U),Hn=m(U),Eo=s(U,"P",{});var _i=l(Eo);Kn=a(_i,"Constructs a TrOCR processor which wraps a vision image processor and a TrOCR tokenizer into a single processor."),_i.forEach(o),es=m(U),O=s(U,"P",{});var P=l(O);Bt=s(P,"A",{href:!0});var Ti=l(Bt);ts=a(Ti,"TrOCRProcessor"),Ti.forEach(o),os=a(P," offers all the functionalities of ["),$o=s(P,"CODE",{});var bi=l($o);rs=a(bi,"ViTImageProcessor"),bi.forEach(o),as=a(P,"/"),Oo=s(P,"CODE",{});var vi=l(Oo);ns=a(vi,"DeiTImageProcessor"),vi.forEach(o),ss=a(P,`] and
[`),jo=s(P,"CODE",{});var yi=l(jo);ls=a(yi,"RobertaTokenizer"),yi.forEach(o),is=a(P,"/"),Jo=s(P,"CODE",{});var wi=l(Jo);cs=a(wi,"XLMRobertaTokenizer"),wi.forEach(o),ds=a(P,"]. See the "),ht=s(P,"A",{href:!0});var il=l(ht);Io=s(il,"STRONG",{});var Ci=l(Io);ms=a(Ci,"call"),Ci.forEach(o),hs=a(il,"()"),il.forEach(o),ps=a(P," and "),Dt=s(P,"A",{href:!0});var Mi=l(Dt);fs=a(Mi,"decode()"),Mi.forEach(o),us=a(P,` for
more information.`),P.forEach(o),gs=m(U),_e=s(U,"DIV",{class:!0});var Wr=l(_e);b(pt.$$.fragment,Wr),_s=m(Wr),V=s(Wr,"P",{});var Ee=l(V);Ts=a(Ee,`When used in normal mode, this method forwards all its arguments to AutoImageProcessor\u2019s
`),Zo=s(Ee,"CODE",{});var ki=l(Zo);bs=a(ki,"__call__()"),ki.forEach(o),vs=a(Ee,` and returns its output. If used in the context
`),xo=s(Ee,"CODE",{});var Ri=l(xo);ys=a(Ri,"as_target_processor()"),Ri.forEach(o),ws=a(Ee,` this method forwards all its arguments to TrOCRTokenizer\u2019s
`),Uo=s(Ee,"CODE",{});var Ei=l(Uo);Cs=a(Ei,"~TrOCRTokenizer.__call__"),Ei.forEach(o),Ms=a(Ee,". Please refer to the doctsring of the above two methods for more information."),Ee.forEach(o),Wr.forEach(o),ks=m(U),Q=s(U,"DIV",{class:!0});var ao=l(Q);b(ft.$$.fragment,ao),Rs=m(ao),Wo=s(ao,"P",{});var $i=l(Wo);Es=a($i,"Instantiate a processor associated with a pretrained model."),$i.forEach(o),$s=m(ao),b(Te.$$.fragment,ao),ao.forEach(o),Os=m(U),H=s(U,"DIV",{class:!0});var no=l(H);b(ut.$$.fragment,no),js=m(no),gt=s(no,"P",{});var Pr=l(gt);Js=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=s(Pr,"A",{href:!0});var Oi=l(Xt);Is=a(Oi,"from_pretrained()"),Oi.forEach(o),Zs=a(Pr," method."),Pr.forEach(o),xs=m(no),b(be.$$.fragment,no),no.forEach(o),Us=m(U),ve=s(U,"DIV",{class:!0});var Fr=l(ve);b(_t.$$.fragment,Fr),Ws=m(Fr),Tt=s(Fr,"P",{});var zr=l(Tt);Ps=a(zr,"This method forwards all its arguments to TrOCRTokenizer\u2019s "),Gt=s(zr,"A",{href:!0});var ji=l(Gt);Fs=a(ji,"batch_decode()"),ji.forEach(o),zs=a(zr,`. Please refer
to the docstring of this method for more information.`),zr.forEach(o),Fr.forEach(o),As=m(U),ye=s(U,"DIV",{class:!0});var Ar=l(ye);b(bt.$$.fragment,Ar),Ns=m(Ar),vt=s(Ar,"P",{});var Nr=l(vt);Ls=a(Nr,"This method forwards all its arguments to TrOCRTokenizer\u2019s "),qt=s(Nr,"A",{href:!0});var Ji=l(qt);Vs=a(Ji,"decode()"),Ji.forEach(o),Ss=a(Nr,`. Please refer to the
docstring of this method for more information.`),Nr.forEach(o),Ar.forEach(o),U.forEach(o),gr=m(t),ne=s(t,"H2",{class:!0});var Lr=l(ne);we=s(Lr,"A",{id:!0,class:!0,href:!0});var Ii=l(we);Po=s(Ii,"SPAN",{});var Zi=l(Po);b(yt.$$.fragment,Zi),Zi.forEach(o),Ii.forEach(o),Bs=m(Lr),Fo=s(Lr,"SPAN",{});var xi=l(Fo);Ds=a(xi,"TrOCRForCausalLM"),xi.forEach(o),Lr.forEach(o),_r=m(t),A=s(t,"DIV",{class:!0});var $e=l(A);b(wt.$$.fragment,$e),Xs=m($e),S=s($e,"P",{});var Oe=l(S);Gs=a(Oe,"The TrOCR Decoder with a language modeling head. Can be used as the decoder part of "),Yt=s(Oe,"A",{href:!0});var Ui=l(Yt);qs=a(Ui,"EncoderDecoderModel"),Ui.forEach(o),Ys=a(Oe," and "),zo=s(Oe,"CODE",{});var Wi=l(zo);Qs=a(Wi,"VisionEncoderDecoder"),Wi.forEach(o),Hs=a(Oe,`.
This model inherits from `),Qt=s(Oe,"A",{href:!0});var Pi=l(Qt);Ks=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=m($e),Ct=s($e,"P",{});var Vr=l(Ct);ol=a(Vr,"This model is also a PyTorch "),Mt=s(Vr,"A",{href:!0,rel:!0});var Fi=l(Mt);rl=a(Fi,"torch.nn.Module"),Fi.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),nl=m($e),Ce=s($e,"DIV",{class:!0});var Sr=l(Ce);b(kt.$$.fragment,Sr),sl=m(Sr),b(Me.$$.fragment,Sr),Sr.forEach(o),$e.forEach(o),this.h()},h(){i(f,"name","hf:doc:metadata"),i(f,"content",JSON.stringify(ec)),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,dl="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/trocr_architecture.jpg")||i(ie,"src",dl),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(Fe,"href","https://huggingface.co/models?other=trocr%3E"),i(Fe,"rel","nofollow"),i(Zt,"href","vision-encoder-decoder"),i(me,"id","resources"),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","#resources"),i(K,"class","relative group"),i(Ve,"href","https://huggingface.co/blog/document-ai"),i(Ve,"rel","nofollow"),i(Be,"href","https://github.com/philschmid/document-ai-transformers"),i(Be,"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(he,"id","inference"),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","#inference"),i(ee,"class","relative group"),i(zt,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.generate"),i(At,"href","/docs/transformers/main/en/model_doc/trocr#transformers.TrOCRProcessor"),i(st,"href","https://huggingface.co/models?filter=trocr"),i(st,"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/main/en/model_doc/trocr#transformers.TrOCRForCausalLM"),i(ct,"href","https://huggingface.co/microsoft/trocr-base-handwritten"),i(ct,"rel","nofollow"),i(Vt,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),i(St,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),i(z,"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(Bt,"href","/docs/transformers/main/en/model_doc/trocr#transformers.TrOCRProcessor"),i(ht,"href","/docs/transformers/main/en/model_doc/trocr#transformers.TrOCRProcessor.__call__"),i(Dt,"href","/docs/transformers/main/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/main/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/main/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.batch_decode"),i(ve,"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/main/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.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(ne,"class","relative group"),i(Yt,"href","/docs/transformers/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),i(Qt,"href","/docs/transformers/main/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,c){e(document.head,f),h(t,E,c),h(t,u,c),e(u,g),e(g,k),v(p,k,null),e(u,_),e(u,F),e(F,W),h(t,j,c),h(t,I,c),e(I,J),e(J,Z),v(D,Z,null),e(I,$t),e(I,le),e(le,Br),h(t,Vo,c),h(t,X,c),e(X,Dr),e(X,je),e(je,Xr),e(X,Gr),e(X,Je),e(Je,qr),e(X,Yr),h(t,So,c),h(t,Ot,c),e(Ot,Qr),h(t,Bo,c),h(t,jt,c),e(jt,so),e(so,Hr),h(t,Do,c),h(t,ie,c),h(t,Xo,c),h(t,ce,c),e(ce,Kr),e(ce,Jt),e(Jt,ea),e(ce,ta),h(t,Go,c),h(t,de,c),e(de,oa),e(de,lo),e(lo,ra),e(de,aa),h(t,qo,c),h(t,G,c),e(G,na),e(G,Ie),e(Ie,sa),e(G,la),e(G,Ze),e(Ze,ia),e(G,ca),h(t,Yo,c),h(t,It,c),e(It,da),h(t,Qo,c),h(t,q,c),e(q,xe),e(xe,ma),e(xe,Ue),e(Ue,ha),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,ba),e(L,Fe),e(Fe,va),e(L,ya),e(q,wa),e(q,ze),e(ze,Ca),e(ze,Zt),e(Zt,Ma),e(ze,ka),h(t,Ho,c),h(t,K,c),e(K,me),e(me,io),v(Ae,io,null),e(K,Ra),e(K,co),e(co,Ea),h(t,Ko,c),h(t,xt,c),e(xt,$a),h(t,er,c),v(Ne,t,c),h(t,tr,c),h(t,x,c),e(x,Le),e(Le,Oa),e(Le,Ve),e(Ve,ja),e(Le,Ja),e(x,Ia),e(x,Se),e(Se,Za),e(Se,Be),e(Be,xa),e(Se,Ua),e(x,Wa),e(x,De),e(De,Pa),e(De,Xe),e(Xe,Fa),e(De,za),e(x,Aa),e(x,Ge),e(Ge,Na),e(Ge,qe),e(qe,La),e(Ge,Va),e(x,Sa),e(x,Ye),e(Ye,Ba),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),h(t,or,c),v(et,t,c),h(t,rr,c),h(t,Ut,c),e(Ut,Wt),e(Wt,tt),e(tt,Ha),e(Wt,Ka),h(t,ar,c),h(t,Pt,c),e(Pt,en),h(t,nr,c),h(t,Ft,c),e(Ft,ot),e(ot,tn),e(ot,rt),e(rt,on),e(ot,rn),h(t,sr,c),h(t,ee,c),e(ee,he),e(he,mo),v(at,mo,null),e(ee,an),e(ee,ho),e(ho,nn),h(t,lr,c),h(t,Y,c),e(Y,sn),e(Y,po),e(po,ln),e(Y,cn),e(Y,zt),e(zt,dn),e(Y,mn),h(t,ir,c),h(t,M,c),e(M,hn),e(M,fo),e(fo,pn),e(M,fn),e(M,uo),e(uo,un),e(M,gn),e(M,go),e(go,_n),e(M,Tn),e(M,_o),e(_o,bn),e(M,vn),e(M,At),e(At,yn),e(M,wn),e(M,To),e(To,Cn),e(M,Mn),e(M,bo),e(bo,kn),e(M,Rn),e(M,vo),e(vo,En),e(M,$n),e(M,yo),e(yo,On),e(M,jn),h(t,cr,c),h(t,Nt,c),e(Nt,wo),e(wo,Jn),h(t,dr,c),v(nt,t,c),h(t,mr,c),h(t,pe,c),e(pe,In),e(pe,st),e(st,Zn),e(pe,xn),h(t,hr,c),h(t,te,c),e(te,fe),e(fe,Co),v(lt,Co,null),e(te,Un),e(te,Mo),e(Mo,Wn),h(t,pr,c),h(t,z,c),v(it,z,null),e(z,Pn),e(z,oe),e(oe,Fn),e(oe,Lt),e(Lt,zn),e(oe,An),e(oe,ct),e(ct,Nn),e(oe,Ln),e(z,Vn),e(z,re),e(re,Sn),e(re,Vt),e(Vt,Bn),e(re,Dn),e(re,St),e(St,Xn),e(re,Gn),e(z,qn),v(ue,z,null),h(t,fr,c),h(t,ae,c),e(ae,ge),e(ge,ko),v(dt,ko,null),e(ae,Yn),e(ae,Ro),e(Ro,Qn),h(t,ur,c),h(t,R,c),v(mt,R,null),e(R,Hn),e(R,Eo),e(Eo,Kn),e(R,es),e(R,O),e(O,Bt),e(Bt,ts),e(O,os),e(O,$o),e($o,rs),e(O,as),e(O,Oo),e(Oo,ns),e(O,ss),e(O,jo),e(jo,ls),e(O,is),e(O,Jo),e(Jo,cs),e(O,ds),e(O,ht),e(ht,Io),e(Io,ms),e(ht,hs),e(O,ps),e(O,Dt),e(Dt,fs),e(O,us),e(R,gs),e(R,_e),v(pt,_e,null),e(_e,_s),e(_e,V),e(V,Ts),e(V,Zo),e(Zo,bs),e(V,vs),e(V,xo),e(xo,ys),e(V,ws),e(V,Uo),e(Uo,Cs),e(V,Ms),e(R,ks),e(R,Q),v(ft,Q,null),e(Q,Rs),e(Q,Wo),e(Wo,Es),e(Q,$s),v(Te,Q,null),e(R,Os),e(R,H),v(ut,H,null),e(H,js),e(H,gt),e(gt,Js),e(gt,Xt),e(Xt,Is),e(gt,Zs),e(H,xs),v(be,H,null),e(R,Us),e(R,ve),v(_t,ve,null),e(ve,Ws),e(ve,Tt),e(Tt,Ps),e(Tt,Gt),e(Gt,Fs),e(Tt,zs),e(R,As),e(R,ye),v(bt,ye,null),e(ye,Ns),e(ye,vt),e(vt,Ls),e(vt,qt),e(qt,Vs),e(vt,Ss),h(t,gr,c),h(t,ne,c),e(ne,we),e(we,Po),v(yt,Po,null),e(ne,Bs),e(ne,Fo),e(Fo,Ds),h(t,_r,c),h(t,A,c),v(wt,A,null),e(A,Xs),e(A,S),e(S,Gs),e(S,Yt),e(Yt,qs),e(S,Ys),e(S,zo),e(zo,Qs),e(S,Hs),e(S,Qt),e(Qt,Ks),e(S,el),e(A,tl),e(A,Ct),e(Ct,ol),e(Ct,Mt),e(Mt,rl),e(Ct,al),e(A,nl),e(A,Ce),v(kt,Ce,null),e(Ce,sl),v(Me,Ce,null),Tr=!0},p(t,[c]){const Rt={};c&2&&(Rt.$$scope={dirty:c,ctx:t}),ue.$set(Rt);const Ao={};c&2&&(Ao.$$scope={dirty:c,ctx:t}),Te.$set(Ao);const No={};c&2&&(No.$$scope={dirty:c,ctx:t}),be.$set(No);const Lo={};c&2&&(Lo.$$scope={dirty:c,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(nt.$$.fragment,t),y(lt.$$.fragment,t),y(it.$$.fragment,t),y(ue.$$.fragment,t),y(dt.$$.fragment,t),y(mt.$$.fragment,t),y(pt.$$.fragment,t),y(ft.$$.fragment,t),y(Te.$$.fragment,t),y(ut.$$.fragment,t),y(be.$$.fragment,t),y(_t.$$.fragment,t),y(bt.$$.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(nt.$$.fragment,t),w(lt.$$.fragment,t),w(it.$$.fragment,t),w(ue.$$.fragment,t),w(dt.$$.fragment,t),w(mt.$$.fragment,t),w(pt.$$.fragment,t),w(ft.$$.fragment,t),w(Te.$$.fragment,t),w(ut.$$.fragment,t),w(be.$$.fragment,t),w(_t.$$.fragment,t),w(bt.$$.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(So),t&&o(Ot),t&&o(Bo),t&&o(jt),t&&o(Do),t&&o(ie),t&&o(Xo),t&&o(ce),t&&o(Go),t&&o(de),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(nr),t&&o(Ft),t&&o(sr),t&&o(ee),C(at),t&&o(lr),t&&o(Y),t&&o(ir),t&&o(M),t&&o(cr),t&&o(Nt),t&&o(dr),C(nt,t),t&&o(mr),t&&o(pe),t&&o(hr),t&&o(te),C(lt),t&&o(pr),t&&o(z),C(it),C(ue),t&&o(fr),t&&o(ae),C(dt),t&&o(ur),t&&o(R),C(mt),C(pt),C(ft),C(Te),C(ut),C(be),C(_t),C(bt),t&&o(gr),t&&o(ne),C(yt),t&&o(_r),t&&o(A),C(wt),C(kt),C(Me)}}}const ec={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 tc(B){return Gi(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class cc extends Vi{constructor(f){super();Si(this,f,tc,Ki,Bi,{})}}export{cc as default,ec as metadata};
