import{S as ri,i as ai,s as si,e as s,k as c,w as b,t as r,M as ni,c as n,d as o,m,a as i,x as C,h as a,b as l,N as ii,G as e,g as p,y as w,q as k,o as O,B as y,v as li,L as oi}from"../../chunks/vendor-hf-doc-builder.js";import{T as ei}from"../../chunks/Tip-hf-doc-builder.js";import{D as re}from"../../chunks/Docstring-hf-doc-builder.js";import{C as As}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as jt}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as ti}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function di(W){let f,R,u,g,T;return g=new As({props:{code:`from transformers import TrOCRConfig, TrOCRForCausalLM

# Initializing a TrOCR-base style configuration
configuration = TrOCRConfig()

# Initializing a model (with random weights) from the TrOCR-base style configuration
model = TrOCRForCausalLM(configuration)

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

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

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the TrOCR-base style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TrOCRForCausalLM(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`}}),{c(){f=s("p"),R=r("Example:"),u=c(),b(g.$$.fragment)},l(h){f=n(h,"P",{});var _=i(f);R=a(_,"Example:"),_.forEach(o),u=m(h),C(g.$$.fragment,h)},m(h,_){p(h,f,_),e(f,R),p(h,u,_),w(g,h,_),T=!0},p:oi,i(h){T||(k(g.$$.fragment,h),T=!0)},o(h){O(g.$$.fragment,h),T=!1},d(h){h&&o(f),h&&o(u),y(g,h)}}}function ci(W){let f,R,u,g,T,h,_,q,I,P,j;return{c(){f=s("p"),R=r(`This class method is simply calling the feature extractor
`),u=s("a"),g=r("from_pretrained()"),T=r(`, image processor
`),h=s("a"),_=r("ImageProcessingMixin"),q=r(` and the tokenizer
`),I=s("code"),P=r("~tokenization_utils_base.PreTrainedTokenizer.from_pretrained"),j=r(` methods. Please refer to the docstrings of the
methods above for more information.`),this.h()},l(M){f=n(M,"P",{});var z=i(f);R=a(z,`This class method is simply calling the feature extractor
`),u=n(z,"A",{href:!0});var B=i(u);g=a(B,"from_pretrained()"),B.forEach(o),T=a(z,`, image processor
`),h=n(z,"A",{href:!0});var st=i(h);_=a(st,"ImageProcessingMixin"),st.forEach(o),q=a(z,` and the tokenizer
`),I=n(z,"CODE",{});var ae=i(I);P=a(ae,"~tokenization_utils_base.PreTrainedTokenizer.from_pretrained"),ae.forEach(o),j=a(z,` methods. Please refer to the docstrings of the
methods above for more information.`),z.forEach(o),this.h()},h(){l(u,"href","/docs/transformers/main/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin.from_pretrained"),l(h,"href","/docs/transformers/main/en/internal/image_processing_utils#transformers.ImageProcessingMixin")},m(M,z){p(M,f,z),e(f,R),e(f,u),e(u,g),e(f,T),e(f,h),e(h,_),e(f,q),e(f,I),e(I,P),e(f,j)},d(M){M&&o(f)}}}function mi(W){let f,R,u,g,T,h,_,q;return{c(){f=s("p"),R=r("This class method is simply calling "),u=s("a"),g=r("save_pretrained()"),T=r(` and
`),h=s("a"),_=r("save_pretrained()"),q=r(`. Please refer to the docstrings of the
methods above for more information.`),this.h()},l(I){f=n(I,"P",{});var P=i(f);R=a(P,"This class method is simply calling "),u=n(P,"A",{href:!0});var j=i(u);g=a(j,"save_pretrained()"),j.forEach(o),T=a(P,` and
`),h=n(P,"A",{href:!0});var M=i(h);_=a(M,"save_pretrained()"),M.forEach(o),q=a(P,`. Please refer to the docstrings of the
methods above for more information.`),P.forEach(o),this.h()},h(){l(u,"href","/docs/transformers/main/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin.save_pretrained"),l(h,"href","/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.save_pretrained")},m(I,P){p(I,f,P),e(f,R),e(f,u),e(u,g),e(f,T),e(f,h),e(h,_),e(f,q)},d(I){I&&o(f)}}}function hi(W){let f,R,u,g,T;return g=new As({props:{code:`from transformers import (
    TrOCRConfig,
    TrOCRProcessor,
    TrOCRForCausalLM,
    ViTConfig,
    ViTModel,
    VisionEncoderDecoderModel,
)
import requests
from PIL import Image

# TrOCR is a decoder model and should be used within a VisionEncoderDecoderModel
# init vision2text model with random weights
encoder = ViTModel(ViTConfig())
decoder = TrOCRForCausalLM(TrOCRConfig())
model = VisionEncoderDecoderModel(encoder=encoder, decoder=decoder)

# If you want to start from the pretrained model, load the checkpoint with \`VisionEncoderDecoderModel\`
processor = TrOCRProcessor.from_pretrained("microsoft/trocr-base-handwritten")
model = VisionEncoderDecoderModel.from_pretrained("microsoft/trocr-base-handwritten")

# load image from the IAM dataset
url = "https://fki.tic.heia-fr.ch/static/img/a01-122-02.jpg"
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
pixel_values = processor(image, return_tensors="pt").pixel_values
text = "industry, ' Mr. Brown commented icily. ' Let us have a"

# training
model.config.decoder_start_token_id = processor.tokenizer.cls_token_id
model.config.pad_token_id = processor.tokenizer.pad_token_id
model.config.vocab_size = model.config.decoder.vocab_size

labels = processor.tokenizer(text, return_tensors="pt").input_ids
outputs = model(pixel_values, labels=labels)
loss = outputs.loss
round(loss.item(), 2)

# inference
generated_ids = model.generate(pixel_values)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
generated_text`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> (
<span class="hljs-meta">... </span>    TrOCRConfig,
<span class="hljs-meta">... </span>    TrOCRProcessor,
<span class="hljs-meta">... </span>    TrOCRForCausalLM,
<span class="hljs-meta">... </span>    ViTConfig,
<span class="hljs-meta">... </span>    ViTModel,
<span class="hljs-meta">... </span>    VisionEncoderDecoderModel,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

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

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

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

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

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

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># inference</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_ids = model.generate(pixel_values)
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_text = processor.batch_decode(generated_ids, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_text
<span class="hljs-string">&#x27;industry, &quot; Mr. Brown commented icily. &quot; Let us have a&#x27;</span>`}}),{c(){f=s("p"),R=r("Example:"),u=c(),b(g.$$.fragment)},l(h){f=n(h,"P",{});var _=i(f);R=a(_,"Example:"),_.forEach(o),u=m(h),C(g.$$.fragment,h)},m(h,_){p(h,f,_),e(f,R),p(h,u,_),w(g,h,_),T=!0},p:oi,i(h){T||(k(g.$$.fragment,h),T=!0)},o(h){O(g.$$.fragment,h),T=!1},d(h){h&&o(f),h&&o(u),y(g,h)}}}function pi(W){let f,R,u,g,T,h,_,q,I,P,j,M,z,B,st,ae,er,fo,H,tr,$e,or,rr,Re,ar,sr,uo,nt,nr,go,it,zt,ir,_o,se,Fs,vo,ne,lr,lt,dr,cr,To,ie,mr,Lt,hr,pr,bo,G,fr,Ee,ur,gr,xe,_r,vr,Co,dt,Tr,wo,X,Pe,br,Me,Cr,wr,kr,V,Or,je,yr,$r,ze,Rr,Er,Le,xr,Pr,Mr,Ie,jr,ct,zr,Lr,ko,Y,le,It,De,Ir,Dt,Dr,Oo,U,qr,qt,Ar,Fr,mt,Vr,Nr,yo,v,Sr,At,Wr,Br,Ft,Hr,Gr,Vt,Xr,Ur,Nt,Zr,Jr,ht,Yr,Kr,St,Qr,ea,Wt,ta,oa,Bt,ra,aa,Ht,sa,na,$o,pt,Gt,ia,Ro,qe,Eo,de,la,Ae,da,ca,xo,K,ce,Xt,Fe,ma,Ut,ha,Po,A,Ve,pa,Q,fa,ft,ua,ga,Ne,_a,va,Ta,ee,ba,ut,Ca,wa,gt,ka,Oa,ya,me,Mo,te,he,Zt,Se,$a,Jt,Ra,jo,$,We,Ea,Yt,xa,Pa,x,_t,Ma,ja,Kt,za,La,Qt,Ia,Da,eo,qa,Aa,to,Fa,Va,Be,oo,Na,Sa,Wa,vt,Ba,Ha,Ga,pe,He,Xa,N,Ua,ro,Za,Ja,ao,Ya,Ka,so,Qa,es,ts,Z,Ge,os,no,rs,as,fe,ss,J,Xe,ns,Ue,is,Tt,ls,ds,cs,ue,ms,ge,Ze,hs,Je,ps,bt,fs,us,gs,_e,Ye,_s,Ke,vs,Ct,Ts,bs,zo,oe,ve,io,Qe,Cs,lo,ws,Lo,F,et,ks,S,Os,wt,ys,$s,co,Rs,Es,kt,xs,Ps,Ms,tt,js,ot,zs,Ls,Is,Te,rt,Ds,be,Io;return h=new jt({}),B=new jt({}),De=new jt({}),qe=new As({props:{code:`from transformers import TrOCRProcessor, VisionEncoderDecoderModel
import requests
from PIL import Image

processor = TrOCRProcessor.from_pretrained("microsoft/trocr-base-handwritten")
model = VisionEncoderDecoderModel.from_pretrained("microsoft/trocr-base-handwritten")

# load image from the IAM dataset
url = "https://fki.tic.heia-fr.ch/static/img/a01-122-02.jpg"
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")

pixel_values = processor(image, return_tensors="pt").pixel_values
generated_ids = model.generate(pixel_values)

generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]`,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>]`}}),Fe=new jt({}),Ve=new re({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:"classifier_dropout",val:" = 0.0"},{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.classifier_dropout",description:`<strong>classifier_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout ratio for classifier.`,name:"classifier_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"}}),me=new ti({props:{anchor:"transformers.TrOCRConfig.example",$$slots:{default:[di]},$$scope:{ctx:W}}}),Se=new jt({}),We=new re({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"}}),He=new re({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#L61"}}),Ge=new re({props:{name:"from_pretrained",anchor:"transformers.TrOCRProcessor.from_pretrained",parameters:[{name:"pretrained_model_name_or_path",val:""},{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#L157"}}),fe=new ei({props:{$$slots:{default:[ci]},$$scope:{ctx:W}}}),Xe=new re({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).
kwargs &#x2014;
Additional key word arguments passed along to the <a href="/docs/transformers/main/en/internal/image_processing_utils#transformers.ImageProcessingMixin.push_to_hub">push_to_hub()</a> method.`,name:"push_to_hub"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/processing_utils.py#L95"}}),ue=new ei({props:{$$slots:{default:[mi]},$$scope:{ctx:W}}}),Ze=new re({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#L94"}}),Ye=new re({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#L101"}}),Qe=new jt({}),et=new re({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#L786"}}),rt=new re({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#L819",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>
`}}),be=new ti({props:{anchor:"transformers.TrOCRForCausalLM.forward.example",$$slots:{default:[hi]},$$scope:{ctx:W}}}),{c(){f=s("meta"),R=c(),u=s("h1"),g=s("a"),T=s("span"),b(h.$$.fragment),_=c(),q=s("span"),I=r("TrOCR"),P=c(),j=s("h2"),M=s("a"),z=s("span"),b(B.$$.fragment),st=c(),ae=s("span"),er=r("Overview"),fo=c(),H=s("p"),tr=r("The TrOCR model was proposed in "),$e=s("a"),or=r(`TrOCR: Transformer-based Optical Character Recognition with Pre-trained
Models`),rr=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 `),Re=s("a"),ar=r("optical character recognition (OCR)"),sr=r("."),uo=c(),nt=s("p"),nr=r("The abstract from the paper is the following:"),go=c(),it=s("p"),zt=s("em"),ir=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.`),_o=c(),se=s("img"),vo=c(),ne=s("small"),lr=r("TrOCR architecture. Taken from the "),lt=s("a"),dr=r("original paper"),cr=r("."),To=c(),ie=s("p"),mr=r("Please refer to the "),Lt=s("code"),hr=r("VisionEncoderDecoder"),pr=r(" class on how to use this model."),bo=c(),G=s("p"),fr=r("This model was contributed by "),Ee=s("a"),ur=r("nielsr"),gr=r(`. The original code can be found
`),xe=s("a"),_r=r("here"),vr=r("."),Co=c(),dt=s("p"),Tr=r("Tips:"),wo=c(),X=s("ul"),Pe=s("li"),br=r("The quickest way to get started with TrOCR is by checking the "),Me=s("a"),Cr=r(`tutorial
notebooks`),wr=r(`, which show how to use the model
at inference time as well as fine-tuning on custom data.`),kr=c(),V=s("li"),Or=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 `),je=s("a"),yr=r("SROIE dataset"),$r=r(" and handwritten (e.g. the "),ze=s("a"),Rr=r(`IAM
Handwriting dataset`),Er=r(` text recognition tasks. For more
information, see the `),Le=s("a"),xr=r("official models"),Pr=r("."),Mr=c(),Ie=s("li"),jr=r("TrOCR is always used within the "),ct=s("a"),zr=r("VisionEncoderDecoder"),Lr=r(" framework."),ko=c(),Y=s("h2"),le=s("a"),It=s("span"),b(De.$$.fragment),Ir=c(),Dt=s("span"),Dr=r("Inference"),Oo=c(),U=s("p"),qr=r("TrOCR\u2019s "),qt=s("code"),Ar=r("VisionEncoderDecoder"),Fr=r(` model accepts images as input and makes use of
`),mt=s("a"),Vr=r("generate()"),Nr=r(" to autoregressively generate text given the input image."),yo=c(),v=s("p"),Sr=r("The ["),At=s("code"),Wr=r("ViTImageProcessor"),Br=r("/"),Ft=s("code"),Hr=r("DeiTImageProcessor"),Gr=r(`] class is responsible for preprocessing the input image and
[`),Vt=s("code"),Xr=r("RobertaTokenizer"),Ur=r("/"),Nt=s("code"),Zr=r("XLMRobertaTokenizer"),Jr=r(`] decodes the generated target tokens to the target string. The
`),ht=s("a"),Yr=r("TrOCRProcessor"),Kr=r(" wraps ["),St=s("code"),Qr=r("ViTImageProcessor"),ea=r("/"),Wt=s("code"),ta=r("DeiTImageProcessor"),oa=r("] and ["),Bt=s("code"),ra=r("RobertaTokenizer"),aa=r("/"),Ht=s("code"),sa=r("XLMRobertaTokenizer"),na=r(`]
into a single instance to both extract the input features and decode the predicted token ids.`),$o=c(),pt=s("ul"),Gt=s("li"),ia=r("Step-by-step Optical Character Recognition (OCR)"),Ro=c(),b(qe.$$.fragment),Eo=c(),de=s("p"),la=r("See the "),Ae=s("a"),da=r("model hub"),ca=r(" to look for TrOCR checkpoints."),xo=c(),K=s("h2"),ce=s("a"),Xt=s("span"),b(Fe.$$.fragment),ma=c(),Ut=s("span"),ha=r("TrOCRConfig"),Po=c(),A=s("div"),b(Ve.$$.fragment),pa=c(),Q=s("p"),fa=r("This is the configuration class to store the configuration of a "),ft=s("a"),ua=r("TrOCRForCausalLM"),ga=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
`),Ne=s("a"),_a=r("microsoft/trocr-base-handwritten"),va=r(" architecture."),Ta=c(),ee=s("p"),ba=r("Configuration objects inherit from "),ut=s("a"),Ca=r("PretrainedConfig"),wa=r(` and can be used to control the model outputs. Read the
documentation from `),gt=s("a"),ka=r("PretrainedConfig"),Oa=r(" for more information."),ya=c(),b(me.$$.fragment),Mo=c(),te=s("h2"),he=s("a"),Zt=s("span"),b(Se.$$.fragment),$a=c(),Jt=s("span"),Ra=r("TrOCRProcessor"),jo=c(),$=s("div"),b(We.$$.fragment),Ea=c(),Yt=s("p"),xa=r("Constructs a TrOCR processor which wraps a vision image processor and a TrOCR tokenizer into a single processor."),Pa=c(),x=s("p"),_t=s("a"),Ma=r("TrOCRProcessor"),ja=r(" offers all the functionalities of ["),Kt=s("code"),za=r("ViTImageProcessor"),La=r("/"),Qt=s("code"),Ia=r("DeiTImageProcessor"),Da=r(`] and
[`),eo=s("code"),qa=r("RobertaTokenizer"),Aa=r("/"),to=s("code"),Fa=r("XLMRobertaTokenizer"),Va=r("]. See the "),Be=s("a"),oo=s("strong"),Na=r("call"),Sa=r("()"),Wa=r(" and "),vt=s("a"),Ba=r("decode()"),Ha=r(` for
more information.`),Ga=c(),pe=s("div"),b(He.$$.fragment),Xa=c(),N=s("p"),Ua=r(`When used in normal mode, this method forwards all its arguments to AutoImageProcessor\u2019s
`),ro=s("code"),Za=r("__call__()"),Ja=r(` and returns its output. If used in the context
`),ao=s("code"),Ya=r("as_target_processor()"),Ka=r(` this method forwards all its arguments to TrOCRTokenizer\u2019s
`),so=s("code"),Qa=r("~TrOCRTokenizer.__call__"),es=r(". Please refer to the doctsring of the above two methods for more information."),ts=c(),Z=s("div"),b(Ge.$$.fragment),os=c(),no=s("p"),rs=r("Instantiate a processor associated with a pretrained model."),as=c(),b(fe.$$.fragment),ss=c(),J=s("div"),b(Xe.$$.fragment),ns=c(),Ue=s("p"),is=r(`Saves the attributes of this processor (feature extractor, tokenizer\u2026) in the specified directory so that it
can be reloaded using the `),Tt=s("a"),ls=r("from_pretrained()"),ds=r(" method."),cs=c(),b(ue.$$.fragment),ms=c(),ge=s("div"),b(Ze.$$.fragment),hs=c(),Je=s("p"),ps=r("This method forwards all its arguments to TrOCRTokenizer\u2019s "),bt=s("a"),fs=r("batch_decode()"),us=r(`. Please refer
to the docstring of this method for more information.`),gs=c(),_e=s("div"),b(Ye.$$.fragment),_s=c(),Ke=s("p"),vs=r("This method forwards all its arguments to TrOCRTokenizer\u2019s "),Ct=s("a"),Ts=r("decode()"),bs=r(`. Please refer to the
docstring of this method for more information.`),zo=c(),oe=s("h2"),ve=s("a"),io=s("span"),b(Qe.$$.fragment),Cs=c(),lo=s("span"),ws=r("TrOCRForCausalLM"),Lo=c(),F=s("div"),b(et.$$.fragment),ks=c(),S=s("p"),Os=r("The TrOCR Decoder with a language modeling head. Can be used as the decoder part of "),wt=s("a"),ys=r("EncoderDecoderModel"),$s=r(" and "),co=s("code"),Rs=r("VisionEncoderDecoder"),Es=r(`.
This model inherits from `),kt=s("a"),xs=r("PreTrainedModel"),Ps=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.)`),Ms=c(),tt=s("p"),js=r("This model is also a PyTorch "),ot=s("a"),zs=r("torch.nn.Module"),Ls=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Is=c(),Te=s("div"),b(rt.$$.fragment),Ds=c(),b(be.$$.fragment),this.h()},l(t){const d=ni('[data-svelte="svelte-1phssyn"]',document.head);f=n(d,"META",{name:!0,content:!0}),d.forEach(o),R=m(t),u=n(t,"H1",{class:!0});var at=i(u);g=n(at,"A",{id:!0,class:!0,href:!0});var mo=i(g);T=n(mo,"SPAN",{});var ho=i(T);C(h.$$.fragment,ho),ho.forEach(o),mo.forEach(o),_=m(at),q=n(at,"SPAN",{});var po=i(q);I=a(po,"TrOCR"),po.forEach(o),at.forEach(o),P=m(t),j=n(t,"H2",{class:!0});var Do=i(j);M=n(Do,"A",{id:!0,class:!0,href:!0});var Vs=i(M);z=n(Vs,"SPAN",{});var Ns=i(z);C(B.$$.fragment,Ns),Ns.forEach(o),Vs.forEach(o),st=m(Do),ae=n(Do,"SPAN",{});var Ss=i(ae);er=a(Ss,"Overview"),Ss.forEach(o),Do.forEach(o),fo=m(t),H=n(t,"P",{});var Ot=i(H);tr=a(Ot,"The TrOCR model was proposed in "),$e=n(Ot,"A",{href:!0,rel:!0});var Ws=i($e);or=a(Ws,`TrOCR: Transformer-based Optical Character Recognition with Pre-trained
Models`),Ws.forEach(o),rr=a(Ot,` 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 `),Re=n(Ot,"A",{href:!0,rel:!0});var Bs=i(Re);ar=a(Bs,"optical character recognition (OCR)"),Bs.forEach(o),sr=a(Ot,"."),Ot.forEach(o),uo=m(t),nt=n(t,"P",{});var Hs=i(nt);nr=a(Hs,"The abstract from the paper is the following:"),Hs.forEach(o),go=m(t),it=n(t,"P",{});var Gs=i(it);zt=n(Gs,"EM",{});var Xs=i(zt);ir=a(Xs,`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.`),Xs.forEach(o),Gs.forEach(o),_o=m(t),se=n(t,"IMG",{src:!0,alt:!0,width:!0}),vo=m(t),ne=n(t,"SMALL",{});var qo=i(ne);lr=a(qo,"TrOCR architecture. Taken from the "),lt=n(qo,"A",{href:!0});var Us=i(lt);dr=a(Us,"original paper"),Us.forEach(o),cr=a(qo,"."),qo.forEach(o),To=m(t),ie=n(t,"P",{});var Ao=i(ie);mr=a(Ao,"Please refer to the "),Lt=n(Ao,"CODE",{});var Zs=i(Lt);hr=a(Zs,"VisionEncoderDecoder"),Zs.forEach(o),pr=a(Ao," class on how to use this model."),Ao.forEach(o),bo=m(t),G=n(t,"P",{});var yt=i(G);fr=a(yt,"This model was contributed by "),Ee=n(yt,"A",{href:!0,rel:!0});var Js=i(Ee);ur=a(Js,"nielsr"),Js.forEach(o),gr=a(yt,`. The original code can be found
`),xe=n(yt,"A",{href:!0,rel:!0});var Ys=i(xe);_r=a(Ys,"here"),Ys.forEach(o),vr=a(yt,"."),yt.forEach(o),Co=m(t),dt=n(t,"P",{});var Ks=i(dt);Tr=a(Ks,"Tips:"),Ks.forEach(o),wo=m(t),X=n(t,"UL",{});var $t=i(X);Pe=n($t,"LI",{});var Fo=i(Pe);br=a(Fo,"The quickest way to get started with TrOCR is by checking the "),Me=n(Fo,"A",{href:!0,rel:!0});var Qs=i(Me);Cr=a(Qs,`tutorial
notebooks`),Qs.forEach(o),wr=a(Fo,`, which show how to use the model
at inference time as well as fine-tuning on custom data.`),Fo.forEach(o),kr=m($t),V=n($t,"LI",{});var Ce=i(V);Or=a(Ce,`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 `),je=n(Ce,"A",{href:!0,rel:!0});var en=i(je);yr=a(en,"SROIE dataset"),en.forEach(o),$r=a(Ce," and handwritten (e.g. the "),ze=n(Ce,"A",{href:!0,rel:!0});var tn=i(ze);Rr=a(tn,`IAM
Handwriting dataset`),tn.forEach(o),Er=a(Ce,` text recognition tasks. For more
information, see the `),Le=n(Ce,"A",{href:!0,rel:!0});var on=i(Le);xr=a(on,"official models"),on.forEach(o),Pr=a(Ce,"."),Ce.forEach(o),Mr=m($t),Ie=n($t,"LI",{});var Vo=i(Ie);jr=a(Vo,"TrOCR is always used within the "),ct=n(Vo,"A",{href:!0});var rn=i(ct);zr=a(rn,"VisionEncoderDecoder"),rn.forEach(o),Lr=a(Vo," framework."),Vo.forEach(o),$t.forEach(o),ko=m(t),Y=n(t,"H2",{class:!0});var No=i(Y);le=n(No,"A",{id:!0,class:!0,href:!0});var an=i(le);It=n(an,"SPAN",{});var sn=i(It);C(De.$$.fragment,sn),sn.forEach(o),an.forEach(o),Ir=m(No),Dt=n(No,"SPAN",{});var nn=i(Dt);Dr=a(nn,"Inference"),nn.forEach(o),No.forEach(o),Oo=m(t),U=n(t,"P",{});var Rt=i(U);qr=a(Rt,"TrOCR\u2019s "),qt=n(Rt,"CODE",{});var ln=i(qt);Ar=a(ln,"VisionEncoderDecoder"),ln.forEach(o),Fr=a(Rt,` model accepts images as input and makes use of
`),mt=n(Rt,"A",{href:!0});var dn=i(mt);Vr=a(dn,"generate()"),dn.forEach(o),Nr=a(Rt," to autoregressively generate text given the input image."),Rt.forEach(o),yo=m(t),v=n(t,"P",{});var E=i(v);Sr=a(E,"The ["),At=n(E,"CODE",{});var cn=i(At);Wr=a(cn,"ViTImageProcessor"),cn.forEach(o),Br=a(E,"/"),Ft=n(E,"CODE",{});var mn=i(Ft);Hr=a(mn,"DeiTImageProcessor"),mn.forEach(o),Gr=a(E,`] class is responsible for preprocessing the input image and
[`),Vt=n(E,"CODE",{});var hn=i(Vt);Xr=a(hn,"RobertaTokenizer"),hn.forEach(o),Ur=a(E,"/"),Nt=n(E,"CODE",{});var pn=i(Nt);Zr=a(pn,"XLMRobertaTokenizer"),pn.forEach(o),Jr=a(E,`] decodes the generated target tokens to the target string. The
`),ht=n(E,"A",{href:!0});var fn=i(ht);Yr=a(fn,"TrOCRProcessor"),fn.forEach(o),Kr=a(E," wraps ["),St=n(E,"CODE",{});var un=i(St);Qr=a(un,"ViTImageProcessor"),un.forEach(o),ea=a(E,"/"),Wt=n(E,"CODE",{});var gn=i(Wt);ta=a(gn,"DeiTImageProcessor"),gn.forEach(o),oa=a(E,"] and ["),Bt=n(E,"CODE",{});var _n=i(Bt);ra=a(_n,"RobertaTokenizer"),_n.forEach(o),aa=a(E,"/"),Ht=n(E,"CODE",{});var vn=i(Ht);sa=a(vn,"XLMRobertaTokenizer"),vn.forEach(o),na=a(E,`]
into a single instance to both extract the input features and decode the predicted token ids.`),E.forEach(o),$o=m(t),pt=n(t,"UL",{});var Tn=i(pt);Gt=n(Tn,"LI",{});var bn=i(Gt);ia=a(bn,"Step-by-step Optical Character Recognition (OCR)"),bn.forEach(o),Tn.forEach(o),Ro=m(t),C(qe.$$.fragment,t),Eo=m(t),de=n(t,"P",{});var So=i(de);la=a(So,"See the "),Ae=n(So,"A",{href:!0,rel:!0});var Cn=i(Ae);da=a(Cn,"model hub"),Cn.forEach(o),ca=a(So," to look for TrOCR checkpoints."),So.forEach(o),xo=m(t),K=n(t,"H2",{class:!0});var Wo=i(K);ce=n(Wo,"A",{id:!0,class:!0,href:!0});var wn=i(ce);Xt=n(wn,"SPAN",{});var kn=i(Xt);C(Fe.$$.fragment,kn),kn.forEach(o),wn.forEach(o),ma=m(Wo),Ut=n(Wo,"SPAN",{});var On=i(Ut);ha=a(On,"TrOCRConfig"),On.forEach(o),Wo.forEach(o),Po=m(t),A=n(t,"DIV",{class:!0});var we=i(A);C(Ve.$$.fragment,we),pa=m(we),Q=n(we,"P",{});var Et=i(Q);fa=a(Et,"This is the configuration class to store the configuration of a "),ft=n(Et,"A",{href:!0});var yn=i(ft);ua=a(yn,"TrOCRForCausalLM"),yn.forEach(o),ga=a(Et,`. 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
`),Ne=n(Et,"A",{href:!0,rel:!0});var $n=i(Ne);_a=a($n,"microsoft/trocr-base-handwritten"),$n.forEach(o),va=a(Et," architecture."),Et.forEach(o),Ta=m(we),ee=n(we,"P",{});var xt=i(ee);ba=a(xt,"Configuration objects inherit from "),ut=n(xt,"A",{href:!0});var Rn=i(ut);Ca=a(Rn,"PretrainedConfig"),Rn.forEach(o),wa=a(xt,` and can be used to control the model outputs. Read the
documentation from `),gt=n(xt,"A",{href:!0});var En=i(gt);ka=a(En,"PretrainedConfig"),En.forEach(o),Oa=a(xt," for more information."),xt.forEach(o),ya=m(we),C(me.$$.fragment,we),we.forEach(o),Mo=m(t),te=n(t,"H2",{class:!0});var Bo=i(te);he=n(Bo,"A",{id:!0,class:!0,href:!0});var xn=i(he);Zt=n(xn,"SPAN",{});var Pn=i(Zt);C(Se.$$.fragment,Pn),Pn.forEach(o),xn.forEach(o),$a=m(Bo),Jt=n(Bo,"SPAN",{});var Mn=i(Jt);Ra=a(Mn,"TrOCRProcessor"),Mn.forEach(o),Bo.forEach(o),jo=m(t),$=n(t,"DIV",{class:!0});var L=i($);C(We.$$.fragment,L),Ea=m(L),Yt=n(L,"P",{});var jn=i(Yt);xa=a(jn,"Constructs a TrOCR processor which wraps a vision image processor and a TrOCR tokenizer into a single processor."),jn.forEach(o),Pa=m(L),x=n(L,"P",{});var D=i(x);_t=n(D,"A",{href:!0});var zn=i(_t);Ma=a(zn,"TrOCRProcessor"),zn.forEach(o),ja=a(D," offers all the functionalities of ["),Kt=n(D,"CODE",{});var Ln=i(Kt);za=a(Ln,"ViTImageProcessor"),Ln.forEach(o),La=a(D,"/"),Qt=n(D,"CODE",{});var In=i(Qt);Ia=a(In,"DeiTImageProcessor"),In.forEach(o),Da=a(D,`] and
[`),eo=n(D,"CODE",{});var Dn=i(eo);qa=a(Dn,"RobertaTokenizer"),Dn.forEach(o),Aa=a(D,"/"),to=n(D,"CODE",{});var qn=i(to);Fa=a(qn,"XLMRobertaTokenizer"),qn.forEach(o),Va=a(D,"]. See the "),Be=n(D,"A",{href:!0});var qs=i(Be);oo=n(qs,"STRONG",{});var An=i(oo);Na=a(An,"call"),An.forEach(o),Sa=a(qs,"()"),qs.forEach(o),Wa=a(D," and "),vt=n(D,"A",{href:!0});var Fn=i(vt);Ba=a(Fn,"decode()"),Fn.forEach(o),Ha=a(D,` for
more information.`),D.forEach(o),Ga=m(L),pe=n(L,"DIV",{class:!0});var Ho=i(pe);C(He.$$.fragment,Ho),Xa=m(Ho),N=n(Ho,"P",{});var ke=i(N);Ua=a(ke,`When used in normal mode, this method forwards all its arguments to AutoImageProcessor\u2019s
`),ro=n(ke,"CODE",{});var Vn=i(ro);Za=a(Vn,"__call__()"),Vn.forEach(o),Ja=a(ke,` and returns its output. If used in the context
`),ao=n(ke,"CODE",{});var Nn=i(ao);Ya=a(Nn,"as_target_processor()"),Nn.forEach(o),Ka=a(ke,` this method forwards all its arguments to TrOCRTokenizer\u2019s
`),so=n(ke,"CODE",{});var Sn=i(so);Qa=a(Sn,"~TrOCRTokenizer.__call__"),Sn.forEach(o),es=a(ke,". Please refer to the doctsring of the above two methods for more information."),ke.forEach(o),Ho.forEach(o),ts=m(L),Z=n(L,"DIV",{class:!0});var Pt=i(Z);C(Ge.$$.fragment,Pt),os=m(Pt),no=n(Pt,"P",{});var Wn=i(no);rs=a(Wn,"Instantiate a processor associated with a pretrained model."),Wn.forEach(o),as=m(Pt),C(fe.$$.fragment,Pt),Pt.forEach(o),ss=m(L),J=n(L,"DIV",{class:!0});var Mt=i(J);C(Xe.$$.fragment,Mt),ns=m(Mt),Ue=n(Mt,"P",{});var Go=i(Ue);is=a(Go,`Saves the attributes of this processor (feature extractor, tokenizer\u2026) in the specified directory so that it
can be reloaded using the `),Tt=n(Go,"A",{href:!0});var Bn=i(Tt);ls=a(Bn,"from_pretrained()"),Bn.forEach(o),ds=a(Go," method."),Go.forEach(o),cs=m(Mt),C(ue.$$.fragment,Mt),Mt.forEach(o),ms=m(L),ge=n(L,"DIV",{class:!0});var Xo=i(ge);C(Ze.$$.fragment,Xo),hs=m(Xo),Je=n(Xo,"P",{});var Uo=i(Je);ps=a(Uo,"This method forwards all its arguments to TrOCRTokenizer\u2019s "),bt=n(Uo,"A",{href:!0});var Hn=i(bt);fs=a(Hn,"batch_decode()"),Hn.forEach(o),us=a(Uo,`. Please refer
to the docstring of this method for more information.`),Uo.forEach(o),Xo.forEach(o),gs=m(L),_e=n(L,"DIV",{class:!0});var Zo=i(_e);C(Ye.$$.fragment,Zo),_s=m(Zo),Ke=n(Zo,"P",{});var Jo=i(Ke);vs=a(Jo,"This method forwards all its arguments to TrOCRTokenizer\u2019s "),Ct=n(Jo,"A",{href:!0});var Gn=i(Ct);Ts=a(Gn,"decode()"),Gn.forEach(o),bs=a(Jo,`. Please refer to the
docstring of this method for more information.`),Jo.forEach(o),Zo.forEach(o),L.forEach(o),zo=m(t),oe=n(t,"H2",{class:!0});var Yo=i(oe);ve=n(Yo,"A",{id:!0,class:!0,href:!0});var Xn=i(ve);io=n(Xn,"SPAN",{});var Un=i(io);C(Qe.$$.fragment,Un),Un.forEach(o),Xn.forEach(o),Cs=m(Yo),lo=n(Yo,"SPAN",{});var Zn=i(lo);ws=a(Zn,"TrOCRForCausalLM"),Zn.forEach(o),Yo.forEach(o),Lo=m(t),F=n(t,"DIV",{class:!0});var Oe=i(F);C(et.$$.fragment,Oe),ks=m(Oe),S=n(Oe,"P",{});var ye=i(S);Os=a(ye,"The TrOCR Decoder with a language modeling head. Can be used as the decoder part of "),wt=n(ye,"A",{href:!0});var Jn=i(wt);ys=a(Jn,"EncoderDecoderModel"),Jn.forEach(o),$s=a(ye," and "),co=n(ye,"CODE",{});var Yn=i(co);Rs=a(Yn,"VisionEncoderDecoder"),Yn.forEach(o),Es=a(ye,`.
This model inherits from `),kt=n(ye,"A",{href:!0});var Kn=i(kt);xs=a(Kn,"PreTrainedModel"),Kn.forEach(o),Ps=a(ye,`. 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.)`),ye.forEach(o),Ms=m(Oe),tt=n(Oe,"P",{});var Ko=i(tt);js=a(Ko,"This model is also a PyTorch "),ot=n(Ko,"A",{href:!0,rel:!0});var Qn=i(ot);zs=a(Qn,"torch.nn.Module"),Qn.forEach(o),Ls=a(Ko,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ko.forEach(o),Is=m(Oe),Te=n(Oe,"DIV",{class:!0});var Qo=i(Te);C(rt.$$.fragment,Qo),Ds=m(Qo),C(be.$$.fragment,Qo),Qo.forEach(o),Oe.forEach(o),this.h()},h(){l(f,"name","hf:doc:metadata"),l(f,"content",JSON.stringify(fi)),l(g,"id","trocr"),l(g,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(g,"href","#trocr"),l(u,"class","relative group"),l(M,"id","overview"),l(M,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(M,"href","#overview"),l(j,"class","relative group"),l($e,"href","https://arxiv.org/abs/2109.10282"),l($e,"rel","nofollow"),l(Re,"href","https://en.wikipedia.org/wiki/Optical_character_recognition"),l(Re,"rel","nofollow"),ii(se.src,Fs="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/trocr_architecture.jpg")||l(se,"src",Fs),l(se,"alt","drawing"),l(se,"width","600"),l(lt,"href","https://arxiv.org/abs/2109.10282"),l(Ee,"href","https://huggingface.co/nielsr"),l(Ee,"rel","nofollow"),l(xe,"href","https://github.com/microsoft/unilm/tree/6f60612e7cc86a2a1ae85c47231507a587ab4e01/trocr"),l(xe,"rel","nofollow"),l(Me,"href","https://github.com/NielsRogge/Transformers-Tutorials/tree/master/TrOCR"),l(Me,"rel","nofollow"),l(je,"href","https://paperswithcode.com/dataset/sroie"),l(je,"rel","nofollow"),l(ze,"href","https://fki.tic.heia-fr.ch/databases/iam-handwriting-database%3E"),l(ze,"rel","nofollow"),l(Le,"href","https://huggingface.co/models?other=trocr%3E"),l(Le,"rel","nofollow"),l(ct,"href","vision-encoder-decoder"),l(le,"id","inference"),l(le,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(le,"href","#inference"),l(Y,"class","relative group"),l(mt,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.generate"),l(ht,"href","/docs/transformers/main/en/model_doc/trocr#transformers.TrOCRProcessor"),l(Ae,"href","https://huggingface.co/models?filter=trocr"),l(Ae,"rel","nofollow"),l(ce,"id","transformers.TrOCRConfig"),l(ce,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(ce,"href","#transformers.TrOCRConfig"),l(K,"class","relative group"),l(ft,"href","/docs/transformers/main/en/model_doc/trocr#transformers.TrOCRForCausalLM"),l(Ne,"href","https://huggingface.co/microsoft/trocr-base-handwritten"),l(Ne,"rel","nofollow"),l(ut,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),l(gt,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),l(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(he,"id","transformers.TrOCRProcessor"),l(he,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(he,"href","#transformers.TrOCRProcessor"),l(te,"class","relative group"),l(_t,"href","/docs/transformers/main/en/model_doc/trocr#transformers.TrOCRProcessor"),l(Be,"href","/docs/transformers/main/en/model_doc/trocr#transformers.TrOCRProcessor.__call__"),l(vt,"href","/docs/transformers/main/en/model_doc/trocr#transformers.TrOCRProcessor.decode"),l(pe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(Tt,"href","/docs/transformers/main/en/model_doc/trocr#transformers.TrOCRProcessor.from_pretrained"),l(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(bt,"href","/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.batch_decode"),l(ge,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(Ct,"href","/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.decode"),l(_e,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ve,"id","transformers.TrOCRForCausalLM"),l(ve,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(ve,"href","#transformers.TrOCRForCausalLM"),l(oe,"class","relative group"),l(wt,"href","/docs/transformers/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),l(kt,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),l(ot,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(ot,"rel","nofollow"),l(Te,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(F,"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),p(t,R,d),p(t,u,d),e(u,g),e(g,T),w(h,T,null),e(u,_),e(u,q),e(q,I),p(t,P,d),p(t,j,d),e(j,M),e(M,z),w(B,z,null),e(j,st),e(j,ae),e(ae,er),p(t,fo,d),p(t,H,d),e(H,tr),e(H,$e),e($e,or),e(H,rr),e(H,Re),e(Re,ar),e(H,sr),p(t,uo,d),p(t,nt,d),e(nt,nr),p(t,go,d),p(t,it,d),e(it,zt),e(zt,ir),p(t,_o,d),p(t,se,d),p(t,vo,d),p(t,ne,d),e(ne,lr),e(ne,lt),e(lt,dr),e(ne,cr),p(t,To,d),p(t,ie,d),e(ie,mr),e(ie,Lt),e(Lt,hr),e(ie,pr),p(t,bo,d),p(t,G,d),e(G,fr),e(G,Ee),e(Ee,ur),e(G,gr),e(G,xe),e(xe,_r),e(G,vr),p(t,Co,d),p(t,dt,d),e(dt,Tr),p(t,wo,d),p(t,X,d),e(X,Pe),e(Pe,br),e(Pe,Me),e(Me,Cr),e(Pe,wr),e(X,kr),e(X,V),e(V,Or),e(V,je),e(je,yr),e(V,$r),e(V,ze),e(ze,Rr),e(V,Er),e(V,Le),e(Le,xr),e(V,Pr),e(X,Mr),e(X,Ie),e(Ie,jr),e(Ie,ct),e(ct,zr),e(Ie,Lr),p(t,ko,d),p(t,Y,d),e(Y,le),e(le,It),w(De,It,null),e(Y,Ir),e(Y,Dt),e(Dt,Dr),p(t,Oo,d),p(t,U,d),e(U,qr),e(U,qt),e(qt,Ar),e(U,Fr),e(U,mt),e(mt,Vr),e(U,Nr),p(t,yo,d),p(t,v,d),e(v,Sr),e(v,At),e(At,Wr),e(v,Br),e(v,Ft),e(Ft,Hr),e(v,Gr),e(v,Vt),e(Vt,Xr),e(v,Ur),e(v,Nt),e(Nt,Zr),e(v,Jr),e(v,ht),e(ht,Yr),e(v,Kr),e(v,St),e(St,Qr),e(v,ea),e(v,Wt),e(Wt,ta),e(v,oa),e(v,Bt),e(Bt,ra),e(v,aa),e(v,Ht),e(Ht,sa),e(v,na),p(t,$o,d),p(t,pt,d),e(pt,Gt),e(Gt,ia),p(t,Ro,d),w(qe,t,d),p(t,Eo,d),p(t,de,d),e(de,la),e(de,Ae),e(Ae,da),e(de,ca),p(t,xo,d),p(t,K,d),e(K,ce),e(ce,Xt),w(Fe,Xt,null),e(K,ma),e(K,Ut),e(Ut,ha),p(t,Po,d),p(t,A,d),w(Ve,A,null),e(A,pa),e(A,Q),e(Q,fa),e(Q,ft),e(ft,ua),e(Q,ga),e(Q,Ne),e(Ne,_a),e(Q,va),e(A,Ta),e(A,ee),e(ee,ba),e(ee,ut),e(ut,Ca),e(ee,wa),e(ee,gt),e(gt,ka),e(ee,Oa),e(A,ya),w(me,A,null),p(t,Mo,d),p(t,te,d),e(te,he),e(he,Zt),w(Se,Zt,null),e(te,$a),e(te,Jt),e(Jt,Ra),p(t,jo,d),p(t,$,d),w(We,$,null),e($,Ea),e($,Yt),e(Yt,xa),e($,Pa),e($,x),e(x,_t),e(_t,Ma),e(x,ja),e(x,Kt),e(Kt,za),e(x,La),e(x,Qt),e(Qt,Ia),e(x,Da),e(x,eo),e(eo,qa),e(x,Aa),e(x,to),e(to,Fa),e(x,Va),e(x,Be),e(Be,oo),e(oo,Na),e(Be,Sa),e(x,Wa),e(x,vt),e(vt,Ba),e(x,Ha),e($,Ga),e($,pe),w(He,pe,null),e(pe,Xa),e(pe,N),e(N,Ua),e(N,ro),e(ro,Za),e(N,Ja),e(N,ao),e(ao,Ya),e(N,Ka),e(N,so),e(so,Qa),e(N,es),e($,ts),e($,Z),w(Ge,Z,null),e(Z,os),e(Z,no),e(no,rs),e(Z,as),w(fe,Z,null),e($,ss),e($,J),w(Xe,J,null),e(J,ns),e(J,Ue),e(Ue,is),e(Ue,Tt),e(Tt,ls),e(Ue,ds),e(J,cs),w(ue,J,null),e($,ms),e($,ge),w(Ze,ge,null),e(ge,hs),e(ge,Je),e(Je,ps),e(Je,bt),e(bt,fs),e(Je,us),e($,gs),e($,_e),w(Ye,_e,null),e(_e,_s),e(_e,Ke),e(Ke,vs),e(Ke,Ct),e(Ct,Ts),e(Ke,bs),p(t,zo,d),p(t,oe,d),e(oe,ve),e(ve,io),w(Qe,io,null),e(oe,Cs),e(oe,lo),e(lo,ws),p(t,Lo,d),p(t,F,d),w(et,F,null),e(F,ks),e(F,S),e(S,Os),e(S,wt),e(wt,ys),e(S,$s),e(S,co),e(co,Rs),e(S,Es),e(S,kt),e(kt,xs),e(S,Ps),e(F,Ms),e(F,tt),e(tt,js),e(tt,ot),e(ot,zs),e(tt,Ls),e(F,Is),e(F,Te),w(rt,Te,null),e(Te,Ds),w(be,Te,null),Io=!0},p(t,[d]){const at={};d&2&&(at.$$scope={dirty:d,ctx:t}),me.$set(at);const mo={};d&2&&(mo.$$scope={dirty:d,ctx:t}),fe.$set(mo);const ho={};d&2&&(ho.$$scope={dirty:d,ctx:t}),ue.$set(ho);const po={};d&2&&(po.$$scope={dirty:d,ctx:t}),be.$set(po)},i(t){Io||(k(h.$$.fragment,t),k(B.$$.fragment,t),k(De.$$.fragment,t),k(qe.$$.fragment,t),k(Fe.$$.fragment,t),k(Ve.$$.fragment,t),k(me.$$.fragment,t),k(Se.$$.fragment,t),k(We.$$.fragment,t),k(He.$$.fragment,t),k(Ge.$$.fragment,t),k(fe.$$.fragment,t),k(Xe.$$.fragment,t),k(ue.$$.fragment,t),k(Ze.$$.fragment,t),k(Ye.$$.fragment,t),k(Qe.$$.fragment,t),k(et.$$.fragment,t),k(rt.$$.fragment,t),k(be.$$.fragment,t),Io=!0)},o(t){O(h.$$.fragment,t),O(B.$$.fragment,t),O(De.$$.fragment,t),O(qe.$$.fragment,t),O(Fe.$$.fragment,t),O(Ve.$$.fragment,t),O(me.$$.fragment,t),O(Se.$$.fragment,t),O(We.$$.fragment,t),O(He.$$.fragment,t),O(Ge.$$.fragment,t),O(fe.$$.fragment,t),O(Xe.$$.fragment,t),O(ue.$$.fragment,t),O(Ze.$$.fragment,t),O(Ye.$$.fragment,t),O(Qe.$$.fragment,t),O(et.$$.fragment,t),O(rt.$$.fragment,t),O(be.$$.fragment,t),Io=!1},d(t){o(f),t&&o(R),t&&o(u),y(h),t&&o(P),t&&o(j),y(B),t&&o(fo),t&&o(H),t&&o(uo),t&&o(nt),t&&o(go),t&&o(it),t&&o(_o),t&&o(se),t&&o(vo),t&&o(ne),t&&o(To),t&&o(ie),t&&o(bo),t&&o(G),t&&o(Co),t&&o(dt),t&&o(wo),t&&o(X),t&&o(ko),t&&o(Y),y(De),t&&o(Oo),t&&o(U),t&&o(yo),t&&o(v),t&&o($o),t&&o(pt),t&&o(Ro),y(qe,t),t&&o(Eo),t&&o(de),t&&o(xo),t&&o(K),y(Fe),t&&o(Po),t&&o(A),y(Ve),y(me),t&&o(Mo),t&&o(te),y(Se),t&&o(jo),t&&o($),y(We),y(He),y(Ge),y(fe),y(Xe),y(ue),y(Ze),y(Ye),t&&o(zo),t&&o(oe),y(Qe),t&&o(Lo),t&&o(F),y(et),y(rt),y(be)}}}const fi={local:"trocr",sections:[{local:"overview",title:"Overview"},{local:"inference",title:"Inference"},{local:"transformers.TrOCRConfig",title:"TrOCRConfig"},{local:"transformers.TrOCRProcessor",title:"TrOCRProcessor"},{local:"transformers.TrOCRForCausalLM",title:"TrOCRForCausalLM"}],title:"TrOCR"};function ui(W){return li(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class wi extends ri{constructor(f){super();ai(this,f,ui,pi,si,{})}}export{wi as default,fi as metadata};
