import{s as Js,A as ws,o as Is,n as Xo}from"../chunks/scheduler.01eeda35.js";import{S as Us,i as Gs,g as i,s,r as l,A as Cs,h as c,f as o,c as a,j as M,u as m,x as u,k as y,y as r,a as n,v as d,d as p,t as h,w as g}from"../chunks/index.6dd51b66.js";import{T as xs}from"../chunks/Tip.de9bae2b.js";import{D as I}from"../chunks/Docstring.76e6b3cf.js";import{C as O}from"../chunks/CodeBlock.864da1b0.js";import{E as vs}from"../chunks/ExampleCodeBlock.6a36fb6b.js";import{H as j,E as Zs}from"../chunks/EditOnGithub.7faefd25.js";function Rs(N){let f,w;return f=new O({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEdvdE9jcjJGb3JDb25kaXRpb25hbEdlbmVyYXRpb24lMkMlMjBHb3RPY3IyQ29uZmlnJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMEdvdE9jcjIlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwR290T2NyMkNvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMG1vZGVsJTIwZnJvbSUyMHRoZSUyMFF3ZW4yLVZMLTdCJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBHb3RPY3IyRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uKGNvbmZpZ3VyYXRpb24pJTBBJTBBJTIzJTIwQWNjZXNzaW5nJTIwdGhlJTIwbW9kZWwlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMG1vZGVsLmNvbmZpZw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GotOcr2ForConditionalGeneration, GotOcr2Config

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

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model from the Qwen2-VL-7B style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = GotOcr2ForConditionalGeneration(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`,wrap:!1}}),{c(){l(f.$$.fragment)},l(_){m(f.$$.fragment,_)},m(_,T){d(f,_,T),w=!0},p:Xo,i(_){w||(p(f.$$.fragment,_),w=!0)},o(_){h(f.$$.fragment,_),w=!1},d(_){g(f,_)}}}function zs(N){let f,w=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){f=i("p"),f.innerHTML=w},l(_){f=c(_,"P",{"data-svelte-h":!0}),u(f)!=="svelte-fincs2"&&(f.innerHTML=w)},m(_,T){n(_,f,T)},p:Xo,d(_){_&&o(f)}}}function ks(N){let f,w="Example:",_,T,R;return T=new O({props:{code:"ZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Byb2Nlc3NvciUyQyUyMEdvdE9jcjJGb3JDb25kaXRpb25hbEdlbmVyYXRpb24lMkMlMjBUZXh0U3RyZWFtZXIlMEElMEFtb2RlbCUyMCUzRCUyMEdvdE9jcjJGb3JDb25kaXRpb25hbEdlbmVyYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMnN0ZXBmdW4tYWklMkZHT1QtT0NSLTIuMC1oZiUyMikudG8oJTIyY3VkYSUyMiklMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJzdGVwZnVuLWFpJTJGR09ULU9DUi0yLjAtaGYlMjIpJTBBJTBBdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaGYtaW50ZXJuYWwtdGVzdGluZyUyRmZpeHR1cmVzX2dvdF9vY3IlMkZyZXNvbHZlJTJGbWFpbiUyRm11bHRpX2JveC5wbmclMjIlMEFpbWFnZSUyMCUzRCUyMEltYWdlLm9wZW4ocmVxdWVzdHMuZ2V0KHVybCUyQyUyMHN0cmVhbSUzRFRydWUpLnJhdyklMEElMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IoaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTJDJTIwY29sb3IlM0QlMjJncmVlbiUyMikudG8oJTIyY3VkYSUyMiklMEElMEElMjMlMjBHZW5lcmF0ZSUwQXN0cmVhbWVyJTIwJTNEJTIwVGV4dFN0cmVhbWVyKHByb2Nlc3Nvci50b2tlbml6ZXIlMkMlMjBza2lwX3Byb21wdCUzRFRydWUlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSklMEFnZW5lcmF0ZV9pZHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSglMEElMjAlMjAlMjAlMjAqKmlucHV0cyUyQyUwQSUyMCUyMCUyMCUyMGRvX3NhbXBsZSUzREZhbHNlJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW5pemVyJTIwJTNEJTIwcHJvY2Vzc29yLnRva2VuaXplciUyQyUwQSUyMCUyMCUyMCUyMHN0b3Bfc3RyaW5ncyUzRCclM0MlN0NpbV9lbmQlN0MlM0UnJTJDJTBBJTIwJTIwJTIwJTIwc3RyZWFtZXIlM0RzdHJlYW1lciUyQyUwQSUyMCUyMCUyMCUyMG1heF9uZXdfdG9rZW5zJTNENDA5NiUyQyUwQSk=",highlighted:`<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-keyword">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, GotOcr2ForConditionalGeneration, TextStreamer

<span class="hljs-meta">&gt;&gt;&gt; </span>model = GotOcr2ForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;stepfun-ai/GOT-OCR-2.0-hf&quot;</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;stepfun-ai/GOT-OCR-2.0-hf&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/fixtures_got_ocr/resolve/main/multi_box.png&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)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>, color=<span class="hljs-string">&quot;green&quot;</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Generate</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>streamer = TextStreamer(processor.tokenizer, skip_prompt=<span class="hljs-literal">True</span>, skip_special_tokens=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>generate_ids = model.generate(
<span class="hljs-meta">... </span>    **inputs,
<span class="hljs-meta">... </span>    do_sample=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    tokenizer = processor.tokenizer,
<span class="hljs-meta">... </span>    stop_strings=<span class="hljs-string">&#x27;&lt;|im_end|&gt;&#x27;</span>,
<span class="hljs-meta">... </span>    streamer=streamer,
<span class="hljs-meta">... </span>    max_new_tokens=<span class="hljs-number">4096</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-string">&quot;You should keep in mind what features from the module should be used, especially
when you&#x27;re planning to sell a template.&quot;</span>`,wrap:!1}}),{c(){f=i("p"),f.textContent=w,_=s(),l(T.$$.fragment)},l(b){f=c(b,"P",{"data-svelte-h":!0}),u(f)!=="svelte-11lpom8"&&(f.textContent=w),_=a(b),m(T.$$.fragment,b)},m(b,z){n(b,f,z),n(b,_,z),d(T,b,z),R=!0},p:Xo,i(b){R||(p(T.$$.fragment,b),R=!0)},o(b){h(T.$$.fragment,b),R=!1},d(b){b&&(o(f),o(_)),g(T,b)}}}function Ws(N){let f,w,_,T,R,b,z,Po='<img alt="PyTorch" src="https://img.shields.io/badge/PyTorch-DE3412?style=flat&amp;logo=pytorch&amp;logoColor=white"/>',ft,te,ut,oe,Qo='The GOT-OCR2 model was proposed in <a href="https://arxiv.org/abs/2409.01704" rel="nofollow">General OCR Theory: Towards OCR-2.0 via a Unified End-to-end Model</a> by Haoran Wei, Chenglong Liu, Jinyue Chen, Jia Wang, Lingyu Kong, Yanming Xu, Zheng Ge, Liang Zhao, Jianjian Sun, Yuang Peng, Chunrui Han, Xiangyu Zhang.',_t,se,Eo="The abstract from the paper is the following:",yt,ae,Ho="<em>Traditional OCR systems (OCR-1.0) are increasingly unable to meet people’snusage due to the growing demand for intelligent processing of man-made opticalncharacters. In this paper, we collectively refer to all artificial optical signals (e.g., plain texts, math/molecular formulas, tables, charts, sheet music, and even geometric shapes) as “characters” and propose the General OCR Theory along with an excellent model, namely GOT, to promote the arrival of OCR-2.0. The GOT, with 580M parameters, is a unified, elegant, and end-to-end model, consisting of a high-compression encoder and a long-contexts decoder. As an OCR-2.0 model, GOT can handle all the above “characters” under various OCR tasks. On the input side, the model supports commonly used scene- and document-style images in slice and whole-page styles. On the output side, GOT can generate plain or formatted results (markdown/tikz/smiles/kern) via an easy prompt. Besides, the model enjoys interactive OCR features, i.e., region-level recognition guided by coordinates or colors. Furthermore, we also adapt dynamic resolution and multipage OCR technologies to GOT for better practicality. In experiments, we provide sufficient results to prove the superiority of our model.</em>",bt,B,So,Tt,ne,Yo='GOT-OCR2 training stages. Taken from the <a href="https://arxiv.org/abs/2409.01704">original paper.</a>',Mt,re,Ao="Tips:",jt,ie,Lo=`GOT-OCR2 works on a wide range of tasks, including plain document OCR, scene text OCR, formatted document OCR, and even OCR for tables, charts, mathematical formulas, geometric shapes, molecular formulas and sheet music. While this implementation of the model will only output plain text, the outputs can be further processed to render the desired format, with packages like <code>pdftex</code>, <code>mathpix</code>, <code>matplotlib</code>, <code>tikz</code>, <code>verovio</code> or <code>pyecharts</code>.
The model can also be used for interactive OCR, where the user can specify the region to be recognized by providing the coordinates or the color of the region’s bounding box.`,wt,ce,Do=`This model was contributed by <a href="https://huggingface.co/yonigozlan" rel="nofollow">yonigozlan</a>.
The original code can be found <a href="https://github.com/Ucas-HaoranWei/GOT-OCR2.0" rel="nofollow">here</a>.`,vt,le,Jt,me,It,de,Ut,pe,Gt,he,Ct,ge,xt,fe,Ko="GOT-OCR2 can also generate formatted text, such as markdown or LaTeX. Here is an example of how to generate formatted text:",Zt,ue,Rt,_e,zt,ye,es=`Although it might be reasonable in most cases to use a “for loop” for multi-page processing, some text data with formatting across several pages make it necessary to process all pages at once. GOT introduces a multi-page OCR (without “for loop”) feature, where multiple pages can be processed by the model at once, whith the output being one continuous text.
Here is an example of how to process multiple pages at once:`,kt,be,Wt,Te,$t,Me,ts=`GOT supports a 1024×1024 input resolution, which is sufficient for most OCR tasks, such as scene OCR or processing A4-sized PDF pages. However, certain scenarios, like horizontally stitched two-page PDFs commonly found in academic papers or images with unusual aspect ratios, can lead to accuracy issues when processed as a single image. To address this, GOT can dynamically crop an image into patches, process them all at once, and merge the results for better accuracy with such inputs.
Here is an example of how to process cropped patches:`,Ot,je,Nt,we,Bt,ve,os="GOT supports interactive OCR, where the user can specify the region to be recognized by providing the coordinates or the color of the region’s bounding box. Here is an example of how to process a specific region:",Vt,Je,Ft,Ie,qt,Ue,ss=`Although this implementation of the model will only output plain text, the outputs can be further processed to render the desired format, with packages like <code>pdftex</code>, <code>mathpix</code>, <code>matplotlib</code>, <code>tikz</code>, <code>verovio</code> or <code>pyecharts</code>.
Here is an example of how to process sheet music:`,Xt,Ge,Pt,V,as,Qt,Ce,Et,v,xe,go,Ae,ns=`This is the configuration class to store the configuration of a <a href="/docs/transformers/main/en/model_doc/got_ocr2#transformers.GotOcr2ForConditionalGeneration">GotOcr2ForConditionalGeneration</a>. It is used to instantiate a
GotOcr2 model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a similar configuration to that of GOT-OCR-2.0.`,fo,Le,rs='e.g <a href="https://huggingface.co/stepfun-ai/GOT-OCR-2.0-hf" rel="nofollow">stepfun-ai/GOT-OCR-2.0-hf</a>',uo,De,is=`Configuration objects inherit from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> and can be used to control the model outputs. Read the
documentation from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,_o,F,Ht,Ze,St,W,Re,yo,Ke,cs=`This is the configuration class to store the configuration of a <code>GotOcr2VisionModel</code>. It is used to instantiate a GOT_OCR2
vision encoder according to the specified arguments, defining the model architecture. Instantiating a configuration
defaults will yield a similar configuration to that of the SAM ViT-h
<a href="https://huggingface.co/facebook/sam-vit-huge" rel="nofollow">facebook/sam-vit-huge</a> architecture.`,bo,et,ls=`Configuration objects inherit from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> and can be used to control the model outputs. Read the
documentation from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,Yt,ze,At,J,ke,To,tt,ms="Constructs a GOT_OCR2 image processor.",Mo,q,We,jo,ot,ds=`Crop the image to patches and return a list of cropped images.
The number of patches and their grid arrangement are determined by the original image size,
the target patch size and the minimum and maximum number of patches.
The aspect ratio of the patches grid is chosen to be the closest to the original image aspect ratio.`,wo,X,$e,vo,st,ps="Preprocess an image or batch of images.",Jo,P,Oe,Io,at,hs="Resize an image to <code>(size[&quot;height&quot;], size[&quot;width&quot;])</code>.",Lt,Ne,Dt,U,Be,Uo,nt,gs="Constructs a fast GotOcr2 image processor.",Go,Q,Ve,Co,rt,fs=`Crop the images to patches and return a list of cropped images.
The number of patches and their grid arrangement are determined by the original image size,
the target patch size and the minimum and maximum number of patches.
The aspect ratio of the patches grid is chosen to be the closest to the original image aspect ratio.`,xo,E,Fe,Zo,it,us="Preprocess an image or batch of images.",Kt,qe,eo,G,Xe,Ro,ct,_s=`Constructs a GotOcr2 processor which wraps a <a href="/docs/transformers/main/en/model_doc/got_ocr2#transformers.GotOcr2ImageProcessor">GotOcr2ImageProcessor</a> and
<code>PretrainedTokenizerFast</code> tokenizer into a single processor that inherits both the image processor and
tokenizer functionalities. See the <code>__call__()</code> and <a href="/docs/transformers/main/en/model_doc/got_ocr2#transformers.GotOcr2Processor.decode">decode()</a> for more information.`,zo,H,Pe,ko,lt,ys=`This method forwards all its arguments to PreTrainedTokenizerFast’s <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.batch_decode">batch_decode()</a>. Please
refer to the docstring of this method for more information.`,Wo,S,Qe,$o,mt,bs=`This method forwards all its arguments to PreTrainedTokenizerFast’s <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.decode">decode()</a>. Please refer to
the docstring of this method for more information.`,to,Ee,oo,C,He,Oo,dt,Ts=`The GOT_OCR2 model which consists of a vision backbone and a language model.
This model inherits from <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. 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.)`,No,pt,Ms=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`,Bo,k,Se,Vo,ht,js='The <a href="/docs/transformers/main/en/model_doc/got_ocr2#transformers.GotOcr2ForConditionalGeneration">GotOcr2ForConditionalGeneration</a> forward method, overrides the <code>__call__</code> special method.',Fo,Y,qo,A,so,Ye,ao,gt,no;return R=new j({props:{title:"GOT-OCR2",local:"got-ocr2",headingTag:"h1"}}),te=new j({props:{title:"Overview",local:"overview",headingTag:"h2"}}),le=new j({props:{title:"Usage example",local:"usage-example",headingTag:"h2"}}),me=new j({props:{title:"Plain text inference",local:"plain-text-inference",headingTag:"h3"}}),de=new O({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBBdXRvTW9kZWxGb3JJbWFnZVRleHRUb1RleHQlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQWRldmljZSUyMCUzRCUyMCUyMmN1ZGElMjIlMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwJTIyY3B1JTIyJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JJbWFnZVRleHRUb1RleHQuZnJvbV9wcmV0cmFpbmVkKCUyMnN0ZXBmdW4tYWklMkZHT1QtT0NSLTIuMC1oZiUyMiUyQyUyMGRldmljZV9tYXAlM0RkZXZpY2UpJTBBcHJvY2Vzc29yJTIwJTNEJTIwQXV0b1Byb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyc3RlcGZ1bi1haSUyRkdPVC1PQ1ItMi4wLWhmJTIyJTJDJTIwdXNlX2Zhc3QlM0RUcnVlKSUwQSUwQWltYWdlJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaGYtaW50ZXJuYWwtdGVzdGluZyUyRmZpeHR1cmVzX2dvdF9vY3IlMkZyZXNvbHZlJTJGbWFpbiUyRmltYWdlX29jci5qcGclMjIlMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IoaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTJDJTIwZGV2aWNlJTNEZGV2aWNlKS50byhkZXZpY2UpJTBBJTBBZ2VuZXJhdGVfaWRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoJTBBJTIwJTIwJTIwJTIwKippbnB1dHMlMkMlMEElMjAlMjAlMjAlMjBkb19zYW1wbGUlM0RGYWxzZSUyQyUwQSUyMCUyMCUyMCUyMHRva2VuaXplciUzRHByb2Nlc3Nvci50b2tlbml6ZXIlMkMlMEElMjAlMjAlMjAlMjBzdG9wX3N0cmluZ3MlM0QlMjIlM0MlN0NpbV9lbmQlN0MlM0UlMjIlMkMlMEElMjAlMjAlMjAlMjBtYXhfbmV3X3Rva2VucyUzRDQwOTYlMkMlMEEpJTBBJTBBcHJvY2Vzc29yLmRlY29kZShnZW5lcmF0ZV9pZHMlNUIwJTJDJTIwaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVELnNoYXBlJTVCMSU1RCUzQSU1RCUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, AutoModelForImageTextToText
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&quot;cuda&quot;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cpu&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForImageTextToText.from_pretrained(<span class="hljs-string">&quot;stepfun-ai/GOT-OCR-2.0-hf&quot;</span>, device_map=device)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;stepfun-ai/GOT-OCR-2.0-hf&quot;</span>, use_fast=<span class="hljs-literal">True</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>image = <span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/fixtures_got_ocr/resolve/main/image_ocr.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>, device=device).to(device)

<span class="hljs-meta">&gt;&gt;&gt; </span>generate_ids = model.generate(
<span class="hljs-meta">... </span>    **inputs,
<span class="hljs-meta">... </span>    do_sample=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    tokenizer=processor.tokenizer,
<span class="hljs-meta">... </span>    stop_strings=<span class="hljs-string">&quot;&lt;|im_end|&gt;&quot;</span>,
<span class="hljs-meta">... </span>    max_new_tokens=<span class="hljs-number">4096</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>processor.decode(generate_ids[<span class="hljs-number">0</span>, inputs[<span class="hljs-string">&quot;input_ids&quot;</span>].shape[<span class="hljs-number">1</span>]:], skip_special_tokens=<span class="hljs-literal">True</span>)
<span class="hljs-string">&quot;R&amp;D QUALITY IMPROVEMENT\\nSUGGESTION/SOLUTION FORM\\nName/Phone Ext. : (...)&quot;</span>`,wrap:!1}}),pe=new j({props:{title:"Plain text inference batched",local:"plain-text-inference-batched",headingTag:"h3"}}),he=new O({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBBdXRvTW9kZWxGb3JJbWFnZVRleHRUb1RleHQlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQWRldmljZSUyMCUzRCUyMCUyMmN1ZGElMjIlMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwJTIyY3B1JTIyJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JJbWFnZVRleHRUb1RleHQuZnJvbV9wcmV0cmFpbmVkKCUyMnN0ZXBmdW4tYWklMkZHT1QtT0NSLTIuMC1oZiUyMiUyQyUyMGRldmljZV9tYXAlM0RkZXZpY2UpJTBBcHJvY2Vzc29yJTIwJTNEJTIwQXV0b1Byb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyc3RlcGZ1bi1haSUyRkdPVC1PQ1ItMi4wLWhmJTIyJTJDJTIwdXNlX2Zhc3QlM0RUcnVlKSUwQSUwQWltYWdlMSUyMCUzRCUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmhmLWludGVybmFsLXRlc3RpbmclMkZmaXh0dXJlc19nb3Rfb2NyJTJGcmVzb2x2ZSUyRm1haW4lMkZtdWx0aV9ib3gucG5nJTIyJTBBaW1hZ2UyJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaGYtaW50ZXJuYWwtdGVzdGluZyUyRmZpeHR1cmVzX2dvdF9vY3IlMkZyZXNvbHZlJTJGbWFpbiUyRmltYWdlX29jci5qcGclMjIlMEElMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IoJTVCaW1hZ2UxJTJDJTIwaW1hZ2UyJTVEJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiUyQyUyMGRldmljZSUzRGRldmljZSkudG8oZGV2aWNlKSUwQSUwQWdlbmVyYXRlX2lkcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCUwQSUyMCUyMCUyMCUyMCoqaW5wdXRzJTJDJTBBJTIwJTIwJTIwJTIwZG9fc2FtcGxlJTNERmFsc2UlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZXIlM0Rwcm9jZXNzb3IudG9rZW5pemVyJTJDJTBBJTIwJTIwJTIwJTIwc3RvcF9zdHJpbmdzJTNEJTIyJTNDJTdDaW1fZW5kJTdDJTNFJTIyJTJDJTBBJTIwJTIwJTIwJTIwbWF4X25ld190b2tlbnMlM0Q0JTJDJTBBKSUwQSUwQXByb2Nlc3Nvci5iYXRjaF9kZWNvZGUoZ2VuZXJhdGVfaWRzJTVCJTNBJTJDJTIwaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVELnNoYXBlJTVCMSU1RCUyMCUzQSU1RCUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, AutoModelForImageTextToText
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&quot;cuda&quot;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cpu&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForImageTextToText.from_pretrained(<span class="hljs-string">&quot;stepfun-ai/GOT-OCR-2.0-hf&quot;</span>, device_map=device)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;stepfun-ai/GOT-OCR-2.0-hf&quot;</span>, use_fast=<span class="hljs-literal">True</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>image1 = <span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/fixtures_got_ocr/resolve/main/multi_box.png&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image2 = <span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/fixtures_got_ocr/resolve/main/image_ocr.jpg&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor([image1, image2], return_tensors=<span class="hljs-string">&quot;pt&quot;</span>, device=device).to(device)

<span class="hljs-meta">&gt;&gt;&gt; </span>generate_ids = model.generate(
<span class="hljs-meta">... </span>    **inputs,
<span class="hljs-meta">... </span>    do_sample=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    tokenizer=processor.tokenizer,
<span class="hljs-meta">... </span>    stop_strings=<span class="hljs-string">&quot;&lt;|im_end|&gt;&quot;</span>,
<span class="hljs-meta">... </span>    max_new_tokens=<span class="hljs-number">4</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>processor.batch_decode(generate_ids[:, inputs[<span class="hljs-string">&quot;input_ids&quot;</span>].shape[<span class="hljs-number">1</span>] :], skip_special_tokens=<span class="hljs-literal">True</span>)
[<span class="hljs-string">&quot;Reducing the number&quot;</span>, <span class="hljs-string">&quot;R&amp;D QUALITY&quot;</span>]`,wrap:!1}}),ge=new j({props:{title:"Formatted text inference",local:"formatted-text-inference",headingTag:"h3"}}),ue=new O({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBBdXRvTW9kZWxGb3JJbWFnZVRleHRUb1RleHQlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQWRldmljZSUyMCUzRCUyMCUyMmN1ZGElMjIlMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwJTIyY3B1JTIyJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JJbWFnZVRleHRUb1RleHQuZnJvbV9wcmV0cmFpbmVkKCUyMnN0ZXBmdW4tYWklMkZHT1QtT0NSLTIuMC1oZiUyMiUyQyUyMGRldmljZV9tYXAlM0RkZXZpY2UpJTBBcHJvY2Vzc29yJTIwJTNEJTIwQXV0b1Byb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyc3RlcGZ1bi1haSUyRkdPVC1PQ1ItMi4wLWhmJTIyJTJDJTIwdXNlX2Zhc3QlM0RUcnVlKSUwQSUwQWltYWdlJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaGYtaW50ZXJuYWwtdGVzdGluZyUyRmZpeHR1cmVzX2dvdF9vY3IlMkZyZXNvbHZlJTJGbWFpbiUyRmxhdGV4LnBuZyUyMiUwQWlucHV0cyUyMCUzRCUyMHByb2Nlc3NvcihpbWFnZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIlMkMlMjBmb3JtYXQlM0RUcnVlJTJDJTIwZGV2aWNlJTNEZGV2aWNlKS50byhkZXZpY2UpJTBBJTBBZ2VuZXJhdGVfaWRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoJTBBJTIwJTIwJTIwJTIwKippbnB1dHMlMkMlMEElMjAlMjAlMjAlMjBkb19zYW1wbGUlM0RGYWxzZSUyQyUwQSUyMCUyMCUyMCUyMHRva2VuaXplciUzRHByb2Nlc3Nvci50b2tlbml6ZXIlMkMlMEElMjAlMjAlMjAlMjBzdG9wX3N0cmluZ3MlM0QlMjIlM0MlN0NpbV9lbmQlN0MlM0UlMjIlMkMlMEElMjAlMjAlMjAlMjBtYXhfbmV3X3Rva2VucyUzRDQwOTYlMkMlMEEpJTBBJTBBcHJvY2Vzc29yLmRlY29kZShnZW5lcmF0ZV9pZHMlNUIwJTJDJTIwaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVELnNoYXBlJTVCMSU1RCUzQSU1RCUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, AutoModelForImageTextToText
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&quot;cuda&quot;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cpu&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForImageTextToText.from_pretrained(<span class="hljs-string">&quot;stepfun-ai/GOT-OCR-2.0-hf&quot;</span>, device_map=device)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;stepfun-ai/GOT-OCR-2.0-hf&quot;</span>, use_fast=<span class="hljs-literal">True</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>image = <span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/fixtures_got_ocr/resolve/main/latex.png&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>, <span class="hljs-built_in">format</span>=<span class="hljs-literal">True</span>, device=device).to(device)

<span class="hljs-meta">&gt;&gt;&gt; </span>generate_ids = model.generate(
<span class="hljs-meta">... </span>    **inputs,
<span class="hljs-meta">... </span>    do_sample=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    tokenizer=processor.tokenizer,
<span class="hljs-meta">... </span>    stop_strings=<span class="hljs-string">&quot;&lt;|im_end|&gt;&quot;</span>,
<span class="hljs-meta">... </span>    max_new_tokens=<span class="hljs-number">4096</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>processor.decode(generate_ids[<span class="hljs-number">0</span>, inputs[<span class="hljs-string">&quot;input_ids&quot;</span>].shape[<span class="hljs-number">1</span>]:], skip_special_tokens=<span class="hljs-literal">True</span>)
<span class="hljs-string">&quot;\\\\author{\\nHanwen Jiang*{@html "<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mspace linebreak="newline"></mspace><mi>q</mi><mi>u</mi><mi>a</mi><mi>d</mi></mrow><annotation encoding="application/x-tex">\\\\quad</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="mspace newline"></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mord mathnormal">u</span><span class="mord mathnormal">a</span><span class="mord mathnormal">d</span></span></span></span>"} Arjun Karpur{@html "<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mrow></mrow><mrow><mspace linebreak="newline"></mspace><mi>d</mi><mi>a</mi><mi>g</mi><mi>g</mi><mi>e</mi><mi>r</mi></mrow></msup><mspace linebreak="newline"></mspace><mi>q</mi><mi>u</mi><mi>a</mi><mi>d</mi></mrow><annotation encoding="application/x-tex">{ }^{\\\\dagger} \\\\quad</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8491em;"></span><span class="mord"><span class="mord"></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8491em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mspace mtight newline"></span><span class="mord mathnormal mtight">d</span><span class="mord mathnormal mtight">a</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">gg</span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">er</span></span></span></span></span></span></span></span></span></span><span class="mspace newline"></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mord mathnormal">u</span><span class="mord mathnormal">a</span><span class="mord mathnormal">d</span></span></span></span>"} Bingyi Cao{@html "<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mrow></mrow><mrow><mspace linebreak="newline"></mspace><mi>d</mi><mi>a</mi><mi>g</mi><mi>g</mi><mi>e</mi><mi>r</mi></mrow></msup><mspace linebreak="newline"></mspace><mi>q</mi><mi>u</mi><mi>a</mi><mi>d</mi></mrow><annotation encoding="application/x-tex">{ }^{\\\\dagger} \\\\quad</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8491em;"></span><span class="mord"><span class="mord"></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8491em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mspace mtight newline"></span><span class="mord mathnormal mtight">d</span><span class="mord mathnormal mtight">a</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">gg</span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">er</span></span></span></span></span></span></span></span></span></span><span class="mspace newline"></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mord mathnormal">u</span><span class="mord mathnormal">a</span><span class="mord mathnormal">d</span></span></span></span>"} (...)&quot;</span>`,wrap:!1}}),_e=new j({props:{title:"Inference on multiple pages",local:"inference-on-multiple-pages",headingTag:"h3"}}),be=new O({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBBdXRvTW9kZWxGb3JJbWFnZVRleHRUb1RleHQlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQWRldmljZSUyMCUzRCUyMCUyMmN1ZGElMjIlMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwJTIyY3B1JTIyJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JJbWFnZVRleHRUb1RleHQuZnJvbV9wcmV0cmFpbmVkKCUyMnN0ZXBmdW4tYWklMkZHT1QtT0NSLTIuMC1oZiUyMiUyQyUyMGRldmljZV9tYXAlM0RkZXZpY2UpJTBBcHJvY2Vzc29yJTIwJTNEJTIwQXV0b1Byb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyc3RlcGZ1bi1haSUyRkdPVC1PQ1ItMi4wLWhmJTIyJTJDJTIwdXNlX2Zhc3QlM0RUcnVlKSUwQSUwQWltYWdlMSUyMCUzRCUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmhmLWludGVybmFsLXRlc3RpbmclMkZmaXh0dXJlc19nb3Rfb2NyJTJGcmVzb2x2ZSUyRm1haW4lMkZwYWdlMS5wbmclMjIlMEFpbWFnZTIlMjAlM0QlMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZoZi1pbnRlcm5hbC10ZXN0aW5nJTJGZml4dHVyZXNfZ290X29jciUyRnJlc29sdmUlMkZtYWluJTJGcGFnZTIucG5nJTIyJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKCU1QmltYWdlMSUyQyUyMGltYWdlMiU1RCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIlMkMlMjBtdWx0aV9wYWdlJTNEVHJ1ZSUyQyUyMGZvcm1hdCUzRFRydWUlMkMlMjBkZXZpY2UlM0RkZXZpY2UpLnRvKGRldmljZSklMEElMEFnZW5lcmF0ZV9pZHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSglMEElMjAlMjAlMjAlMjAqKmlucHV0cyUyQyUwQSUyMCUyMCUyMCUyMGRvX3NhbXBsZSUzREZhbHNlJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW5pemVyJTNEcHJvY2Vzc29yLnRva2VuaXplciUyQyUwQSUyMCUyMCUyMCUyMHN0b3Bfc3RyaW5ncyUzRCUyMiUzQyU3Q2ltX2VuZCU3QyUzRSUyMiUyQyUwQSUyMCUyMCUyMCUyMG1heF9uZXdfdG9rZW5zJTNENDA5NiUyQyUwQSklMEElMEFwcm9jZXNzb3IuZGVjb2RlKGdlbmVyYXRlX2lkcyU1QjAlMkMlMjBpbnB1dHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQuc2hhcGUlNUIxJTVEJTNBJTVEJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, AutoModelForImageTextToText
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&quot;cuda&quot;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cpu&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForImageTextToText.from_pretrained(<span class="hljs-string">&quot;stepfun-ai/GOT-OCR-2.0-hf&quot;</span>, device_map=device)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;stepfun-ai/GOT-OCR-2.0-hf&quot;</span>, use_fast=<span class="hljs-literal">True</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>image1 = <span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/fixtures_got_ocr/resolve/main/page1.png&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image2 = <span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/fixtures_got_ocr/resolve/main/page2.png&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor([image1, image2], return_tensors=<span class="hljs-string">&quot;pt&quot;</span>, multi_page=<span class="hljs-literal">True</span>, <span class="hljs-built_in">format</span>=<span class="hljs-literal">True</span>, device=device).to(device)

<span class="hljs-meta">&gt;&gt;&gt; </span>generate_ids = model.generate(
<span class="hljs-meta">... </span>    **inputs,
<span class="hljs-meta">... </span>    do_sample=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    tokenizer=processor.tokenizer,
<span class="hljs-meta">... </span>    stop_strings=<span class="hljs-string">&quot;&lt;|im_end|&gt;&quot;</span>,
<span class="hljs-meta">... </span>    max_new_tokens=<span class="hljs-number">4096</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>processor.decode(generate_ids[<span class="hljs-number">0</span>, inputs[<span class="hljs-string">&quot;input_ids&quot;</span>].shape[<span class="hljs-number">1</span>]:], skip_special_tokens=<span class="hljs-literal">True</span>)
<span class="hljs-string">&quot;\\\\title{\\nGeneral OCR Theory: Towards OCR-2.0 via a Unified End-to-end Model\\n}\\n\\\\author{\\nHaoran Wei (...)&quot;</span>`,wrap:!1}}),Te=new j({props:{title:"Inference on cropped patches",local:"inference-on-cropped-patches",headingTag:"h3"}}),je=new O({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Byb2Nlc3NvciUyQyUyMEF1dG9Nb2RlbEZvckltYWdlVGV4dFRvVGV4dCUwQWltcG9ydCUyMHRvcmNoJTBBJTBBZGV2aWNlJTIwJTNEJTIwJTIyY3VkYSUyMiUyMGlmJTIwdG9yY2guY3VkYS5pc19hdmFpbGFibGUoKSUyMGVsc2UlMjAlMjJjcHUlMjIlMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckltYWdlVGV4dFRvVGV4dC5mcm9tX3ByZXRyYWluZWQoJTIyc3RlcGZ1bi1haSUyRkdPVC1PQ1ItMi4wLWhmJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5iZmxvYXQxNiUyQyUyMGRldmljZV9tYXAlM0RkZXZpY2UpJTBBcHJvY2Vzc29yJTIwJTNEJTIwQXV0b1Byb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyc3RlcGZ1bi1haSUyRkdPVC1PQ1ItMi4wLWhmJTIyJTJDJTIwdXNlX2Zhc3QlM0RUcnVlKSUwQSUwQWltYWdlJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaGYtaW50ZXJuYWwtdGVzdGluZyUyRmZpeHR1cmVzX2dvdF9vY3IlMkZyZXNvbHZlJTJGbWFpbiUyRm9uZV9jb2x1bW4ucG5nJTIyJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKGltYWdlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiUyQyUyMGZvcm1hdCUzRFRydWUlMkMlMjBjcm9wX3RvX3BhdGNoZXMlM0RUcnVlJTJDJTIwbWF4X3BhdGNoZXMlM0QzJTJDJTIwZGV2aWNlJTNEZGV2aWNlKS50byhkZXZpY2UpJTBBJTBBZ2VuZXJhdGVfaWRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoJTBBJTIwJTIwJTIwJTIwKippbnB1dHMlMkMlMEElMjAlMjAlMjAlMjBkb19zYW1wbGUlM0RGYWxzZSUyQyUwQSUyMCUyMCUyMCUyMHRva2VuaXplciUzRHByb2Nlc3Nvci50b2tlbml6ZXIlMkMlMEElMjAlMjAlMjAlMjBzdG9wX3N0cmluZ3MlM0QlMjIlM0MlN0NpbV9lbmQlN0MlM0UlMjIlMkMlMEElMjAlMjAlMjAlMjBtYXhfbmV3X3Rva2VucyUzRDQwOTYlMkMlMEEpJTBBJTBBcHJvY2Vzc29yLmRlY29kZShnZW5lcmF0ZV9pZHMlNUIwJTJDJTIwaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVELnNoYXBlJTVCMSU1RCUzQSU1RCUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, AutoModelForImageTextToText
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&quot;cuda&quot;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cpu&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForImageTextToText.from_pretrained(<span class="hljs-string">&quot;stepfun-ai/GOT-OCR-2.0-hf&quot;</span>, torch_dtype=torch.bfloat16, device_map=device)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;stepfun-ai/GOT-OCR-2.0-hf&quot;</span>, use_fast=<span class="hljs-literal">True</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>image = <span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/fixtures_got_ocr/resolve/main/one_column.png&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>, <span class="hljs-built_in">format</span>=<span class="hljs-literal">True</span>, crop_to_patches=<span class="hljs-literal">True</span>, max_patches=<span class="hljs-number">3</span>, device=device).to(device)

<span class="hljs-meta">&gt;&gt;&gt; </span>generate_ids = model.generate(
<span class="hljs-meta">... </span>    **inputs,
<span class="hljs-meta">... </span>    do_sample=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    tokenizer=processor.tokenizer,
<span class="hljs-meta">... </span>    stop_strings=<span class="hljs-string">&quot;&lt;|im_end|&gt;&quot;</span>,
<span class="hljs-meta">... </span>    max_new_tokens=<span class="hljs-number">4096</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>processor.decode(generate_ids[<span class="hljs-number">0</span>, inputs[<span class="hljs-string">&quot;input_ids&quot;</span>].shape[<span class="hljs-number">1</span>]:], skip_special_tokens=<span class="hljs-literal">True</span>)
<span class="hljs-string">&quot;on developing architectural improvements to make learnable matching methods generalize.\\nMotivated by the above observations, (...)&quot;</span>`,wrap:!1}}),we=new j({props:{title:"Inference on a specific region",local:"inference-on-a-specific-region",headingTag:"h3"}}),Je=new O({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBBdXRvTW9kZWxGb3JJbWFnZVRleHRUb1RleHQlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQWRldmljZSUyMCUzRCUyMCUyMmN1ZGElMjIlMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwJTIyY3B1JTIyJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JJbWFnZVRleHRUb1RleHQuZnJvbV9wcmV0cmFpbmVkKCUyMnN0ZXBmdW4tYWklMkZHT1QtT0NSLTIuMC1oZiUyMiUyQyUyMGRldmljZV9tYXAlM0RkZXZpY2UpJTBBcHJvY2Vzc29yJTIwJTNEJTIwQXV0b1Byb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyc3RlcGZ1bi1haSUyRkdPVC1PQ1ItMi4wLWhmJTIyJTJDJTIwdXNlX2Zhc3QlM0RUcnVlKSUwQSUwQWltYWdlJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaGYtaW50ZXJuYWwtdGVzdGluZyUyRmZpeHR1cmVzX2dvdF9vY3IlMkZyZXNvbHZlJTJGbWFpbiUyRm11bHRpX2JveC5wbmclMjIlMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IoaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTJDJTIwY29sb3IlM0QlMjJncmVlbiUyMiUyQyUyMGRldmljZSUzRGRldmljZSkudG8oZGV2aWNlKSUyMCUyMyUyMG9yJTIwYm94JTNEJTVCeDElMkMlMjB5MSUyQyUyMHgyJTJDJTIweTIlNUQlMjBmb3IlMjBjb29yZGluYXRlcyUyMChpbWFnZSUyMHBpeGVscyklMEElMEFnZW5lcmF0ZV9pZHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSglMEElMjAlMjAlMjAlMjAqKmlucHV0cyUyQyUwQSUyMCUyMCUyMCUyMGRvX3NhbXBsZSUzREZhbHNlJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW5pemVyJTNEcHJvY2Vzc29yLnRva2VuaXplciUyQyUwQSUyMCUyMCUyMCUyMHN0b3Bfc3RyaW5ncyUzRCUyMiUzQyU3Q2ltX2VuZCU3QyUzRSUyMiUyQyUwQSUyMCUyMCUyMCUyMG1heF9uZXdfdG9rZW5zJTNENDA5NiUyQyUwQSklMEElMEFwcm9jZXNzb3IuZGVjb2RlKGdlbmVyYXRlX2lkcyU1QjAlMkMlMjBpbnB1dHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQuc2hhcGUlNUIxJTVEJTNBJTVEJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, AutoModelForImageTextToText
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&quot;cuda&quot;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cpu&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForImageTextToText.from_pretrained(<span class="hljs-string">&quot;stepfun-ai/GOT-OCR-2.0-hf&quot;</span>, device_map=device)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;stepfun-ai/GOT-OCR-2.0-hf&quot;</span>, use_fast=<span class="hljs-literal">True</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>image = <span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/fixtures_got_ocr/resolve/main/multi_box.png&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>, color=<span class="hljs-string">&quot;green&quot;</span>, device=device).to(device) <span class="hljs-comment"># or box=[x1, y1, x2, y2] for coordinates (image pixels)</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>generate_ids = model.generate(
<span class="hljs-meta">... </span>    **inputs,
<span class="hljs-meta">... </span>    do_sample=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    tokenizer=processor.tokenizer,
<span class="hljs-meta">... </span>    stop_strings=<span class="hljs-string">&quot;&lt;|im_end|&gt;&quot;</span>,
<span class="hljs-meta">... </span>    max_new_tokens=<span class="hljs-number">4096</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>processor.decode(generate_ids[<span class="hljs-number">0</span>, inputs[<span class="hljs-string">&quot;input_ids&quot;</span>].shape[<span class="hljs-number">1</span>]:], skip_special_tokens=<span class="hljs-literal">True</span>)
<span class="hljs-string">&quot;You should keep in mind what features from the module should be used, especially \\nwhen you’re planning to sell a template.&quot;</span>`,wrap:!1}}),Ie=new j({props:{title:"Inference on general OCR data example: sheet music",local:"inference-on-general-ocr-data-example-sheet-music",headingTag:"h3"}}),Ge=new O({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBBdXRvTW9kZWxGb3JJbWFnZVRleHRUb1RleHQlMEFpbXBvcnQlMjB0b3JjaCUwQWltcG9ydCUyMHZlcm92aW8lMEElMEFkZXZpY2UlMjAlM0QlMjAlMjJjdWRhJTIyJTIwaWYlMjB0b3JjaC5jdWRhLmlzX2F2YWlsYWJsZSgpJTIwZWxzZSUyMCUyMmNwdSUyMiUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9ySW1hZ2VUZXh0VG9UZXh0LmZyb21fcHJldHJhaW5lZCglMjJzdGVwZnVuLWFpJTJGR09ULU9DUi0yLjAtaGYlMjIlMkMlMjBkZXZpY2VfbWFwJTNEZGV2aWNlKSUwQXByb2Nlc3NvciUyMCUzRCUyMEF1dG9Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMnN0ZXBmdW4tYWklMkZHT1QtT0NSLTIuMC1oZiUyMiUyQyUyMHVzZV9mYXN0JTNEVHJ1ZSklMEElMEFpbWFnZSUyMCUzRCUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmhmLWludGVybmFsLXRlc3RpbmclMkZmaXh0dXJlc19nb3Rfb2NyJTJGcmVzb2x2ZSUyRm1haW4lMkZzaGVldF9tdXNpYy5wbmclMjIlMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IoaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTJDJTIwZm9ybWF0JTNEVHJ1ZSUyQyUyMGRldmljZSUzRGRldmljZSkudG8oZGV2aWNlKSUwQSUwQWdlbmVyYXRlX2lkcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCUwQSUyMCUyMCUyMCUyMCoqaW5wdXRzJTJDJTBBJTIwJTIwJTIwJTIwZG9fc2FtcGxlJTNERmFsc2UlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZXIlM0Rwcm9jZXNzb3IudG9rZW5pemVyJTJDJTBBJTIwJTIwJTIwJTIwc3RvcF9zdHJpbmdzJTNEJTIyJTNDJTdDaW1fZW5kJTdDJTNFJTIyJTJDJTBBJTIwJTIwJTIwJTIwbWF4X25ld190b2tlbnMlM0Q0MDk2JTJDJTBBKSUwQSUwQW91dHB1dHMlMjAlM0QlMjBwcm9jZXNzb3IuZGVjb2RlKGdlbmVyYXRlX2lkcyU1QjAlMkMlMjBpbnB1dHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQuc2hhcGUlNUIxJTVEJTNBJTVEJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpJTBBdGslMjAlM0QlMjB2ZXJvdmlvLnRvb2xraXQoKSUwQXRrLmxvYWREYXRhKG91dHB1dHMpJTBBdGsuc2V0T3B0aW9ucyglMEElMjAlMjAlMjAlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJwYWdlV2lkdGglMjIlM0ElMjAyMTAwJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIycGFnZUhlaWdodCUyMiUzQSUyMDgwMCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmZvb3RlciUyMiUzQSUyMCUyMm5vbmUlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJiYXJMaW5lV2lkdGglMjIlM0ElMjAwLjUlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJiZWFtTWF4U2xvcGUlMjIlM0ElMjAxNSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnN0YWZmTGluZVdpZHRoJTIyJTNBJTIwMC4yJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyc3BhY2luZ1N0YWZmJTIyJTNBJTIwNiUyQyUwQSUyMCUyMCUyMCUyMCU3RCUwQSklMEF0ay5nZXRQYWdlQ291bnQoKSUwQXN2ZyUyMCUzRCUyMHRrLnJlbmRlclRvU1ZHKCklMEFzdmclMjAlM0QlMjBzdmcucmVwbGFjZSgnb3ZlcmZsb3clM0QlMjJpbmhlcml0JTIyJyUyQyUyMCdvdmVyZmxvdyUzRCUyMnZpc2libGUlMjInKSUwQXdpdGglMjBvcGVuKCUyMm91dHB1dC5zdmclMjIlMkMlMjAlMjJ3JTIyKSUyMGFzJTIwZiUzQSUwQSUyMCUyMCUyMCUyMGYud3JpdGUoc3ZnKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, AutoModelForImageTextToText
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> verovio

<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&quot;cuda&quot;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cpu&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForImageTextToText.from_pretrained(<span class="hljs-string">&quot;stepfun-ai/GOT-OCR-2.0-hf&quot;</span>, device_map=device)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;stepfun-ai/GOT-OCR-2.0-hf&quot;</span>, use_fast=<span class="hljs-literal">True</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>image = <span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/fixtures_got_ocr/resolve/main/sheet_music.png&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>, <span class="hljs-built_in">format</span>=<span class="hljs-literal">True</span>, device=device).to(device)

<span class="hljs-meta">&gt;&gt;&gt; </span>generate_ids = model.generate(
<span class="hljs-meta">... </span>    **inputs,
<span class="hljs-meta">... </span>    do_sample=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    tokenizer=processor.tokenizer,
<span class="hljs-meta">... </span>    stop_strings=<span class="hljs-string">&quot;&lt;|im_end|&gt;&quot;</span>,
<span class="hljs-meta">... </span>    max_new_tokens=<span class="hljs-number">4096</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = processor.decode(generate_ids[<span class="hljs-number">0</span>, inputs[<span class="hljs-string">&quot;input_ids&quot;</span>].shape[<span class="hljs-number">1</span>]:], skip_special_tokens=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tk = verovio.toolkit()
<span class="hljs-meta">&gt;&gt;&gt; </span>tk.loadData(outputs)
<span class="hljs-meta">&gt;&gt;&gt; </span>tk.setOptions(
<span class="hljs-meta">... </span>    {
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;pageWidth&quot;</span>: <span class="hljs-number">2100</span>,
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;pageHeight&quot;</span>: <span class="hljs-number">800</span>,
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;footer&quot;</span>: <span class="hljs-string">&quot;none&quot;</span>,
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;barLineWidth&quot;</span>: <span class="hljs-number">0.5</span>,
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;beamMaxSlope&quot;</span>: <span class="hljs-number">15</span>,
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;staffLineWidth&quot;</span>: <span class="hljs-number">0.2</span>,
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;spacingStaff&quot;</span>: <span class="hljs-number">6</span>,
<span class="hljs-meta">... </span>    }
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tk.getPageCount()
<span class="hljs-meta">&gt;&gt;&gt; </span>svg = tk.renderToSVG()
<span class="hljs-meta">&gt;&gt;&gt; </span>svg = svg.replace(<span class="hljs-string">&#x27;overflow=&quot;inherit&quot;&#x27;</span>, <span class="hljs-string">&#x27;overflow=&quot;visible&quot;&#x27;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> <span class="hljs-built_in">open</span>(<span class="hljs-string">&quot;output.svg&quot;</span>, <span class="hljs-string">&quot;w&quot;</span>) <span class="hljs-keyword">as</span> f:
<span class="hljs-meta">&gt;&gt;&gt; </span>    f.write(svg)`,wrap:!1}}),Ce=new j({props:{title:"GotOcr2Config",local:"transformers.GotOcr2Config",headingTag:"h2"}}),xe=new I({props:{name:"class transformers.GotOcr2Config",anchor:"transformers.GotOcr2Config",parameters:[{name:"vision_config",val:" = None"},{name:"text_config",val:" = None"},{name:"image_token_index",val:" = 151859"},{name:"image_seq_length",val:" = 576"},{name:"pad_token_id",val:" = -1"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.GotOcr2Config.vision_config",description:`<strong>vision_config</strong> (<code>Union[AutoConfig, dict]</code>,  <em>optional</em>, defaults to <code>CLIPVisionConfig</code>) &#x2014;
The config object or dictionary of the vision backbone.`,name:"vision_config"},{anchor:"transformers.GotOcr2Config.text_config",description:`<strong>text_config</strong> (<code>Union[AutoConfig, dict]</code>, <em>optional</em>, defaults to <code>LlamaConfig</code>) &#x2014;
The config object or dictionary of the text backbone.`,name:"text_config"},{anchor:"transformers.GotOcr2Config.image_token_index",description:`<strong>image_token_index</strong> (<code>int</code>, <em>optional</em>, defaults to 151859) &#x2014;
The image token index to encode the image prompt.`,name:"image_token_index"},{anchor:"transformers.GotOcr2Config.image_seq_length",description:`<strong>image_seq_length</strong> (<code>int</code>, <em>optional</em>, defaults to 576) &#x2014;
Sequence length of one image embedding.`,name:"image_seq_length"},{anchor:"transformers.GotOcr2Config.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to -1) &#x2014;
Padding token id.`,name:"pad_token_id"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/got_ocr2/configuration_got_ocr2.py#L118"}}),F=new vs({props:{anchor:"transformers.GotOcr2Config.example",$$slots:{default:[Rs]},$$scope:{ctx:N}}}),Ze=new j({props:{title:"GotOcr2VisionConfig",local:"transformers.GotOcr2VisionConfig",headingTag:"h2"}}),Re=new I({props:{name:"class transformers.GotOcr2VisionConfig",anchor:"transformers.GotOcr2VisionConfig",parameters:[{name:"hidden_size",val:" = 768"},{name:"output_channels",val:" = 256"},{name:"num_hidden_layers",val:" = 12"},{name:"num_attention_heads",val:" = 12"},{name:"num_channels",val:" = 3"},{name:"image_size",val:" = 1024"},{name:"patch_size",val:" = 16"},{name:"hidden_act",val:" = 'gelu'"},{name:"layer_norm_eps",val:" = 1e-06"},{name:"attention_dropout",val:" = 0.0"},{name:"initializer_range",val:" = 1e-10"},{name:"qkv_bias",val:" = True"},{name:"use_abs_pos",val:" = True"},{name:"use_rel_pos",val:" = True"},{name:"window_size",val:" = 14"},{name:"global_attn_indexes",val:" = [2, 5, 8, 11]"},{name:"mlp_dim",val:" = 3072"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.GotOcr2VisionConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 768) &#x2014;
Dimensionality of the encoder layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.GotOcr2VisionConfig.output_channels",description:`<strong>output_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 256) &#x2014;
Dimensionality of the output channels in the Patch Encoder.`,name:"output_channels"},{anchor:"transformers.GotOcr2VisionConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"num_hidden_layers"},{anchor:"transformers.GotOcr2VisionConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_attention_heads"},{anchor:"transformers.GotOcr2VisionConfig.num_channels",description:`<strong>num_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 3) &#x2014;
Number of channels in the input image.`,name:"num_channels"},{anchor:"transformers.GotOcr2VisionConfig.image_size",description:`<strong>image_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
Expected resolution. Target size of the resized input image.`,name:"image_size"},{anchor:"transformers.GotOcr2VisionConfig.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
Size of the patches to be extracted from the input image.`,name:"patch_size"},{anchor:"transformers.GotOcr2VisionConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string)`,name:"hidden_act"},{anchor:"transformers.GotOcr2VisionConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-06) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.GotOcr2VisionConfig.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.GotOcr2VisionConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-10) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.GotOcr2VisionConfig.qkv_bias",description:`<strong>qkv_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to add a bias to query, key, value projections.`,name:"qkv_bias"},{anchor:"transformers.GotOcr2VisionConfig.use_abs_pos",description:`<strong>use_abs_pos</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to use absolute position embedding.`,name:"use_abs_pos"},{anchor:"transformers.GotOcr2VisionConfig.use_rel_pos",description:`<strong>use_rel_pos</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to use relative position embedding.`,name:"use_rel_pos"},{anchor:"transformers.GotOcr2VisionConfig.window_size",description:`<strong>window_size</strong> (<code>int</code>, <em>optional</em>, defaults to 14) &#x2014;
Window size for relative position.`,name:"window_size"},{anchor:"transformers.GotOcr2VisionConfig.global_attn_indexes",description:`<strong>global_attn_indexes</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[2, 5, 8, 11]</code>) &#x2014;
The indexes of the global attention layers.`,name:"global_attn_indexes"},{anchor:"transformers.GotOcr2VisionConfig.mlp_dim",description:`<strong>mlp_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 3072) &#x2014;
The dimensionality of the MLP layer in the Transformer encoder.`,name:"mlp_dim"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/got_ocr2/configuration_got_ocr2.py#L27"}}),ze=new j({props:{title:"GotOcr2ImageProcessor",local:"transformers.GotOcr2ImageProcessor",headingTag:"h2"}}),ke=new I({props:{name:"class transformers.GotOcr2ImageProcessor",anchor:"transformers.GotOcr2ImageProcessor",parameters:[{name:"do_resize",val:": bool = True"},{name:"size",val:": typing.Dict[str, int] = None"},{name:"crop_to_patches",val:": bool = False"},{name:"min_patches",val:": int = 1"},{name:"max_patches",val:": int = 12"},{name:"resample",val:": Resampling = <Resampling.BICUBIC: 3>"},{name:"do_rescale",val:": bool = True"},{name:"rescale_factor",val:": typing.Union[int, float] = 0.00392156862745098"},{name:"do_normalize",val:": bool = True"},{name:"image_mean",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"image_std",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"do_convert_rgb",val:": bool = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.GotOcr2ImageProcessor.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to resize the image&#x2019;s (height, width) dimensions to the specified <code>size</code>. Can be overridden by the
<code>do_resize</code> parameter in the <code>preprocess</code> method.`,name:"do_resize"},{anchor:"transformers.GotOcr2ImageProcessor.size",description:`<strong>size</strong> (<code>dict</code>, <em>optional</em>, defaults to <code>{&quot;height&quot; -- 384, &quot;width&quot;: 384}</code>):
Size of the output image after resizing. Can be overridden by the <code>size</code> parameter in the <code>preprocess</code>
method.`,name:"size"},{anchor:"transformers.GotOcr2ImageProcessor.crop_to_patches",description:`<strong>crop_to_patches</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to crop the image to patches. Can be overridden by the <code>crop_to_patches</code> parameter in the
<code>preprocess</code> method.`,name:"crop_to_patches"},{anchor:"transformers.GotOcr2ImageProcessor.min_patches",description:`<strong>min_patches</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The minimum number of patches to be extracted from the image. Only has an effect if <code>crop_to_patches</code> is
set to <code>True</code>. Can be overridden by the <code>min_patches</code> parameter in the <code>preprocess</code> method.`,name:"min_patches"},{anchor:"transformers.GotOcr2ImageProcessor.max_patches",description:`<strong>max_patches</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
The maximum number of patches to be extracted from the image. Only has an effect if <code>crop_to_patches</code> is
set to <code>True</code>. Can be overridden by the <code>max_patches</code> parameter in the <code>preprocess</code> method.`,name:"max_patches"},{anchor:"transformers.GotOcr2ImageProcessor.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code>, <em>optional</em>, defaults to <code>Resampling.BICUBIC</code>) &#x2014;
Resampling filter to use if resizing the image. Only has an effect if <code>do_resize</code> is set to <code>True</code>. Can be
overridden by the <code>resample</code> parameter in the <code>preprocess</code> method.`,name:"resample"},{anchor:"transformers.GotOcr2ImageProcessor.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to rescale the image by the specified scale <code>rescale_factor</code>. Can be overridden by the
<code>do_rescale</code> parameter in the <code>preprocess</code> method.`,name:"do_rescale"},{anchor:"transformers.GotOcr2ImageProcessor.rescale_factor",description:`<strong>rescale_factor</strong> (<code>int</code> or <code>float</code>, <em>optional</em>, defaults to <code>1/255</code>) &#x2014;
Scale factor to use if rescaling the image. Only has an effect if <code>do_rescale</code> is set to <code>True</code>. Can be
overridden by the <code>rescale_factor</code> parameter in the <code>preprocess</code> method.`,name:"rescale_factor"},{anchor:"transformers.GotOcr2ImageProcessor.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to normalize the image. Can be overridden by the <code>do_normalize</code> parameter in the <code>preprocess</code>
method. Can be overridden by the <code>do_normalize</code> parameter in the <code>preprocess</code> method.`,name:"do_normalize"},{anchor:"transformers.GotOcr2ImageProcessor.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IMAGENET_STANDARD_MEAN</code>) &#x2014;
Mean to use if normalizing the image. This is a float or list of floats the length of the number of
channels in the image. Can be overridden by the <code>image_mean</code> parameter in the <code>preprocess</code> method. Can be
overridden by the <code>image_mean</code> parameter in the <code>preprocess</code> method.`,name:"image_mean"},{anchor:"transformers.GotOcr2ImageProcessor.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IMAGENET_STANDARD_STD</code>) &#x2014;
Standard deviation to use if normalizing the image. This is a float or list of floats the length of the
number of channels in the image. Can be overridden by the <code>image_std</code> parameter in the <code>preprocess</code> method.
Can be overridden by the <code>image_std</code> parameter in the <code>preprocess</code> method.`,name:"image_std"},{anchor:"transformers.GotOcr2ImageProcessor.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to convert the image to RGB.`,name:"do_convert_rgb"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/got_ocr2/image_processing_got_ocr2.py#L126"}}),We=new I({props:{name:"crop_image_to_patches",anchor:"transformers.GotOcr2ImageProcessor.crop_image_to_patches",parameters:[{name:"images",val:": ndarray"},{name:"min_patches",val:": int"},{name:"max_patches",val:": int"},{name:"use_thumbnail",val:": bool = True"},{name:"patch_size",val:": typing.Union[typing.Tuple, int, dict] = None"},{name:"data_format",val:": ChannelDimension = None"}],parametersDescription:[{anchor:"transformers.GotOcr2ImageProcessor.crop_image_to_patches.images",description:`<strong>images</strong> (<code>np.ndarray</code>) &#x2014;
The image to be cropped.`,name:"images"},{anchor:"transformers.GotOcr2ImageProcessor.crop_image_to_patches.min_patches",description:`<strong>min_patches</strong> (<code>int</code>) &#x2014;
The minimum number of patches to be extracted from the image.`,name:"min_patches"},{anchor:"transformers.GotOcr2ImageProcessor.crop_image_to_patches.max_patches",description:`<strong>max_patches</strong> (<code>int</code>) &#x2014;
The maximum number of patches to be extracted from the image.`,name:"max_patches"},{anchor:"transformers.GotOcr2ImageProcessor.crop_image_to_patches.use_thumbnail",description:`<strong>use_thumbnail</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to add a thumbnail image to the list of cropped patches.`,name:"use_thumbnail"},{anchor:"transformers.GotOcr2ImageProcessor.crop_image_to_patches.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <code>Tuple[int, int]</code>, <code>dict</code>, <em>optional</em>) &#x2014;
The size of the output patches.`,name:"patch_size"},{anchor:"transformers.GotOcr2ImageProcessor.crop_image_to_patches.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code>, <em>optional</em>) &#x2014;
The format of the image data. If <code>None</code>, the format is inferred from the input image.`,name:"data_format"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/got_ocr2/image_processing_got_ocr2.py#L416",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The list of cropped images.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p>List<code>PIL.Image.Image</code> or List[np.ndarray]</p>
`}}),$e=new I({props:{name:"preprocess",anchor:"transformers.GotOcr2ImageProcessor.preprocess",parameters:[{name:"images",val:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), list['PIL.Image.Image'], list[numpy.ndarray], list['torch.Tensor']]"},{name:"do_resize",val:": typing.Optional[bool] = None"},{name:"size",val:": typing.Optional[typing.Dict[str, int]] = None"},{name:"crop_to_patches",val:": typing.Optional[bool] = None"},{name:"min_patches",val:": typing.Optional[int] = None"},{name:"max_patches",val:": typing.Optional[int] = None"},{name:"resample",val:": Resampling = None"},{name:"do_rescale",val:": typing.Optional[bool] = None"},{name:"rescale_factor",val:": typing.Optional[float] = None"},{name:"do_normalize",val:": typing.Optional[bool] = None"},{name:"image_mean",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"image_std",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"return_tensors",val:": typing.Union[str, transformers.utils.generic.TensorType, NoneType] = None"},{name:"do_convert_rgb",val:": bool = None"},{name:"data_format",val:": ChannelDimension = <ChannelDimension.FIRST: 'channels_first'>"},{name:"input_data_format",val:": typing.Union[str, transformers.image_utils.ChannelDimension, NoneType] = None"}],parametersDescription:[{anchor:"transformers.GotOcr2ImageProcessor.preprocess.images",description:`<strong>images</strong> (<code>ImageInput</code>) &#x2014;
Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If
passing in images with pixel values between 0 and 1, set <code>do_rescale=False</code>.`,name:"images"},{anchor:"transformers.GotOcr2ImageProcessor.preprocess.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_resize</code>) &#x2014;
Whether to resize the image.`,name:"do_resize"},{anchor:"transformers.GotOcr2ImageProcessor.preprocess.size",description:`<strong>size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>self.size</code>) &#x2014;
Controls the size of the image after <code>resize</code>. The shortest edge of the image is resized to
<code>size[&quot;shortest_edge&quot;]</code> whilst preserving the aspect ratio. If the longest edge of this resized image
is &gt; <code>int(size[&quot;shortest_edge&quot;] * (1333 / 800))</code>, then the image is resized again to make the longest
edge equal to <code>int(size[&quot;shortest_edge&quot;] * (1333 / 800))</code>.`,name:"size"},{anchor:"transformers.GotOcr2ImageProcessor.preprocess.crop_to_patches",description:`<strong>crop_to_patches</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.crop_to_patches</code>) &#x2014;
Whether to crop the image to patches.`,name:"crop_to_patches"},{anchor:"transformers.GotOcr2ImageProcessor.preprocess.min_patches",description:`<strong>min_patches</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.min_patches</code>) &#x2014;
The minimum number of patches to be extracted from the image. Only has an effect if <code>crop_to_patches</code> is
set to <code>True</code>.`,name:"min_patches"},{anchor:"transformers.GotOcr2ImageProcessor.preprocess.max_patches",description:`<strong>max_patches</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.max_patches</code>) &#x2014;
The maximum number of patches to be extracted from the image. Only has an effect if <code>crop_to_patches</code> is
set to <code>True</code>.`,name:"max_patches"},{anchor:"transformers.GotOcr2ImageProcessor.preprocess.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code>, <em>optional</em>, defaults to <code>self.resample</code>) &#x2014;
Resampling filter to use if resizing the image. Only has an effect if <code>do_resize</code> is set to <code>True</code>.`,name:"resample"},{anchor:"transformers.GotOcr2ImageProcessor.preprocess.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_rescale</code>) &#x2014;
Whether to rescale the image values between [0 - 1].`,name:"do_rescale"},{anchor:"transformers.GotOcr2ImageProcessor.preprocess.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>optional</em>, defaults to <code>self.rescale_factor</code>) &#x2014;
Rescale factor to rescale the image by if <code>do_rescale</code> is set to <code>True</code>.`,name:"rescale_factor"},{anchor:"transformers.GotOcr2ImageProcessor.preprocess.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_normalize</code>) &#x2014;
Whether to normalize the image.`,name:"do_normalize"},{anchor:"transformers.GotOcr2ImageProcessor.preprocess.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_mean</code>) &#x2014;
Image mean to normalize the image by if <code>do_normalize</code> is set to <code>True</code>.`,name:"image_mean"},{anchor:"transformers.GotOcr2ImageProcessor.preprocess.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_std</code>) &#x2014;
Image standard deviation to normalize the image by if <code>do_normalize</code> is set to <code>True</code>.`,name:"image_std"},{anchor:"transformers.GotOcr2ImageProcessor.preprocess.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_convert_rgb</code>) &#x2014;
Whether to convert the image to RGB.`,name:"do_convert_rgb"},{anchor:"transformers.GotOcr2ImageProcessor.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <code>TensorType</code>, <em>optional</em>) &#x2014;
The type of tensors to return. Can be one of:<ul>
<li>Unset: Return a list of <code>np.ndarray</code>.</li>
<li><code>TensorType.TENSORFLOW</code> or <code>&apos;tf&apos;</code>: Return a batch of type <code>tf.Tensor</code>.</li>
<li><code>TensorType.PYTORCH</code> or <code>&apos;pt&apos;</code>: Return a batch of type <code>torch.Tensor</code>.</li>
<li><code>TensorType.NUMPY</code> or <code>&apos;np&apos;</code>: Return a batch of type <code>np.ndarray</code>.</li>
<li><code>TensorType.JAX</code> or <code>&apos;jax&apos;</code>: Return a batch of type <code>jax.numpy.ndarray</code>.</li>
</ul>`,name:"return_tensors"},{anchor:"transformers.GotOcr2ImageProcessor.preprocess.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>, defaults to <code>ChannelDimension.FIRST</code>) &#x2014;
The channel dimension format for the output image. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
<li>Unset: Use the channel dimension format of the input image.</li>
</ul>`,name:"data_format"},{anchor:"transformers.GotOcr2ImageProcessor.preprocess.input_data_format",description:`<strong>input_data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>) &#x2014;
The channel dimension format for the input image. If unset, the channel dimension format is inferred
from the input image. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
<li><code>&quot;none&quot;</code> or <code>ChannelDimension.NONE</code>: image in (height, width) format.</li>
</ul>`,name:"input_data_format"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/got_ocr2/image_processing_got_ocr2.py#L253"}}),Oe=new I({props:{name:"resize",anchor:"transformers.GotOcr2ImageProcessor.resize",parameters:[{name:"image",val:": ndarray"},{name:"size",val:": typing.Dict[str, int]"},{name:"resample",val:": Resampling = <Resampling.BICUBIC: 3>"},{name:"data_format",val:": typing.Union[str, transformers.image_utils.ChannelDimension, NoneType] = None"},{name:"input_data_format",val:": typing.Union[str, transformers.image_utils.ChannelDimension, NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.GotOcr2ImageProcessor.resize.image",description:`<strong>image</strong> (<code>np.ndarray</code>) &#x2014;
Image to resize.`,name:"image"},{anchor:"transformers.GotOcr2ImageProcessor.resize.size",description:`<strong>size</strong> (<code>Dict[str, int]</code>) &#x2014;
Dictionary in the format <code>{&quot;height&quot;: int, &quot;width&quot;: int}</code> specifying the size of the output image.`,name:"size"},{anchor:"transformers.GotOcr2ImageProcessor.resize.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code>, <em>optional</em>, defaults to <code>PILImageResampling.BICUBIC</code>) &#x2014;
<code>PILImageResampling</code> filter to use when resizing the image e.g. <code>PILImageResampling.BICUBIC</code>.`,name:"resample"},{anchor:"transformers.GotOcr2ImageProcessor.resize.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>) &#x2014;
The channel dimension format for the output image. If unset, the channel dimension format of the input
image is used. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
<li><code>&quot;none&quot;</code> or <code>ChannelDimension.NONE</code>: image in (height, width) format.</li>
</ul>`,name:"data_format"},{anchor:"transformers.GotOcr2ImageProcessor.resize.input_data_format",description:`<strong>input_data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>) &#x2014;
The channel dimension format for the input image. If unset, the channel dimension format is inferred
from the input image. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
<li><code>&quot;none&quot;</code> or <code>ChannelDimension.NONE</code>: image in (height, width) format.</li>
</ul>`,name:"input_data_format"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/got_ocr2/image_processing_got_ocr2.py#L205",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The resized image.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>np.ndarray</code></p>
`}}),Ne=new j({props:{title:"GotOcr2ImageProcessorFast",local:"transformers.GotOcr2ImageProcessorFast",headingTag:"h2"}}),Be=new I({props:{name:"class transformers.GotOcr2ImageProcessorFast",anchor:"transformers.GotOcr2ImageProcessorFast",parameters:[{name:"**kwargs",val:": typing_extensions.Unpack[transformers.models.got_ocr2.image_processing_got_ocr2_fast.GotOcr2ImageProcessorKwargs]"}],parametersDescription:[{anchor:"transformers.GotOcr2ImageProcessorFast.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_resize</code>) &#x2014;
Whether to resize the image&#x2019;s (height, width) dimensions to the specified <code>size</code>. Can be overridden by the
<code>do_resize</code> parameter in the <code>preprocess</code> method.`,name:"do_resize"},{anchor:"transformers.GotOcr2ImageProcessorFast.size",description:`<strong>size</strong> (<code>dict</code>, <em>optional</em>, defaults to <code>self.size</code>) &#x2014;
Size of the output image after resizing. Can be overridden by the <code>size</code> parameter in the <code>preprocess</code>
method.`,name:"size"},{anchor:"transformers.GotOcr2ImageProcessorFast.default_to_square",description:`<strong>default_to_square</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.default_to_square</code>) &#x2014;
Whether to default to a square image when resizing, if size is an int.`,name:"default_to_square"},{anchor:"transformers.GotOcr2ImageProcessorFast.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code>, <em>optional</em>, defaults to <code>self.resample</code>) &#x2014;
Resampling filter to use if resizing the image. Only has an effect if <code>do_resize</code> is set to <code>True</code>. Can be
overridden by the <code>resample</code> parameter in the <code>preprocess</code> method.`,name:"resample"},{anchor:"transformers.GotOcr2ImageProcessorFast.do_center_crop",description:`<strong>do_center_crop</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_center_crop</code>) &#x2014;
Whether to center crop the image to the specified <code>crop_size</code>. Can be overridden by <code>do_center_crop</code> in the
<code>preprocess</code> method.`,name:"do_center_crop"},{anchor:"transformers.GotOcr2ImageProcessorFast.crop_size",description:`<strong>crop_size</strong> (<code>Dict[str, int]</code> <em>optional</em>, defaults to <code>self.crop_size</code>) &#x2014;
Size of the output image after applying <code>center_crop</code>. Can be overridden by <code>crop_size</code> in the <code>preprocess</code>
method.`,name:"crop_size"},{anchor:"transformers.GotOcr2ImageProcessorFast.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_rescale</code>) &#x2014;
Whether to rescale the image by the specified scale <code>rescale_factor</code>. Can be overridden by the
<code>do_rescale</code> parameter in the <code>preprocess</code> method.`,name:"do_rescale"},{anchor:"transformers.GotOcr2ImageProcessorFast.rescale_factor",description:`<strong>rescale_factor</strong> (<code>int</code> or <code>float</code>, <em>optional</em>, defaults to <code>self.rescale_factor</code>) &#x2014;
Scale factor to use if rescaling the image. Only has an effect if <code>do_rescale</code> is set to <code>True</code>. Can be
overridden by the <code>rescale_factor</code> parameter in the <code>preprocess</code> method.`,name:"rescale_factor"},{anchor:"transformers.GotOcr2ImageProcessorFast.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_normalize</code>) &#x2014;
Whether to normalize the image. Can be overridden by the <code>do_normalize</code> parameter in the <code>preprocess</code>
method. Can be overridden by the <code>do_normalize</code> parameter in the <code>preprocess</code> method.`,name:"do_normalize"},{anchor:"transformers.GotOcr2ImageProcessorFast.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_mean</code>) &#x2014;
Mean to use if normalizing the image. This is a float or list of floats the length of the number of
channels in the image. Can be overridden by the <code>image_mean</code> parameter in the <code>preprocess</code> method. Can be
overridden by the <code>image_mean</code> parameter in the <code>preprocess</code> method.`,name:"image_mean"},{anchor:"transformers.GotOcr2ImageProcessorFast.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_std</code>) &#x2014;
Standard deviation to use if normalizing the image. This is a float or list of floats the length of the
number of channels in the image. Can be overridden by the <code>image_std</code> parameter in the <code>preprocess</code> method.
Can be overridden by the <code>image_std</code> parameter in the <code>preprocess</code> method.`,name:"image_std"},{anchor:"transformers.GotOcr2ImageProcessorFast.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_convert_rgb</code>) &#x2014;
Whether to convert the image to RGB.`,name:"do_convert_rgb"},{anchor:"transformers.GotOcr2ImageProcessorFast.return_tensors",description:"<strong>return_tensors</strong> (<code>str</code> or <code>TensorType</code>, <em>optional</em>, defaults to <code>self.return_tensors</code>) &#x2014;\nReturns stacked tensors if set to `pt, otherwise returns a list of tensors.",name:"return_tensors"},{anchor:"transformers.GotOcr2ImageProcessorFast.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>, defaults to <code>self.data_format</code>) &#x2014;
Only <code>ChannelDimension.FIRST</code> is supported. Added for compatibility with slow processors.`,name:"data_format"},{anchor:"transformers.GotOcr2ImageProcessorFast.input_data_format",description:`<strong>input_data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>, defaults to <code>self.input_data_format</code>) &#x2014;
The channel dimension format for the input image. If unset, the channel dimension format is inferred
from the input image. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
<li><code>&quot;none&quot;</code> or <code>ChannelDimension.NONE</code>: image in (height, width) format.</li>
</ul>`,name:"input_data_format"},{anchor:"transformers.GotOcr2ImageProcessorFast.device",description:`<strong>device</strong> (<code>torch.device</code>, <em>optional</em>, defaults to <code>self.device</code>) &#x2014;
The device to process the images on. If unset, the device is inferred from the input images.`,name:"device"},{anchor:"transformers.GotOcr2ImageProcessorFast.crop_to_patches",description:`<strong>crop_to_patches</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to crop the image to patches. Can be overridden by the <code>crop_to_patches</code> parameter in the
<code>preprocess</code> method.`,name:"crop_to_patches"},{anchor:"transformers.GotOcr2ImageProcessorFast.min_patches",description:`<strong>min_patches</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The minimum number of patches to be extracted from the image. Only has an effect if <code>crop_to_patches</code> is
set to <code>True</code>. Can be overridden by the <code>min_patches</code> parameter in the <code>preprocess</code> method.`,name:"min_patches"},{anchor:"transformers.GotOcr2ImageProcessorFast.max_patches",description:`<strong>max_patches</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
The maximum number of patches to be extracted from the image. Only has an effect if <code>crop_to_patches</code> is
set to <code>True</code>. Can be overridden by the <code>max_patches</code> parameter in the <code>preprocess</code> method.`,name:"max_patches"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/got_ocr2/image_processing_got_ocr2_fast.py#L62"}}),Ve=new I({props:{name:"crop_image_to_patches",anchor:"transformers.GotOcr2ImageProcessorFast.crop_image_to_patches",parameters:[{name:"images",val:": torch.Tensor"},{name:"min_patches",val:": int"},{name:"max_patches",val:": int"},{name:"use_thumbnail",val:": bool = True"},{name:"patch_size",val:": typing.Union[typing.Tuple, int, dict] = None"},{name:"interpolation",val:": typing.Optional[ForwardRef('F.InterpolationMode')] = None"}],parametersDescription:[{anchor:"transformers.GotOcr2ImageProcessorFast.crop_image_to_patches.images",description:`<strong>images</strong> (<code>torch.Tensor</code>) &#x2014;
The images to be cropped.`,name:"images"},{anchor:"transformers.GotOcr2ImageProcessorFast.crop_image_to_patches.min_patches",description:`<strong>min_patches</strong> (<code>int</code>) &#x2014;
The minimum number of patches to be extracted from the image.`,name:"min_patches"},{anchor:"transformers.GotOcr2ImageProcessorFast.crop_image_to_patches.max_patches",description:`<strong>max_patches</strong> (<code>int</code>) &#x2014;
The maximum number of patches to be extracted from the image.`,name:"max_patches"},{anchor:"transformers.GotOcr2ImageProcessorFast.crop_image_to_patches.use_thumbnail",description:`<strong>use_thumbnail</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to add a thumbnail image to the list of cropped patches.`,name:"use_thumbnail"},{anchor:"transformers.GotOcr2ImageProcessorFast.crop_image_to_patches.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <code>Tuple[int, int]</code>, <code>dict</code>, <em>optional</em>) &#x2014;
The size of the output patches.
The format of the image data. If <code>None</code>, the format is inferred from the input image.`,name:"patch_size"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/got_ocr2/image_processing_got_ocr2_fast.py#L111",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The list of cropped images.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p>List<code>PIL.Image.Image</code> or List[np.ndarray]</p>
`}}),Fe=new I({props:{name:"preprocess",anchor:"transformers.GotOcr2ImageProcessorFast.preprocess",parameters:[{name:"images",val:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), list['PIL.Image.Image'], list[numpy.ndarray], list['torch.Tensor']]"},{name:"**kwargs",val:": typing_extensions.Unpack[transformers.models.got_ocr2.image_processing_got_ocr2_fast.GotOcr2ImageProcessorKwargs]"}],parametersDescription:[{anchor:"transformers.GotOcr2ImageProcessorFast.preprocess.images",description:`<strong>images</strong> (<code>ImageInput</code>) &#x2014;
Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If
passing in images with pixel values between 0 and 1, set <code>do_rescale=False</code>.`,name:"images"},{anchor:"transformers.GotOcr2ImageProcessorFast.preprocess.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_resize</code>) &#x2014;
Whether to resize the image.`,name:"do_resize"},{anchor:"transformers.GotOcr2ImageProcessorFast.preprocess.size",description:`<strong>size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>self.size</code>) &#x2014;
Describes the maximum input dimensions to the model.`,name:"size"},{anchor:"transformers.GotOcr2ImageProcessorFast.preprocess.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code> or <code>InterpolationMode</code>, <em>optional</em>, defaults to <code>self.resample</code>) &#x2014;
Resampling filter to use if resizing the image. This can be one of the enum <code>PILImageResampling</code>. Only
has an effect if <code>do_resize</code> is set to <code>True</code>.`,name:"resample"},{anchor:"transformers.GotOcr2ImageProcessorFast.preprocess.do_center_crop",description:`<strong>do_center_crop</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_center_crop</code>) &#x2014;
Whether to center crop the image.`,name:"do_center_crop"},{anchor:"transformers.GotOcr2ImageProcessorFast.preprocess.crop_size",description:`<strong>crop_size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>self.crop_size</code>) &#x2014;
Size of the output image after applying <code>center_crop</code>.`,name:"crop_size"},{anchor:"transformers.GotOcr2ImageProcessorFast.preprocess.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_rescale</code>) &#x2014;
Whether to rescale the image.`,name:"do_rescale"},{anchor:"transformers.GotOcr2ImageProcessorFast.preprocess.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>optional</em>, defaults to <code>self.rescale_factor</code>) &#x2014;
Rescale factor to rescale the image by if <code>do_rescale</code> is set to <code>True</code>.`,name:"rescale_factor"},{anchor:"transformers.GotOcr2ImageProcessorFast.preprocess.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_normalize</code>) &#x2014;
Whether to normalize the image.`,name:"do_normalize"},{anchor:"transformers.GotOcr2ImageProcessorFast.preprocess.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_mean</code>) &#x2014;
Image mean to use for normalization. Only has an effect if <code>do_normalize</code> is set to <code>True</code>.`,name:"image_mean"},{anchor:"transformers.GotOcr2ImageProcessorFast.preprocess.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_std</code>) &#x2014;
Image standard deviation to use for normalization. Only has an effect if <code>do_normalize</code> is set to
<code>True</code>.`,name:"image_std"},{anchor:"transformers.GotOcr2ImageProcessorFast.preprocess.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_convert_rgb</code>) &#x2014;
Whether to convert the image to RGB.`,name:"do_convert_rgb"},{anchor:"transformers.GotOcr2ImageProcessorFast.preprocess.return_tensors",description:"<strong>return_tensors</strong> (<code>str</code> or <code>TensorType</code>, <em>optional</em>, defaults to <code>self.return_tensors</code>) &#x2014;\nReturns stacked tensors if set to `pt, otherwise returns a list of tensors.",name:"return_tensors"},{anchor:"transformers.GotOcr2ImageProcessorFast.preprocess.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>, defaults to <code>self.data_format</code>) &#x2014;
Only <code>ChannelDimension.FIRST</code> is supported. Added for compatibility with slow processors.`,name:"data_format"},{anchor:"transformers.GotOcr2ImageProcessorFast.preprocess.input_data_format",description:`<strong>input_data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>, defaults to <code>self.input_data_format</code>) &#x2014;
The channel dimension format for the input image. If unset, the channel dimension format is inferred
from the input image. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
<li><code>&quot;none&quot;</code> or <code>ChannelDimension.NONE</code>: image in (height, width) format.</li>
</ul>`,name:"input_data_format"},{anchor:"transformers.GotOcr2ImageProcessorFast.preprocess.device",description:`<strong>device</strong> (<code>torch.device</code>, <em>optional</em>, defaults to <code>self.device</code>) &#x2014;
The device to process the images on. If unset, the device is inferred from the input images.
crop_to_patches (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>):
Whether to crop the image to patches. Can be overridden by the <code>crop_to_patches</code> parameter in the
<code>preprocess</code> method.
min_patches (<code>int</code>, <em>optional</em>, defaults to 1):
The minimum number of patches to be extracted from the image. Only has an effect if <code>crop_to_patches</code> is
set to <code>True</code>. Can be overridden by the <code>min_patches</code> parameter in the <code>preprocess</code> method.
max_patches (<code>int</code>, <em>optional</em>, defaults to 12):
The maximum number of patches to be extracted from the image. Only has an effect if <code>crop_to_patches</code> is
set to <code>True</code>. Can be overridden by the <code>max_patches</code> parameter in the <code>preprocess</code> method.`,name:"device"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/got_ocr2/image_processing_got_ocr2_fast.py#L94"}}),qe=new j({props:{title:"GotOcr2Processor",local:"transformers.GotOcr2Processor",headingTag:"h2"}}),Xe=new I({props:{name:"class transformers.GotOcr2Processor",anchor:"transformers.GotOcr2Processor",parameters:[{name:"image_processor",val:" = None"},{name:"tokenizer",val:" = None"},{name:"chat_template",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.GotOcr2Processor.image_processor",description:`<strong>image_processor</strong> (<a href="/docs/transformers/main/en/model_doc/got_ocr2#transformers.GotOcr2ImageProcessor">GotOcr2ImageProcessor</a>, <em>optional</em>) &#x2014;
The image processor is a required input.`,name:"image_processor"},{anchor:"transformers.GotOcr2Processor.tokenizer",description:`<strong>tokenizer</strong> ([<code>PreTrainedTokenizer</code>, <code>PreTrainedTokenizerFast</code>], <em>optional</em>) &#x2014;
The tokenizer is a required input.`,name:"tokenizer"},{anchor:"transformers.GotOcr2Processor.chat_template",description:`<strong>chat_template</strong> (<code>str</code>, <em>optional</em>) &#x2014; A Jinja template which will be used to convert lists of messages
in a chat into a tokenizable string.`,name:"chat_template"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/got_ocr2/processing_got_ocr2.py#L83"}}),Pe=new I({props:{name:"batch_decode",anchor:"transformers.GotOcr2Processor.batch_decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/got_ocr2/processing_got_ocr2.py#L256"}}),Qe=new I({props:{name:"decode",anchor:"transformers.GotOcr2Processor.decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/got_ocr2/processing_got_ocr2.py#L263"}}),Ee=new j({props:{title:"GotOcr2ForConditionalGeneration",local:"transformers.GotOcr2ForConditionalGeneration",headingTag:"h2"}}),He=new I({props:{name:"class transformers.GotOcr2ForConditionalGeneration",anchor:"transformers.GotOcr2ForConditionalGeneration",parameters:[{name:"config",val:": GotOcr2Config"}],parametersDescription:[{anchor:"transformers.GotOcr2ForConditionalGeneration.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/got_ocr2#transformers.GotOcr2Config">GotOcr2Config</a> or <a href="/docs/transformers/main/en/model_doc/got_ocr2#transformers.GotOcr2VisionConfig">GotOcr2VisionConfig</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/got_ocr2/modeling_got_ocr2.py#L688"}}),Se=new I({props:{name:"forward",anchor:"transformers.GotOcr2ForConditionalGeneration.forward",parameters:[{name:"input_ids",val:": LongTensor = None"},{name:"pixel_values",val:": FloatTensor = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.List[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"},{name:"cache_position",val:": typing.Optional[torch.LongTensor] = None"},{name:"logits_to_keep",val:": typing.Union[int, torch.Tensor] = 0"}],parametersDescription:[{anchor:"transformers.GotOcr2ForConditionalGeneration.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.GotOcr2ForConditionalGeneration.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape \`(seq_length, num_channels <em> image_size </em> image_size)) &#x2014;
The tensors corresponding to the input images. Pixel values can be obtained using
<a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See <a href="/docs/transformers/main/en/model_doc/vilt#transformers.ViltFeatureExtractor.__call__">GotOcr2ImageProcessor.<strong>call</strong>()</a> for details. <a href="/docs/transformers/main/en/model_doc/got_ocr2#transformers.GotOcr2Processor">GotOcr2Processor</a> uses
<a href="/docs/transformers/main/en/model_doc/got_ocr2#transformers.GotOcr2ImageProcessor">GotOcr2ImageProcessor</a> for processing images.`,name:"pixel_values"},{anchor:"transformers.GotOcr2ForConditionalGeneration.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></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>If <code>past_key_values</code> is used, optionally only the last <code>decoder_input_ids</code> have to be input (see
<code>past_key_values</code>).</p>
<p>If you want to change padding behavior, you should read <code>modeling_opt._prepare_decoder_attention_mask</code>
and modify to your needs. See diagram 1 in <a href="https://arxiv.org/abs/1910.13461" rel="nofollow">the paper</a> for more
information on the default strategy.</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:"attention_mask"},{anchor:"transformers.GotOcr2ForConditionalGeneration.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.n_positions - 1]</code>. <a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.GotOcr2ForConditionalGeneration.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>.</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.GotOcr2ForConditionalGeneration.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.GotOcr2ForConditionalGeneration.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>).`,name:"use_cache"},{anchor:"transformers.GotOcr2ForConditionalGeneration.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.GotOcr2ForConditionalGeneration.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.GotOcr2ForConditionalGeneration.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"},{anchor:"transformers.GotOcr2ForConditionalGeneration.forward.cache_position",description:`<strong>cache_position</strong> (<code>torch.LongTensor</code> of shape <code>(sequence_length)</code>, <em>optional</em>) &#x2014;
Indices depicting the position of the input sequence tokens in the sequence. Contrarily to <code>position_ids</code>,
this tensor is not affected by padding. It is used to update the cache in the correct position and to infer
the complete sequence length.`,name:"cache_position"},{anchor:"transformers.GotOcr2ForConditionalGeneration.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.GotOcr2ForConditionalGeneration.forward.logits_to_keep",description:`<strong>logits_to_keep</strong> (<code>int</code> or <code>torch.Tensor</code>, <em>optional</em>) &#x2014;
If an <code>int</code>, compute logits for the last <code>logits_to_keep</code> tokens. If <code>0</code>, calculate logits for all
<code>input_ids</code> (special case). Only last token logits are needed for generation, and calculating them only for that
token can save memory, which becomes pretty significant for long sequences or large vocabulary size.
If a <code>torch.Tensor</code>, must be 1D corresponding to the indices to keep in the sequence length dimension.
This is useful when using packed tensor format (single dimension for batch and sequence length).`,name:"logits_to_keep"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/got_ocr2/modeling_got_ocr2.py#L741",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <code>transformers.models.got_ocr2.modeling_got_ocr2.GotOcr2CausalLMOutputWithPast</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/got_ocr2#transformers.GotOcr2Config"
>GotOcr2Config</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) — 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>) — Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</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>) — 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>)</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</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>) — 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>) — 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>image_hidden_states</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) — A <code>torch.FloatTensor</code> of size (batch_size, num_images, sequence_length, hidden_size)\`.
image_hidden_states of the model produced by the vision encoder and after projecting the last hidden state.</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.models.got_ocr2.modeling_got_ocr2.GotOcr2CausalLMOutputWithPast</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Y=new xs({props:{$$slots:{default:[zs]},$$scope:{ctx:N}}}),A=new vs({props:{anchor:"transformers.GotOcr2ForConditionalGeneration.forward.example",$$slots:{default:[ks]},$$scope:{ctx:N}}}),Ye=new Zs({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/got_ocr2.md"}}),{c(){f=i("meta"),w=s(),_=i("p"),T=s(),l(R.$$.fragment),b=s(),z=i("div"),z.innerHTML=Po,ft=s(),l(te.$$.fragment),ut=s(),oe=i("p"),oe.innerHTML=Qo,_t=s(),se=i("p"),se.textContent=Eo,yt=s(),ae=i("p"),ae.innerHTML=Ho,bt=s(),B=i("img"),Tt=s(),ne=i("small"),ne.innerHTML=Yo,Mt=s(),re=i("p"),re.textContent=Ao,jt=s(),ie=i("p"),ie.innerHTML=Lo,wt=s(),ce=i("p"),ce.innerHTML=Do,vt=s(),l(le.$$.fragment),Jt=s(),l(me.$$.fragment),It=s(),l(de.$$.fragment),Ut=s(),l(pe.$$.fragment),Gt=s(),l(he.$$.fragment),Ct=s(),l(ge.$$.fragment),xt=s(),fe=i("p"),fe.textContent=Ko,Zt=s(),l(ue.$$.fragment),Rt=s(),l(_e.$$.fragment),zt=s(),ye=i("p"),ye.textContent=es,kt=s(),l(be.$$.fragment),Wt=s(),l(Te.$$.fragment),$t=s(),Me=i("p"),Me.textContent=ts,Ot=s(),l(je.$$.fragment),Nt=s(),l(we.$$.fragment),Bt=s(),ve=i("p"),ve.textContent=os,Vt=s(),l(Je.$$.fragment),Ft=s(),l(Ie.$$.fragment),qt=s(),Ue=i("p"),Ue.innerHTML=ss,Xt=s(),l(Ge.$$.fragment),Pt=s(),V=i("img"),Qt=s(),l(Ce.$$.fragment),Et=s(),v=i("div"),l(xe.$$.fragment),go=s(),Ae=i("p"),Ae.innerHTML=ns,fo=s(),Le=i("p"),Le.innerHTML=rs,uo=s(),De=i("p"),De.innerHTML=is,_o=s(),l(F.$$.fragment),Ht=s(),l(Ze.$$.fragment),St=s(),W=i("div"),l(Re.$$.fragment),yo=s(),Ke=i("p"),Ke.innerHTML=cs,bo=s(),et=i("p"),et.innerHTML=ls,Yt=s(),l(ze.$$.fragment),At=s(),J=i("div"),l(ke.$$.fragment),To=s(),tt=i("p"),tt.textContent=ms,Mo=s(),q=i("div"),l(We.$$.fragment),jo=s(),ot=i("p"),ot.textContent=ds,wo=s(),X=i("div"),l($e.$$.fragment),vo=s(),st=i("p"),st.textContent=ps,Jo=s(),P=i("div"),l(Oe.$$.fragment),Io=s(),at=i("p"),at.innerHTML=hs,Lt=s(),l(Ne.$$.fragment),Dt=s(),U=i("div"),l(Be.$$.fragment),Uo=s(),nt=i("p"),nt.textContent=gs,Go=s(),Q=i("div"),l(Ve.$$.fragment),Co=s(),rt=i("p"),rt.textContent=fs,xo=s(),E=i("div"),l(Fe.$$.fragment),Zo=s(),it=i("p"),it.textContent=us,Kt=s(),l(qe.$$.fragment),eo=s(),G=i("div"),l(Xe.$$.fragment),Ro=s(),ct=i("p"),ct.innerHTML=_s,zo=s(),H=i("div"),l(Pe.$$.fragment),ko=s(),lt=i("p"),lt.innerHTML=ys,Wo=s(),S=i("div"),l(Qe.$$.fragment),$o=s(),mt=i("p"),mt.innerHTML=bs,to=s(),l(Ee.$$.fragment),oo=s(),C=i("div"),l(He.$$.fragment),Oo=s(),dt=i("p"),dt.innerHTML=Ts,No=s(),pt=i("p"),pt.innerHTML=Ms,Bo=s(),k=i("div"),l(Se.$$.fragment),Vo=s(),ht=i("p"),ht.innerHTML=js,Fo=s(),l(Y.$$.fragment),qo=s(),l(A.$$.fragment),so=s(),l(Ye.$$.fragment),ao=s(),gt=i("p"),this.h()},l(e){const t=Cs("svelte-u9bgzb",document.head);f=c(t,"META",{name:!0,content:!0}),t.forEach(o),w=a(e),_=c(e,"P",{}),M(_).forEach(o),T=a(e),m(R.$$.fragment,e),b=a(e),z=c(e,"DIV",{class:!0,"data-svelte-h":!0}),u(z)!=="svelte-13t8s2t"&&(z.innerHTML=Po),ft=a(e),m(te.$$.fragment,e),ut=a(e),oe=c(e,"P",{"data-svelte-h":!0}),u(oe)!=="svelte-g5p5bk"&&(oe.innerHTML=Qo),_t=a(e),se=c(e,"P",{"data-svelte-h":!0}),u(se)!=="svelte-vfdo9a"&&(se.textContent=Eo),yt=a(e),ae=c(e,"P",{"data-svelte-h":!0}),u(ae)!=="svelte-1gg8rmy"&&(ae.innerHTML=Ho),bt=a(e),B=c(e,"IMG",{src:!0,alt:!0,width:!0}),Tt=a(e),ne=c(e,"SMALL",{"data-svelte-h":!0}),u(ne)!=="svelte-a6x3c0"&&(ne.innerHTML=Yo),Mt=a(e),re=c(e,"P",{"data-svelte-h":!0}),u(re)!=="svelte-axv494"&&(re.textContent=Ao),jt=a(e),ie=c(e,"P",{"data-svelte-h":!0}),u(ie)!=="svelte-16ypbp5"&&(ie.innerHTML=Lo),wt=a(e),ce=c(e,"P",{"data-svelte-h":!0}),u(ce)!=="svelte-1m1qiop"&&(ce.innerHTML=Do),vt=a(e),m(le.$$.fragment,e),Jt=a(e),m(me.$$.fragment,e),It=a(e),m(de.$$.fragment,e),Ut=a(e),m(pe.$$.fragment,e),Gt=a(e),m(he.$$.fragment,e),Ct=a(e),m(ge.$$.fragment,e),xt=a(e),fe=c(e,"P",{"data-svelte-h":!0}),u(fe)!=="svelte-148y0f4"&&(fe.textContent=Ko),Zt=a(e),m(ue.$$.fragment,e),Rt=a(e),m(_e.$$.fragment,e),zt=a(e),ye=c(e,"P",{"data-svelte-h":!0}),u(ye)!=="svelte-14wxjuz"&&(ye.textContent=es),kt=a(e),m(be.$$.fragment,e),Wt=a(e),m(Te.$$.fragment,e),$t=a(e),Me=c(e,"P",{"data-svelte-h":!0}),u(Me)!=="svelte-17mhybv"&&(Me.textContent=ts),Ot=a(e),m(je.$$.fragment,e),Nt=a(e),m(we.$$.fragment,e),Bt=a(e),ve=c(e,"P",{"data-svelte-h":!0}),u(ve)!=="svelte-2al3wt"&&(ve.textContent=os),Vt=a(e),m(Je.$$.fragment,e),Ft=a(e),m(Ie.$$.fragment,e),qt=a(e),Ue=c(e,"P",{"data-svelte-h":!0}),u(Ue)!=="svelte-ebj6ng"&&(Ue.innerHTML=ss),Xt=a(e),m(Ge.$$.fragment,e),Pt=a(e),V=c(e,"IMG",{src:!0,alt:!0,width:!0}),Qt=a(e),m(Ce.$$.fragment,e),Et=a(e),v=c(e,"DIV",{class:!0});var x=M(v);m(xe.$$.fragment,x),go=a(x),Ae=c(x,"P",{"data-svelte-h":!0}),u(Ae)!=="svelte-nodo4f"&&(Ae.innerHTML=ns),fo=a(x),Le=c(x,"P",{"data-svelte-h":!0}),u(Le)!=="svelte-t42ckt"&&(Le.innerHTML=rs),uo=a(x),De=c(x,"P",{"data-svelte-h":!0}),u(De)!=="svelte-o55m63"&&(De.innerHTML=is),_o=a(x),m(F.$$.fragment,x),x.forEach(o),Ht=a(e),m(Ze.$$.fragment,e),St=a(e),W=c(e,"DIV",{class:!0});var $=M(W);m(Re.$$.fragment,$),yo=a($),Ke=c($,"P",{"data-svelte-h":!0}),u(Ke)!=="svelte-1dcilvq"&&(Ke.innerHTML=cs),bo=a($),et=c($,"P",{"data-svelte-h":!0}),u(et)!=="svelte-o55m63"&&(et.innerHTML=ls),$.forEach(o),Yt=a(e),m(ze.$$.fragment,e),At=a(e),J=c(e,"DIV",{class:!0});var Z=M(J);m(ke.$$.fragment,Z),To=a(Z),tt=c(Z,"P",{"data-svelte-h":!0}),u(tt)!=="svelte-youup"&&(tt.textContent=ms),Mo=a(Z),q=c(Z,"DIV",{class:!0});var ro=M(q);m(We.$$.fragment,ro),jo=a(ro),ot=c(ro,"P",{"data-svelte-h":!0}),u(ot)!=="svelte-j3z5fq"&&(ot.textContent=ds),ro.forEach(o),wo=a(Z),X=c(Z,"DIV",{class:!0});var io=M(X);m($e.$$.fragment,io),vo=a(io),st=c(io,"P",{"data-svelte-h":!0}),u(st)!=="svelte-1x3yxsa"&&(st.textContent=ps),io.forEach(o),Jo=a(Z),P=c(Z,"DIV",{class:!0});var co=M(P);m(Oe.$$.fragment,co),Io=a(co),at=c(co,"P",{"data-svelte-h":!0}),u(at)!=="svelte-1oee9wu"&&(at.innerHTML=hs),co.forEach(o),Z.forEach(o),Lt=a(e),m(Ne.$$.fragment,e),Dt=a(e),U=c(e,"DIV",{class:!0});var L=M(U);m(Be.$$.fragment,L),Uo=a(L),nt=c(L,"P",{"data-svelte-h":!0}),u(nt)!=="svelte-6wdgcy"&&(nt.textContent=gs),Go=a(L),Q=c(L,"DIV",{class:!0});var lo=M(Q);m(Ve.$$.fragment,lo),Co=a(lo),rt=c(lo,"P",{"data-svelte-h":!0}),u(rt)!=="svelte-n3q7zj"&&(rt.textContent=fs),lo.forEach(o),xo=a(L),E=c(L,"DIV",{class:!0});var mo=M(E);m(Fe.$$.fragment,mo),Zo=a(mo),it=c(mo,"P",{"data-svelte-h":!0}),u(it)!=="svelte-1x3yxsa"&&(it.textContent=us),mo.forEach(o),L.forEach(o),Kt=a(e),m(qe.$$.fragment,e),eo=a(e),G=c(e,"DIV",{class:!0});var D=M(G);m(Xe.$$.fragment,D),Ro=a(D),ct=c(D,"P",{"data-svelte-h":!0}),u(ct)!=="svelte-1v291js"&&(ct.innerHTML=_s),zo=a(D),H=c(D,"DIV",{class:!0});var po=M(H);m(Pe.$$.fragment,po),ko=a(po),lt=c(po,"P",{"data-svelte-h":!0}),u(lt)!=="svelte-1yrf9bj"&&(lt.innerHTML=ys),po.forEach(o),Wo=a(D),S=c(D,"DIV",{class:!0});var ho=M(S);m(Qe.$$.fragment,ho),$o=a(ho),mt=c(ho,"P",{"data-svelte-h":!0}),u(mt)!=="svelte-1jl7gd5"&&(mt.innerHTML=bs),ho.forEach(o),D.forEach(o),to=a(e),m(Ee.$$.fragment,e),oo=a(e),C=c(e,"DIV",{class:!0});var K=M(C);m(He.$$.fragment,K),Oo=a(K),dt=c(K,"P",{"data-svelte-h":!0}),u(dt)!=="svelte-1abibdw"&&(dt.innerHTML=Ts),No=a(K),pt=c(K,"P",{"data-svelte-h":!0}),u(pt)!=="svelte-hswkmf"&&(pt.innerHTML=Ms),Bo=a(K),k=c(K,"DIV",{class:!0});var ee=M(k);m(Se.$$.fragment,ee),Vo=a(ee),ht=c(ee,"P",{"data-svelte-h":!0}),u(ht)!=="svelte-17arr04"&&(ht.innerHTML=js),Fo=a(ee),m(Y.$$.fragment,ee),qo=a(ee),m(A.$$.fragment,ee),ee.forEach(o),K.forEach(o),so=a(e),m(Ye.$$.fragment,e),ao=a(e),gt=c(e,"P",{}),M(gt).forEach(o),this.h()},h(){y(f,"name","hf:doc:metadata"),y(f,"content",$s),y(z,"class","flex flex-wrap space-x-1"),ws(B.src,So="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/got_ocr_overview.png")||y(B,"src",So),y(B,"alt","drawing"),y(B,"width","600"),ws(V.src,as="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/sheet_music.svg")||y(V,"src",as),y(V,"alt","drawing"),y(V,"width","600"),y(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){r(document.head,f),n(e,w,t),n(e,_,t),n(e,T,t),d(R,e,t),n(e,b,t),n(e,z,t),n(e,ft,t),d(te,e,t),n(e,ut,t),n(e,oe,t),n(e,_t,t),n(e,se,t),n(e,yt,t),n(e,ae,t),n(e,bt,t),n(e,B,t),n(e,Tt,t),n(e,ne,t),n(e,Mt,t),n(e,re,t),n(e,jt,t),n(e,ie,t),n(e,wt,t),n(e,ce,t),n(e,vt,t),d(le,e,t),n(e,Jt,t),d(me,e,t),n(e,It,t),d(de,e,t),n(e,Ut,t),d(pe,e,t),n(e,Gt,t),d(he,e,t),n(e,Ct,t),d(ge,e,t),n(e,xt,t),n(e,fe,t),n(e,Zt,t),d(ue,e,t),n(e,Rt,t),d(_e,e,t),n(e,zt,t),n(e,ye,t),n(e,kt,t),d(be,e,t),n(e,Wt,t),d(Te,e,t),n(e,$t,t),n(e,Me,t),n(e,Ot,t),d(je,e,t),n(e,Nt,t),d(we,e,t),n(e,Bt,t),n(e,ve,t),n(e,Vt,t),d(Je,e,t),n(e,Ft,t),d(Ie,e,t),n(e,qt,t),n(e,Ue,t),n(e,Xt,t),d(Ge,e,t),n(e,Pt,t),n(e,V,t),n(e,Qt,t),d(Ce,e,t),n(e,Et,t),n(e,v,t),d(xe,v,null),r(v,go),r(v,Ae),r(v,fo),r(v,Le),r(v,uo),r(v,De),r(v,_o),d(F,v,null),n(e,Ht,t),d(Ze,e,t),n(e,St,t),n(e,W,t),d(Re,W,null),r(W,yo),r(W,Ke),r(W,bo),r(W,et),n(e,Yt,t),d(ze,e,t),n(e,At,t),n(e,J,t),d(ke,J,null),r(J,To),r(J,tt),r(J,Mo),r(J,q),d(We,q,null),r(q,jo),r(q,ot),r(J,wo),r(J,X),d($e,X,null),r(X,vo),r(X,st),r(J,Jo),r(J,P),d(Oe,P,null),r(P,Io),r(P,at),n(e,Lt,t),d(Ne,e,t),n(e,Dt,t),n(e,U,t),d(Be,U,null),r(U,Uo),r(U,nt),r(U,Go),r(U,Q),d(Ve,Q,null),r(Q,Co),r(Q,rt),r(U,xo),r(U,E),d(Fe,E,null),r(E,Zo),r(E,it),n(e,Kt,t),d(qe,e,t),n(e,eo,t),n(e,G,t),d(Xe,G,null),r(G,Ro),r(G,ct),r(G,zo),r(G,H),d(Pe,H,null),r(H,ko),r(H,lt),r(G,Wo),r(G,S),d(Qe,S,null),r(S,$o),r(S,mt),n(e,to,t),d(Ee,e,t),n(e,oo,t),n(e,C,t),d(He,C,null),r(C,Oo),r(C,dt),r(C,No),r(C,pt),r(C,Bo),r(C,k),d(Se,k,null),r(k,Vo),r(k,ht),r(k,Fo),d(Y,k,null),r(k,qo),d(A,k,null),n(e,so,t),d(Ye,e,t),n(e,ao,t),n(e,gt,t),no=!0},p(e,[t]){const x={};t&2&&(x.$$scope={dirty:t,ctx:e}),F.$set(x);const $={};t&2&&($.$$scope={dirty:t,ctx:e}),Y.$set($);const Z={};t&2&&(Z.$$scope={dirty:t,ctx:e}),A.$set(Z)},i(e){no||(p(R.$$.fragment,e),p(te.$$.fragment,e),p(le.$$.fragment,e),p(me.$$.fragment,e),p(de.$$.fragment,e),p(pe.$$.fragment,e),p(he.$$.fragment,e),p(ge.$$.fragment,e),p(ue.$$.fragment,e),p(_e.$$.fragment,e),p(be.$$.fragment,e),p(Te.$$.fragment,e),p(je.$$.fragment,e),p(we.$$.fragment,e),p(Je.$$.fragment,e),p(Ie.$$.fragment,e),p(Ge.$$.fragment,e),p(Ce.$$.fragment,e),p(xe.$$.fragment,e),p(F.$$.fragment,e),p(Ze.$$.fragment,e),p(Re.$$.fragment,e),p(ze.$$.fragment,e),p(ke.$$.fragment,e),p(We.$$.fragment,e),p($e.$$.fragment,e),p(Oe.$$.fragment,e),p(Ne.$$.fragment,e),p(Be.$$.fragment,e),p(Ve.$$.fragment,e),p(Fe.$$.fragment,e),p(qe.$$.fragment,e),p(Xe.$$.fragment,e),p(Pe.$$.fragment,e),p(Qe.$$.fragment,e),p(Ee.$$.fragment,e),p(He.$$.fragment,e),p(Se.$$.fragment,e),p(Y.$$.fragment,e),p(A.$$.fragment,e),p(Ye.$$.fragment,e),no=!0)},o(e){h(R.$$.fragment,e),h(te.$$.fragment,e),h(le.$$.fragment,e),h(me.$$.fragment,e),h(de.$$.fragment,e),h(pe.$$.fragment,e),h(he.$$.fragment,e),h(ge.$$.fragment,e),h(ue.$$.fragment,e),h(_e.$$.fragment,e),h(be.$$.fragment,e),h(Te.$$.fragment,e),h(je.$$.fragment,e),h(we.$$.fragment,e),h(Je.$$.fragment,e),h(Ie.$$.fragment,e),h(Ge.$$.fragment,e),h(Ce.$$.fragment,e),h(xe.$$.fragment,e),h(F.$$.fragment,e),h(Ze.$$.fragment,e),h(Re.$$.fragment,e),h(ze.$$.fragment,e),h(ke.$$.fragment,e),h(We.$$.fragment,e),h($e.$$.fragment,e),h(Oe.$$.fragment,e),h(Ne.$$.fragment,e),h(Be.$$.fragment,e),h(Ve.$$.fragment,e),h(Fe.$$.fragment,e),h(qe.$$.fragment,e),h(Xe.$$.fragment,e),h(Pe.$$.fragment,e),h(Qe.$$.fragment,e),h(Ee.$$.fragment,e),h(He.$$.fragment,e),h(Se.$$.fragment,e),h(Y.$$.fragment,e),h(A.$$.fragment,e),h(Ye.$$.fragment,e),no=!1},d(e){e&&(o(w),o(_),o(T),o(b),o(z),o(ft),o(ut),o(oe),o(_t),o(se),o(yt),o(ae),o(bt),o(B),o(Tt),o(ne),o(Mt),o(re),o(jt),o(ie),o(wt),o(ce),o(vt),o(Jt),o(It),o(Ut),o(Gt),o(Ct),o(xt),o(fe),o(Zt),o(Rt),o(zt),o(ye),o(kt),o(Wt),o($t),o(Me),o(Ot),o(Nt),o(Bt),o(ve),o(Vt),o(Ft),o(qt),o(Ue),o(Xt),o(Pt),o(V),o(Qt),o(Et),o(v),o(Ht),o(St),o(W),o(Yt),o(At),o(J),o(Lt),o(Dt),o(U),o(Kt),o(eo),o(G),o(to),o(oo),o(C),o(so),o(ao),o(gt)),o(f),g(R,e),g(te,e),g(le,e),g(me,e),g(de,e),g(pe,e),g(he,e),g(ge,e),g(ue,e),g(_e,e),g(be,e),g(Te,e),g(je,e),g(we,e),g(Je,e),g(Ie,e),g(Ge,e),g(Ce,e),g(xe),g(F),g(Ze,e),g(Re),g(ze,e),g(ke),g(We),g($e),g(Oe),g(Ne,e),g(Be),g(Ve),g(Fe),g(qe,e),g(Xe),g(Pe),g(Qe),g(Ee,e),g(He),g(Se),g(Y),g(A),g(Ye,e)}}}const $s='{"title":"GOT-OCR2","local":"got-ocr2","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Usage example","local":"usage-example","sections":[{"title":"Plain text inference","local":"plain-text-inference","sections":[],"depth":3},{"title":"Plain text inference batched","local":"plain-text-inference-batched","sections":[],"depth":3},{"title":"Formatted text inference","local":"formatted-text-inference","sections":[],"depth":3},{"title":"Inference on multiple pages","local":"inference-on-multiple-pages","sections":[],"depth":3},{"title":"Inference on cropped patches","local":"inference-on-cropped-patches","sections":[],"depth":3},{"title":"Inference on a specific region","local":"inference-on-a-specific-region","sections":[],"depth":3},{"title":"Inference on general OCR data example: sheet music","local":"inference-on-general-ocr-data-example-sheet-music","sections":[],"depth":3}],"depth":2},{"title":"GotOcr2Config","local":"transformers.GotOcr2Config","sections":[],"depth":2},{"title":"GotOcr2VisionConfig","local":"transformers.GotOcr2VisionConfig","sections":[],"depth":2},{"title":"GotOcr2ImageProcessor","local":"transformers.GotOcr2ImageProcessor","sections":[],"depth":2},{"title":"GotOcr2ImageProcessorFast","local":"transformers.GotOcr2ImageProcessorFast","sections":[],"depth":2},{"title":"GotOcr2Processor","local":"transformers.GotOcr2Processor","sections":[],"depth":2},{"title":"GotOcr2ForConditionalGeneration","local":"transformers.GotOcr2ForConditionalGeneration","sections":[],"depth":2}],"depth":1}';function Os(N){return Is(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Qs extends Us{constructor(f){super(),Gs(this,f,Os,Ws,Js,{})}}export{Qs as component};
