import{S as Vi,i as Bi,s as Si,e as n,k as c,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 Fi}from"../../chunks/Tip-hf-doc-builder.js";import{D as se}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=n("p"),E=r("Example:"),u=c(),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(S){let f,E,u,g,k,p,_,z,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"),z=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),z=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/internal/image_processing_utils#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,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=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()"),z=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),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/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,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=n("p"),E=r("Example:"),u=c(),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(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,so,Hr,Do,ie,cl,Xo,de,Kr,Jt,ea,ta,Go,ce,oa,lo,ra,aa,qo,G,na,Ie,sa,la,Ze,ia,da,Yo,It,ca,Qo,q,xe,ma,Ue,ha,pa,fa,L,ua,We,ga,_a,Pe,Ta,ba,ze,va,ya,wa,Fe,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,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,en,nr,zt,ot,tn,rt,on,rn,sr,ee,he,mo,at,an,ho,nn,lr,Y,sn,po,ln,dn,Ft,cn,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,dr,Nt,wo,Jn,cr,nt,mr,pe,In,st,Zn,xn,hr,te,fe,Co,lt,Un,Mo,Wn,pr,F,it,Pn,oe,zn,Lt,Fn,An,dt,Nn,Ln,Vn,re,Bn,Vt,Sn,Dn,Bt,Xn,Gn,qn,ue,fr,ae,ge,ko,ct,Yn,Ro,Qn,ur,R,mt,Hn,Eo,Kn,es,O,St,ts,os,$o,rs,as,Oo,ns,ss,jo,ls,is,Jo,ds,cs,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,zs,Fs,As,ye,bt,Ns,vt,Ls,qt,Vs,Bs,gr,ne,we,Po,yt,Ss,zo,Ds,_r,A,wt,Xs,B,Gs,Yt,qs,Ys,Fo,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 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 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:S}}}),ct=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 Fi({props:{$$slots:{default:[Yi]},$$scope:{ctx:S}}}),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/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.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 Fi({props:{$$slots:{default:[Qi]},$$scope:{ctx:S}}}),_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/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/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/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:S}}}),{c(){f=n("meta"),E=c(),u=n("h1"),g=n("a"),k=n("span"),T(p.$$.fragment),_=c(),z=n("span"),W=r("TrOCR"),j=c(),I=n("h2"),J=n("a"),Z=n("span"),T(D.$$.fragment),$t=c(),le=n("span"),Sr=r("Overview"),Vo=c(),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("."),Bo=c(),Ot=n("p"),Qr=r("The abstract from the paper is the following:"),So=c(),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=c(),ie=n("img"),Xo=c(),de=n("small"),Kr=r("TrOCR architecture. Taken from the "),Jt=n("a"),ea=r("original paper"),ta=r("."),Go=c(),ce=n("p"),oa=r("Please refer to the "),lo=n("code"),ra=r("VisionEncoderDecoder"),aa=r(" class on how to use this model."),qo=c(),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"),da=r("."),Yo=c(),It=n("p"),ca=r("Tips:"),Qo=c(),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=c(),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 `),ze=n("a"),va=r("official models"),ya=r("."),wa=c(),Fe=n("li"),Ca=r("TrOCR is always used within the "),Zt=n("a"),Ma=r("VisionEncoderDecoder"),ka=r(" framework."),Ho=c(),K=n("h2"),me=n("a"),io=n("span"),T(Ae.$$.fragment),Ra=c(),co=n("span"),Ea=r("Resources"),Ko=c(),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=c(),T(Ne.$$.fragment),tr=c(),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=c(),Be=n("li"),Za=r("A blog post on how to "),Se=n("a"),xa=r("Document AI"),Ua=r(" with TrOCR."),Wa=c(),De=n("li"),Pa=r("A notebook on how to "),Xe=n("a"),za=r("finetune TrOCR on IAM Handwriting Database using Seq2SeqTrainer"),Fa=r("."),Aa=c(),Ge=n("li"),Na=r("A notebook on "),qe=n("a"),La=r("inference with TrOCR"),Va=r(" and Gradio demo."),Ba=c(),Ye=n("li"),Sa=r("A notebook on "),Qe=n("a"),Da=r("finetune TrOCR on the IAM Handwriting Database"),Xa=r(" using native PyTorch."),Ga=c(),He=n("li"),qa=r("A notebook on "),Ke=n("a"),Ya=r("evaluating TrOCR on the IAM test set"),Qa=r("."),or=c(),T(et.$$.fragment),rr=c(),Ut=n("ul"),Wt=n("li"),tt=n("a"),Ha=r("Casual language modeling"),Ka=r(" task guide."),ar=c(),Pt=n("p"),en=r("\u26A1\uFE0F Inference"),nr=c(),zt=n("ul"),ot=n("li"),tn=r("An interactive-demo on "),rt=n("a"),on=r("TrOCR handwritten character recognition"),rn=r("."),sr=c(),ee=n("h2"),he=n("a"),mo=n("span"),T(at.$$.fragment),an=c(),ho=n("span"),nn=r("Inference"),lr=c(),Y=n("p"),sn=r("TrOCR\u2019s "),po=n("code"),ln=r("VisionEncoderDecoder"),dn=r(` model accepts images as input and makes use of
`),Ft=n("a"),cn=r("generate()"),mn=r(" to autoregressively generate text given the input image."),ir=c(),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.`),dr=c(),Nt=n("ul"),wo=n("li"),Jn=r("Step-by-step Optical Character Recognition (OCR)"),cr=c(),T(nt.$$.fragment),mr=c(),pe=n("p"),In=r("See the "),st=n("a"),Zn=r("model hub"),xn=r(" to look for TrOCR checkpoints."),hr=c(),te=n("h2"),fe=n("a"),Co=n("span"),T(lt.$$.fragment),Un=c(),Mo=n("span"),Wn=r("TrOCRConfig"),pr=c(),F=n("div"),T(it.$$.fragment),Pn=c(),oe=n("p"),zn=r("This is the configuration class to store the configuration of a "),Lt=n("a"),Fn=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
`),dt=n("a"),Nn=r("microsoft/trocr-base-handwritten"),Ln=r(" architecture."),Vn=c(),re=n("p"),Bn=r("Configuration objects inherit from "),Vt=n("a"),Sn=r("PretrainedConfig"),Dn=r(` and can be used to control the model outputs. Read the
documentation from `),Bt=n("a"),Xn=r("PretrainedConfig"),Gn=r(" for more information."),qn=c(),T(ue.$$.fragment),fr=c(),ae=n("h2"),ge=n("a"),ko=n("span"),T(ct.$$.fragment),Yn=c(),Ro=n("span"),Qn=r("TrOCRProcessor"),ur=c(),R=n("div"),T(mt.$$.fragment),Hn=c(),Eo=n("p"),Kn=r("Constructs a TrOCR processor which wraps a vision image processor and a TrOCR tokenizer into a single processor."),es=c(),O=n("p"),St=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"),ds=r("XLMRobertaTokenizer"),cs=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=c(),_e=n("div"),T(pt.$$.fragment),_s=c(),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=c(),Q=n("div"),T(ft.$$.fragment),Rs=c(),Wo=n("p"),Es=r("Instantiate a processor associated with a pretrained model."),$s=c(),T(Te.$$.fragment),Os=c(),H=n("div"),T(ut.$$.fragment),js=c(),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=c(),T(be.$$.fragment),Us=c(),ve=n("div"),T(_t.$$.fragment),Ws=c(),Tt=n("p"),Ps=r("This method forwards all its arguments to TrOCRTokenizer\u2019s "),Gt=n("a"),zs=r("batch_decode()"),Fs=r(`. Please refer
to the docstring of this method for more information.`),As=c(),ye=n("div"),T(bt.$$.fragment),Ns=c(),vt=n("p"),Ls=r("This method forwards all its arguments to TrOCRTokenizer\u2019s "),qt=n("a"),Vs=r("decode()"),Bs=r(`. Please refer to the
docstring of this method for more information.`),gr=c(),ne=n("h2"),we=n("a"),Po=n("span"),T(yt.$$.fragment),Ss=c(),zo=n("span"),Ds=r("TrOCRForCausalLM"),_r=c(),A=n("div"),T(wt.$$.fragment),Xs=c(),B=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 "),Fo=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=c(),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=c(),Ce=n("div"),T(kt.$$.fragment),sl=c(),T(Me.$$.fragment),this.h()},l(t){const d=Di('[data-svelte="svelte-1phssyn"]',document.head);f=s(d,"META",{name:!0,content:!0}),d.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),z=s(Rt,"SPAN",{});var Lo=l(z);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);Sr=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),Bo=m(t),Ot=s(t,"P",{});var gl=l(Ot);Qr=a(gl,"The abstract from the paper is the following:"),gl.forEach(o),So=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),de=s(t,"SMALL",{});var vr=l(de);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),ce=s(t,"P",{});var yr=l(ce);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),da=a(Kt,"."),Kt.forEach(o),Yo=m(t),It=s(t,"P",{});var Cl=l(It);ca=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 `),ze=s(ke,"A",{href:!0,rel:!0});var El=l(ze);va=a(El,"official models"),El.forEach(o),ya=a(ke,"."),ke.forEach(o),wa=m(eo),Fe=s(eo,"LI",{});var Cr=l(Fe);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),Be=s(N,"LI",{});var Rr=l(Be);Za=a(Rr,"A blog post on how to "),Se=s(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=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);za=a(Ul,"finetune TrOCR on IAM Handwriting Database using Seq2SeqTrainer"),Ul.forEach(o),Fa=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),Ba=m(N),Ye=s(N,"LI",{});var Or=l(Ye);Sa=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 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=m(t),b(et.$$.fragment,t),rr=m(t),Ut=s(t,"UL",{});var Fl=l(Ut);Wt=s(Fl,"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),Fl.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),zt=s(t,"UL",{});var Ll=l(zt);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 Bl=l(he);mo=s(Bl,"SPAN",{});var Sl=l(mo);b(at.$$.fragment,Sl),Sl.forEach(o),Bl.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),dn=a(to,` model accepts images as input and makes use of
`),Ft=s(to,"A",{href:!0});var Gl=l(Ft);cn=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),dr=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),cr=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 di=l(Mo);Wn=a(di,"TrOCRConfig"),di.forEach(o),xr.forEach(o),pr=m(t),F=s(t,"DIV",{class:!0});var Re=l(F);b(it.$$.fragment,Re),Pn=m(Re),oe=s(Re,"P",{});var oo=l(oe);zn=a(oo,"This is the configuration class to store the configuration of a "),Lt=s(oo,"A",{href:!0});var ci=l(Lt);Fn=a(ci,"TrOCRForCausalLM"),ci.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
`),dt=s(oo,"A",{href:!0,rel:!0});var mi=l(dt);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);Bn=a(ro,"Configuration objects inherit from "),Vt=s(ro,"A",{href:!0});var hi=l(Vt);Sn=a(hi,"PretrainedConfig"),hi.forEach(o),Dn=a(ro,` and can be used to control the model outputs. Read the
documentation from `),Bt=s(ro,"A",{href:!0});var pi=l(Bt);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(ct.$$.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);St=s(P,"A",{href:!0});var Ti=l(St);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);ds=a(wi,"XLMRobertaTokenizer"),wi.forEach(o),cs=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 zr=l(ve);b(_t.$$.fragment,zr),Ws=m(zr),Tt=s(zr,"P",{});var Fr=l(Tt);Ps=a(Fr,"This method forwards all its arguments to TrOCRTokenizer\u2019s "),Gt=s(Fr,"A",{href:!0});var ji=l(Gt);zs=a(ji,"batch_decode()"),ji.forEach(o),Fs=a(Fr,`. Please refer
to the docstring of this method for more information.`),Fr.forEach(o),zr.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),Bs=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),Ss=m(Lr),zo=s(Lr,"SPAN",{});var xi=l(zo);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),B=s($e,"P",{});var Oe=l(B);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 "),Fo=s(Oe,"CODE",{});var Wi=l(Fo);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 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),nl=m($e),Ce=s($e,"DIV",{class:!0});var Br=l(Ce);b(kt.$$.fragment,Br),sl=m(Br),b(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(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(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(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(Ft,"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(dt,"href","https://huggingface.co/microsoft/trocr-base-handwritten"),i(dt,"rel","nofollow"),i(Vt,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),i(Bt,"href","/docs/transformers/main/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/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/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.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/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(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,d){e(document.head,f),h(t,E,d),h(t,u,d),e(u,g),e(g,k),v(p,k,null),e(u,_),e(u,z),e(z,W),h(t,j,d),h(t,I,d),e(I,J),e(J,Z),v(D,Z,null),e(I,$t),e(I,le),e(le,Sr),h(t,Vo,d),h(t,X,d),e(X,Dr),e(X,je),e(je,Xr),e(X,Gr),e(X,Je),e(Je,qr),e(X,Yr),h(t,Bo,d),h(t,Ot,d),e(Ot,Qr),h(t,So,d),h(t,jt,d),e(jt,so),e(so,Hr),h(t,Do,d),h(t,ie,d),h(t,Xo,d),h(t,de,d),e(de,Kr),e(de,Jt),e(Jt,ea),e(de,ta),h(t,Go,d),h(t,ce,d),e(ce,oa),e(ce,lo),e(lo,ra),e(ce,aa),h(t,qo,d),h(t,G,d),e(G,na),e(G,Ie),e(Ie,sa),e(G,la),e(G,Ze),e(Ze,ia),e(G,da),h(t,Yo,d),h(t,It,d),e(It,ca),h(t,Qo,d),h(t,q,d),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,ze),e(ze,va),e(L,ya),e(q,wa),e(q,Fe),e(Fe,Ca),e(Fe,Zt),e(Zt,Ma),e(Fe,ka),h(t,Ho,d),h(t,K,d),e(K,me),e(me,io),v(Ae,io,null),e(K,Ra),e(K,co),e(co,Ea),h(t,Ko,d),h(t,xt,d),e(xt,$a),h(t,er,d),v(Ne,t,d),h(t,tr,d),h(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),h(t,or,d),v(et,t,d),h(t,rr,d),h(t,Ut,d),e(Ut,Wt),e(Wt,tt),e(tt,Ha),e(Wt,Ka),h(t,ar,d),h(t,Pt,d),e(Pt,en),h(t,nr,d),h(t,zt,d),e(zt,ot),e(ot,tn),e(ot,rt),e(rt,on),e(ot,rn),h(t,sr,d),h(t,ee,d),e(ee,he),e(he,mo),v(at,mo,null),e(ee,an),e(ee,ho),e(ho,nn),h(t,lr,d),h(t,Y,d),e(Y,sn),e(Y,po),e(po,ln),e(Y,dn),e(Y,Ft),e(Ft,cn),e(Y,mn),h(t,ir,d),h(t,M,d),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,dr,d),h(t,Nt,d),e(Nt,wo),e(wo,Jn),h(t,cr,d),v(nt,t,d),h(t,mr,d),h(t,pe,d),e(pe,In),e(pe,st),e(st,Zn),e(pe,xn),h(t,hr,d),h(t,te,d),e(te,fe),e(fe,Co),v(lt,Co,null),e(te,Un),e(te,Mo),e(Mo,Wn),h(t,pr,d),h(t,F,d),v(it,F,null),e(F,Pn),e(F,oe),e(oe,zn),e(oe,Lt),e(Lt,Fn),e(oe,An),e(oe,dt),e(dt,Nn),e(oe,Ln),e(F,Vn),e(F,re),e(re,Bn),e(re,Vt),e(Vt,Sn),e(re,Dn),e(re,Bt),e(Bt,Xn),e(re,Gn),e(F,qn),v(ue,F,null),h(t,fr,d),h(t,ae,d),e(ae,ge),e(ge,ko),v(ct,ko,null),e(ae,Yn),e(ae,Ro),e(Ro,Qn),h(t,ur,d),h(t,R,d),v(mt,R,null),e(R,Hn),e(R,Eo),e(Eo,Kn),e(R,es),e(R,O),e(O,St),e(St,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,ds),e(O,cs),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,zs),e(Tt,Fs),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,Bs),h(t,gr,d),h(t,ne,d),e(ne,we),e(we,Po),v(yt,Po,null),e(ne,Ss),e(ne,zo),e(zo,Ds),h(t,_r,d),h(t,A,d),v(wt,A,null),e(A,Xs),e(A,B),e(B,Gs),e(B,Yt),e(Yt,qs),e(B,Ys),e(B,Fo),e(Fo,Qs),e(B,Hs),e(B,Qt),e(Qt,Ks),e(B,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,[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}),be.$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(nt.$$.fragment,t),y(lt.$$.fragment,t),y(it.$$.fragment,t),y(ue.$$.fragment,t),y(ct.$$.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(ct.$$.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(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(nr),t&&o(zt),t&&o(sr),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(nt,t),t&&o(mr),t&&o(pe),t&&o(hr),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(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 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};
