import{s as Qt,o as Ot,n as Ze}from"../chunks/scheduler.9bc65507.js";import{S as At,i as Kt,g as l,s as a,r as g,A as eo,h as c,f as o,c as r,j as R,u as h,x as b,k as N,y as i,a as d,v as f,d as u,t as _,w as y}from"../chunks/index.707bf1b6.js";import{T as Dt}from"../chunks/Tip.c2ecdbf4.js";import{D as G}from"../chunks/Docstring.570ddb64.js";import{C as ot}from"../chunks/CodeBlock.54a9f38d.js";import{E as kt}from"../chunks/ExampleCodeBlock.bc2be6bc.js";import{H as fe,E as to}from"../chunks/EditOnGithub.922df6ba.js";function oo(j){let s,I="Example:",m,p,T;return p=new ot({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMElkZWZpY3MyTW9kZWwlMkMlMjBJZGVmaWNzMkNvbmZpZyUwQSUyMyUyMEluaXRpYWxpemluZyUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwSWRlZmljczJDb25maWcoKSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBtb2RlbCUyMGZyb20lMjB0aGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBJZGVmaWNzMk1vZGVsKGNvbmZpZ3VyYXRpb24pJTBBJTIzJTIwQWNjZXNzaW5nJTIwdGhlJTIwbW9kZWwlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMG1vZGVsLmNvbmZpZw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Idefics2Model, Idefics2Config
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = Idefics2Config()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model from the configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Idefics2Model(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(){s=l("p"),s.textContent=I,m=a(),g(p.$$.fragment)},l(n){s=c(n,"P",{"data-svelte-h":!0}),b(s)!=="svelte-11lpom8"&&(s.textContent=I),m=r(n),h(p.$$.fragment,n)},m(n,M){d(n,s,M),d(n,m,M),f(p,n,M),T=!0},p:Ze,i(n){T||(u(p.$$.fragment,n),T=!0)},o(n){_(p.$$.fragment,n),T=!1},d(n){n&&(o(s),o(m)),y(p,n)}}}function so(j){let s,I=`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(){s=l("p"),s.innerHTML=I},l(m){s=c(m,"P",{"data-svelte-h":!0}),b(s)!=="svelte-fincs2"&&(s.innerHTML=I)},m(m,p){d(m,s,p)},p:Ze,d(m){m&&o(s)}}}function no(j){let s,I=`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(){s=l("p"),s.innerHTML=I},l(m){s=c(m,"P",{"data-svelte-h":!0}),b(s)!=="svelte-fincs2"&&(s.innerHTML=I)},m(m,p){d(m,s,p)},p:Ze,d(m){m&&o(s)}}}function ao(j){let s,I="Example:",m,p,T;return p=new ot({props:{code:"aW1wb3J0JTIwcmVxdWVzdHMlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBQSUwlMjBpbXBvcnQlMjBJbWFnZSUwQWZyb20lMjBpbyUyMGltcG9ydCUyMEJ5dGVzSU8lMEElMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Byb2Nlc3NvciUyQyUyMEF1dG9Nb2RlbEZvclZpc2lvbjJTZXElMEFmcm9tJTIwdHJhbnNmb3JtZXJzLmltYWdlX3V0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUwQSUwQSUyMyUyME5vdGUlMjB0aGF0JTIwcGFzc2luZyUyMHRoZSUyMGltYWdlJTIwdXJscyUyMChpbnN0ZWFkJTIwb2YlMjB0aGUlMjBhY3R1YWwlMjBwaWwlMjBpbWFnZXMpJTIwdG8lMjB0aGUlMjBwcm9jZXNzb3IlMjBpcyUyMGFsc28lMjBwb3NzaWJsZSUwQWltYWdlMSUyMCUzRCUyMGxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZjZG4uYnJpdGFubmljYS5jb20lMkY2MSUyRjkzMDYxLTA1MC05OTE0N0RDRSUyRlN0YXR1ZS1vZi1MaWJlcnR5LUlzbGFuZC1OZXctWW9yay1CYXkuanBnJTIyKSUwQWltYWdlMiUyMCUzRCUyMGxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZjZG4uYnJpdGFubmljYS5jb20lMkY1OSUyRjk0NDU5LTA1MC1EQkE0MjQ2NyUyRlNreWxpbmUtQ2hpY2Fnby5qcGclMjIpJTBBaW1hZ2UzJTIwJTNEJTIwbG9hZF9pbWFnZSglMjJodHRwcyUzQSUyRiUyRmNkbi5icml0YW5uaWNhLmNvbSUyRjY4JTJGMTcwODY4LTA1MC04RERFODI2MyUyRkdvbGRlbi1HYXRlLUJyaWRnZS1TYW4tRnJhbmNpc2NvLmpwZyUyMiklMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJIdWdnaW5nRmFjZU00JTJGaWRlZmljczItOGItYmFzZSUyMiklMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclZpc2lvbjJTZXEuZnJvbV9wcmV0cmFpbmVkKCUyMkh1Z2dpbmdGYWNlTTQlMkZpZGVmaWNzMi04Yi1iYXNlJTIyJTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIpJTBBJTBBQkFEX1dPUkRTX0lEUyUyMCUzRCUyMHByb2Nlc3Nvci50b2tlbml6ZXIoJTVCJTIyJTNDaW1hZ2UlM0UlMjIlMkMlMjAlMjIlM0NmYWtlX3Rva2VuX2Fyb3VuZF9pbWFnZSUzRSUyMiU1RCUyQyUyMGFkZF9zcGVjaWFsX3Rva2VucyUzREZhbHNlKS5pbnB1dF9pZHMlMEFFT1NfV09SRFNfSURTJTIwJTNEJTIwJTVCcHJvY2Vzc29yLnRva2VuaXplci5lb3NfdG9rZW5faWQlNUQlMEElMEElMjMlMjBDcmVhdGUlMjBpbnB1dHMlMEFwcm9tcHRzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIyJTNDaW1hZ2UlM0VJbiUyMHRoaXMlMjBpbWFnZSUyQyUyMHdlJTIwY2FuJTIwc2VlJTIwdGhlJTIwY2l0eSUyMG9mJTIwTmV3JTIwWW9yayUyQyUyMGFuZCUyMG1vcmUlMjBzcGVjaWZpY2FsbHklMjB0aGUlMjBTdGF0dWUlMjBvZiUyMExpYmVydHkuJTNDaW1hZ2UlM0VJbiUyMHRoaXMlMjBpbWFnZSUyQyUyMiUyQyUwQSUyMCUyMCUyMkluJTIwd2hpY2glMjBjaXR5JTIwaXMlMjB0aGF0JTIwYnJpZGdlJTIwbG9jYXRlZCUzRiUzQ2ltYWdlJTNFJTIyJTJDJTBBJTVEJTBBaW1hZ2VzJTIwJTNEJTIwJTVCJTVCaW1hZ2UxJTJDJTIwaW1hZ2UyJTVEJTJDJTIwJTVCaW1hZ2UzJTVEJTVEJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKHRleHQlM0Rwcm9tcHRzJTJDJTIwcGFkZGluZyUzRFRydWUlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS50byglMjJjdWRhJTIyKSUwQSUwQSUyMyUyMEdlbmVyYXRlJTBBZ2VuZXJhdGVkX2lkcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzJTJDJTIwYmFkX3dvcmRzX2lkcyUzREJBRF9XT1JEU19JRFMlMkMlMjBtYXhfbmV3X3Rva2VucyUzRDIwKSUwQWdlbmVyYXRlZF90ZXh0cyUyMCUzRCUyMHByb2Nlc3Nvci5iYXRjaF9kZWNvZGUoZ2VuZXJhdGVkX2lkcyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSUwQSUwQXByaW50KGdlbmVyYXRlZF90ZXh0cyk=",highlighted:`<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">import</span> torch
<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">from</span> io <span class="hljs-keyword">import</span> BytesIO

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, AutoModelForVision2Seq
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.image_utils <span class="hljs-keyword">import</span> load_image

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Note that passing the image urls (instead of the actual pil images) to the processor is also possible</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image1 = load_image(<span class="hljs-string">&quot;https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image2 = load_image(<span class="hljs-string">&quot;https://cdn.britannica.com/59/94459-050-DBA42467/Skyline-Chicago.jpg&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image3 = load_image(<span class="hljs-string">&quot;https://cdn.britannica.com/68/170868-050-8DDE8263/Golden-Gate-Bridge-San-Francisco.jpg&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;HuggingFaceM4/idefics2-8b-base&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForVision2Seq.from_pretrained(<span class="hljs-string">&quot;HuggingFaceM4/idefics2-8b-base&quot;</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>BAD_WORDS_IDS = processor.tokenizer([<span class="hljs-string">&quot;&lt;image&gt;&quot;</span>, <span class="hljs-string">&quot;&lt;fake_token_around_image&gt;&quot;</span>], add_special_tokens=<span class="hljs-literal">False</span>).input_ids
<span class="hljs-meta">&gt;&gt;&gt; </span>EOS_WORDS_IDS = [processor.tokenizer.eos_token_id]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Create inputs</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>prompts = [
<span class="hljs-meta">... </span>  <span class="hljs-string">&quot;&lt;image&gt;In this image, we can see the city of New York, and more specifically the Statue of Liberty.&lt;image&gt;In this image,&quot;</span>,
<span class="hljs-meta">... </span>  <span class="hljs-string">&quot;In which city is that bridge located?&lt;image&gt;&quot;</span>,
<span class="hljs-meta">... </span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>images = [[image1, image2], [image3]]
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(text=prompts, padding=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;pt&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>generated_ids = model.generate(**inputs, bad_words_ids=BAD_WORDS_IDS, max_new_tokens=<span class="hljs-number">20</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_texts = processor.batch_decode(generated_ids, skip_special_tokens=<span class="hljs-literal">True</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(generated_texts)
[<span class="hljs-string">&#x27;In this image, we can see the city of New York, and more specifically the Statue of Liberty. In this image, we can see the city of New York, and more specifically the Statue of Liberty.\\n\\n&#x27;</span>, <span class="hljs-string">&#x27;In which city is that bridge located?\\n\\nThe bridge is located in the city of Pittsburgh, Pennsylvania.\\n\\n\\nThe bridge is&#x27;</span>]`,wrap:!1}}),{c(){s=l("p"),s.textContent=I,m=a(),g(p.$$.fragment)},l(n){s=c(n,"P",{"data-svelte-h":!0}),b(s)!=="svelte-11lpom8"&&(s.textContent=I),m=r(n),h(p.$$.fragment,n)},m(n,M){d(n,s,M),d(n,m,M),f(p,n,M),T=!0},p:Ze,i(n){T||(u(p.$$.fragment,n),T=!0)},o(n){_(p.$$.fragment,n),T=!1},d(n){n&&(o(s),o(m)),y(p,n)}}}function ro(j){let s,I="Example:",m,p,T;return p=new ot({props:{code:"aW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwSWRlZmljczJQcm9jZXNzb3IlMEFmcm9tJTIwdHJhbnNmb3JtZXJzLmltYWdlX3V0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUwQSUwQXByb2Nlc3NvciUyMCUzRCUyMElkZWZpY3MyUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJIdWdnaW5nRmFjZU00JTJGaWRlZmljczItOGIlMjIlMkMlMjBpbWFnZV9zZXFfbGVuJTNEMiklMEFwcm9jZXNzb3IuaW1hZ2VfcHJvY2Vzc29yLmRvX2ltYWdlX3NwbGl0dGluZyUyMCUzRCUyMEZhbHNlJTIwJTIwJTIzJTIwRm9yY2UlMjBhcyUyMEZhbHNlJTIwdG8lMjBzaW1wbGlmeSUyMHRoZSUyMGV4YW1wbGUlMEElMEF1cmwxJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZjZG4uYnJpdGFubmljYS5jb20lMkY2MSUyRjkzMDYxLTA1MC05OTE0N0RDRSUyRlN0YXR1ZS1vZi1MaWJlcnR5LUlzbGFuZC1OZXctWW9yay1CYXkuanBnJTIyJTBBdXJsMiUyMCUzRCUyMCUyMmh0dHBzJTNBJTJGJTJGY2RuLmJyaXRhbm5pY2EuY29tJTJGNTklMkY5NDQ1OS0wNTAtREJBNDI0NjclMkZTa3lsaW5lLUNoaWNhZ28uanBnJTIyJTBBJTBBaW1hZ2UxJTJDJTIwaW1hZ2UyJTIwJTNEJTIwbG9hZF9pbWFnZSh1cmwxKSUyQyUyMGxvYWRfaW1hZ2UodXJsMiklMEFpbWFnZXMlMjAlM0QlMjAlNUIlNUJpbWFnZTElNUQlMkMlMjAlNUJpbWFnZTIlNUQlNUQlMEElMEF0ZXh0JTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIyJTNDaW1hZ2UlM0VJbiUyMHRoaXMlMjBpbWFnZSUyQyUyMHdlJTIwc2VlJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyYmxhJTIwYmxhJTIwYmxhJTNDaW1hZ2UlM0UlMjIlMkMlMEElNUQlMEFvdXRwdXRzJTIwJTNEJTIwcHJvY2Vzc29yKHRleHQlM0R0ZXh0JTJDJTIwaW1hZ2VzJTNEaW1hZ2VzJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiUyQyUyMHBhZGRpbmclM0RUcnVlKSUwQWlucHV0X2lkcyUyMCUzRCUyMG91dHB1dHMuaW5wdXRfaWRzJTBBaW5wdXRfdG9rZW5zJTIwJTNEJTIwcHJvY2Vzc29yLnRva2VuaXplci5iYXRjaF9kZWNvZGUoaW5wdXRfaWRzKSUwQXByaW50KGlucHV0X3Rva2Vucyk=",highlighted:`<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> Idefics2Processor
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.image_utils <span class="hljs-keyword">import</span> load_image

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = Idefics2Processor.from_pretrained(<span class="hljs-string">&quot;HuggingFaceM4/idefics2-8b&quot;</span>, image_seq_len=<span class="hljs-number">2</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor.image_processor.do_image_splitting = <span class="hljs-literal">False</span>  <span class="hljs-comment"># Force as False to simplify the example</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>url1 = <span class="hljs-string">&quot;https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>url2 = <span class="hljs-string">&quot;https://cdn.britannica.com/59/94459-050-DBA42467/Skyline-Chicago.jpg&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>image1, image2 = load_image(url1), load_image(url2)
<span class="hljs-meta">&gt;&gt;&gt; </span>images = [[image1], [image2]]

<span class="hljs-meta">&gt;&gt;&gt; </span>text = [
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;&lt;image&gt;In this image, we see&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;bla bla bla&lt;image&gt;&quot;</span>,
<span class="hljs-meta">... </span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = processor(text=text, images=images, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>, padding=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = outputs.input_ids
<span class="hljs-meta">&gt;&gt;&gt; </span>input_tokens = processor.tokenizer.batch_decode(input_ids)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(input_tokens)
[<span class="hljs-string">&#x27;&lt;s&gt;&lt;fake_token_around_image&gt;&lt;image&gt;&lt;image&gt;&lt;fake_token_around_image&gt; In this image, we see&#x27;</span>, <span class="hljs-string">&#x27;&lt;s&gt; bla bla bla&lt;fake_token_around_image&gt;&lt;image&gt;&lt;image&gt;&lt;fake_token_around_image&gt;&#x27;</span>]`,wrap:!1}}),{c(){s=l("p"),s.textContent=I,m=a(),g(p.$$.fragment)},l(n){s=c(n,"P",{"data-svelte-h":!0}),b(s)!=="svelte-11lpom8"&&(s.textContent=I),m=r(n),h(p.$$.fragment,n)},m(n,M){d(n,s,M),d(n,m,M),f(p,n,M),T=!0},p:Ze,i(n){T||(u(p.$$.fragment,n),T=!0)},o(n){_(p.$$.fragment,n),T=!1},d(n){n&&(o(s),o(m)),y(p,n)}}}function io(j){let s,I,m,p,T,n,M,Fe,L,zt=`The Idefics2 model was created by the <a href="https://huggingface.co/HuggingFaceM4" rel="nofollow">Hugging Face M4</a> team and authored by Léo Tronchon, Hugo Laurencon, Victor Sanh.
The accompanying blog post can be found <a href="https://huggingface.co/blog/idefics2" rel="nofollow">here</a>.`,Re,Y,jt=`Idefics2 is an open multimodal model that accepts arbitrary sequences of image and text inputs and produces text
outputs. The model can answer questions about images, describe visual content, create stories grounded on multiple
images, or simply behave as a pure language model without visual inputs. It improves upon IDEFICS-1, notably on
document understanding, OCR, or visual reasoning. Idefics2 is lightweight (8 billion parameters) and treats
images in their native aspect ratio and resolution, which allows for varying inference efficiency.`,Ne,D,xt="Tips:",Pe,Q,Ct="<li>Each sample can contain multiple images, and the number of images can vary between samples. The processor will pad the inputs to the maximum number of images in a batch for input to the model.</li> <li>The processor has a <code>do_image_splitting</code> option. If <code>True</code>, each input image will be split into 4 sub-images, and concatenated with the original to form 5 images. This is useful for increasing model performance. Make sure <code>processor.image_processor.do_image_splitting</code> is set to <code>False</code> if the model was not trained with this option.</li> <li><code>text</code> passed to the processor should have the <code>&lt;image&gt;</code> tokens where the images should be inserted. And <code>&lt;end_of_utterance&gt;</code> at the end of each utterance if the text is a chat message.</li> <li>The processor has its own <code>apply_chat_template</code> method to convert chat messages to text that can then be passed as <code>text</code> to the processor.</li>",Ge,O,$t="Example of how to use the processor on chat messages:",Be,A,Se,K,Wt=`This model was contributed by <a href="https://huggingface.co/amyeroberts" rel="nofollow">amyeroberts</a>.
The original code can be found <a href="https://huggingface.co/HuggingFaceM4/idefics2" rel="nofollow">here</a>.`,qe,ee,Ee,v,te,st,ue,Zt=`This is the configuration class to store the configuration of a <a href="/docs/transformers/main/en/model_doc/idefics2#transformers.Idefics2Model">Idefics2Model</a>. It is used to instantiate a
Idefics2 model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yield a similar configuration to that of the model of the Idefics2
<a href="https://huggingface.co/HuggingFaceM4/idefics2-8b" rel="nofollow">HuggingFaceM4/idefics2-8b</a> architecture.`,nt,_e,Ft=`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.`,at,B,Ve,oe,Xe,J,se,rt,ye,Rt=`Idefics2 model consisting of a SIGLIP vision encoder and Mistral language decoder
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.)`,it,be,Nt=`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.`,dt,w,ne,lt,Te,Pt='The <a href="/docs/transformers/main/en/model_doc/idefics2#transformers.Idefics2Model">Idefics2Model</a> forward method, overrides the <code>__call__</code> special method.',ct,S,mt,Ie,Gt=`Inputs fed to the model can have an arbitrary number of images. To account for this, pixel_values fed to
the model have image padding -> (batch_size, max_num_images, 3, max_heights, max_widths) where
max_num_images is the maximum number of images among the batch_size samples in the batch.`,pt,Me,Bt=`Padding images are not needed beyond padding the pixel_values at the entrance of the model.
For efficiency, we only pass through the vision_model’s forward the real images by
discarding the padding images i.e. pixel_values of size (image_batch_size, 3, height, width) where
image_batch_size would be 7 when num_images_per_sample=[1, 3, 1, 2] and max_num_images would be 3.`,He,ae,Le,U,re,gt,we,St=`The Idefics2 Model with a language modeling head. It is made up a SigLIP vision encoder, with a language modeling head on top.
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.)`,ht,ve,qt=`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.`,ft,x,ie,ut,Je,Et='The <a href="/docs/transformers/main/en/model_doc/idefics2#transformers.Idefics2ForConditionalGeneration">Idefics2ForConditionalGeneration</a> forward method, overrides the <code>__call__</code> special method.',_t,q,yt,E,Ye,de,De,C,le,bt,Ue,Vt="Constructs a Idefics image processor.",Tt,V,ce,It,ke,Xt="Preprocess a batch of images.",Qe,me,Oe,k,pe,Mt,ze,Ht="Constructs a IDEFICS2 processor which wraps a LLama tokenizer and IDEFICS2 image processor into a single processor.",wt,je,Lt=`<a href="/docs/transformers/main/en/model_doc/idefics#transformers.IdeficsProcessor">IdeficsProcessor</a> offers all the functionalities of <a href="/docs/transformers/main/en/model_doc/idefics2#transformers.Idefics2ImageProcessor">Idefics2ImageProcessor</a> and <a href="/docs/transformers/main/en/model_doc/llama#transformers.LlamaTokenizerFast">LlamaTokenizerFast</a>. See
the docstring of <a href="/docs/transformers/main/en/model_doc/idefics#transformers.IdeficsProcessor.__call__"><strong>call</strong>()</a> and <code>decode()</code> for more information.`,vt,P,ge,Jt,xe,Yt="Processes the input prompts and returns a BatchEncoding.",Ut,X,Ae,he,Ke,We,et;return T=new fe({props:{title:"Idefics2",local:"idefics2",headingTag:"h1"}}),M=new fe({props:{title:"Overview",local:"overview",headingTag:"h2"}}),A=new ot({props:{code:"aW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwSWRlZmljczJQcm9jZXNzb3IlMkMlMjBJZGVmaWNzMkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQSUwQXVybF8xJTIwJTNEJTIwJTIyaHR0cCUzQSUyRiUyRmltYWdlcy5jb2NvZGF0YXNldC5vcmclMkZ2YWwyMDE3JTJGMDAwMDAwMDM5NzY5LmpwZyUyMiUwQXVybF8yJTIwJTNEJTIwJTIyaHR0cCUzQSUyRiUyRmltYWdlcy5jb2NvZGF0YXNldC5vcmclMkZ2YWwyMDE3JTJGMDAwMDAwMjE5NTc4LmpwZyUyMiUwQSUwQWltYWdlXzElMjAlM0QlMjBJbWFnZS5vcGVuKHJlcXVlc3RzLmdldCh1cmxfMSUyQyUyMHN0cmVhbSUzRFRydWUpLnJhdyklMEFpbWFnZV8yJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQodXJsXzIlMkMlMjBzdHJlYW0lM0RUcnVlKS5yYXcpJTBBaW1hZ2VzJTIwJTNEJTIwJTVCaW1hZ2VfMSUyQyUyMGltYWdlXzIlNUQlMEElMEFtZXNzYWdlcyUyMCUzRCUyMCU1QiU3QiUwQSUyMCUyMCUyMCUyMCUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyY29udGVudCUyMiUzQSUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnR5cGUlMjIlM0ElMjAlMjJ0ZXh0JTIyJTJDJTIwJTIydGV4dCUyMiUzQSUyMCUyMldoYXQlRTIlODAlOTlzJTIwdGhlJTIwZGlmZmVyZW5jZSUyMGJldHdlZW4lMjB0aGVzZSUyMHR3byUyMGltYWdlcyUzRiUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnR5cGUlMjIlM0ElMjAlMjJpbWFnZSUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnR5cGUlMjIlM0ElMjAlMjJpbWFnZSUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCU1RCUyQyUwQSU3RCU1RCUwQSUwQXByb2Nlc3NvciUyMCUzRCUyMElkZWZpY3MyUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJIdWdnaW5nRmFjZU00JTJGaWRlZmljczItOGIlMjIpJTBBbW9kZWwlMjAlM0QlMjBJZGVmaWNzMkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIySHVnZ2luZ0ZhY2VNNCUyRmlkZWZpY3MyLThiJTIyKSUwQSUwQXRleHQlMjAlM0QlMjBwcm9jZXNzb3IuYXBwbHlfY2hhdF90ZW1wbGF0ZShtZXNzYWdlcyklMEElMjMlMjAlMjJVc2VyJTNBJTIwV2hhdCVFMiU4MCU5OXMlMjB0aGUlMjBkaWZmZXJlbmNlJTIwYmV0d2VlbiUyMHRoZXNlJTIwdHdvJTIwaW1hZ2VzJTNGJTNDaW1hZ2UlM0UlM0NpbWFnZSUzRSUzQ2VuZF9vZl91dHRlcmFuY2UlM0UlNUNuJTIyJTBBcHJpbnQodGV4dCklMEElMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IoaW1hZ2VzJTNEaW1hZ2VzJTJDJTIwdGV4dCUzRHRleHQpJTBBJTBBZ2VuZXJhdGVkX3RleHQlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSgqKmlucHV0cyk=",highlighted:`<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Idefics2Processor, Idefics2ForConditionalGeneration

url_1 = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
url_2 = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000219578.jpg&quot;</span>

image_1 = Image.<span class="hljs-built_in">open</span>(requests.get(url_1, stream=<span class="hljs-literal">True</span>).raw)
image_2 = Image.<span class="hljs-built_in">open</span>(requests.get(url_2, stream=<span class="hljs-literal">True</span>).raw)
images = [image_1, image_2]

messages = [{
    <span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>,
    <span class="hljs-string">&quot;content&quot;</span>: [
        {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;What’s the difference between these two images?&quot;</span>},
        {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;image&quot;</span>},
        {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;image&quot;</span>},
    ],
}]

processor = Idefics2Processor.from_pretrained(<span class="hljs-string">&quot;HuggingFaceM4/idefics2-8b&quot;</span>)
model = Idefics2ForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;HuggingFaceM4/idefics2-8b&quot;</span>)

text = processor.apply_chat_template(messages)
<span class="hljs-comment"># &quot;User: What’s the difference between these two images?&lt;image&gt;&lt;image&gt;&lt;end_of_utterance&gt;\\n&quot;</span>
<span class="hljs-built_in">print</span>(text)

inputs = processor(images=images, text=text)

generated_text = model.generate(**inputs)`,wrap:!1}}),ee=new fe({props:{title:"Idefics2Config",local:"transformers.Idefics2Config",headingTag:"h2"}}),te=new G({props:{name:"class transformers.Idefics2Config",anchor:"transformers.Idefics2Config",parameters:[{name:"use_cache",val:" = True"},{name:"image_token_id",val:" = 32001"},{name:"tie_word_embeddings",val:" = False"},{name:"vision_config",val:" = None"},{name:"perceiver_config",val:" = None"},{name:"text_config",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Idefics2Config.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the model should cache the key/value pairs of the attention mechanism.`,name:"use_cache"},{anchor:"transformers.Idefics2Config.image_token_id",description:`<strong>image_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 32001) &#x2014;
The id of the &#x201C;image&#x201D; token.`,name:"image_token_id"},{anchor:"transformers.Idefics2Config.tie_word_embeddings",description:`<strong>tie_word_embeddings</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to tie the word embeddings with the token embeddings.`,name:"tie_word_embeddings"},{anchor:"transformers.Idefics2Config.vision_config",description:`<strong>vision_config</strong> (<code>IdeficsVisionConfig</code> or <code>dict</code>, <em>optional</em>) &#x2014;
Custom vision config or dict`,name:"vision_config"},{anchor:"transformers.Idefics2Config.perceiver_config",description:`<strong>perceiver_config</strong> (<code>IdeficsPerceiverConfig</code> or <code>dict</code>, <em>optional</em>) &#x2014;
Custom perceiver config or dict`,name:"perceiver_config"},{anchor:"transformers.Idefics2Config.text_config",description:`<strong>text_config</strong> (<code>MistralConfig</code> or <code>dict</code>, <em>optional</em>) &#x2014;
Custom text config or dict for the text model`,name:"text_config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/idefics2/configuration_idefics2.py#L179"}}),B=new kt({props:{anchor:"transformers.Idefics2Config.example",$$slots:{default:[oo]},$$scope:{ctx:j}}}),oe=new fe({props:{title:"Idefics2Model",local:"transformers.Idefics2Model",headingTag:"h2"}}),se=new G({props:{name:"class transformers.Idefics2Model",anchor:"transformers.Idefics2Model",parameters:[{name:"config",val:": Idefics2Config"}],parametersDescription:[{anchor:"transformers.Idefics2Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/idefics2#transformers.Idefics2Config">Idefics2Config</a> or <code>Idefics2VisionConfig</code>) &#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/idefics2/modeling_idefics2.py#L1467"}}),ne=new G({props:{name:"forward",anchor:"transformers.Idefics2Model.forward",parameters:[{name:"input_ids",val:": LongTensor = None"},{name:"attention_mask",val:": Optional = None"},{name:"position_ids",val:": Optional = None"},{name:"past_key_values",val:": Optional = None"},{name:"inputs_embeds",val:": Optional = None"},{name:"pixel_values",val:": Optional = None"},{name:"pixel_attention_mask",val:": Optional = None"},{name:"image_hidden_states",val:": Optional = None"},{name:"use_cache",val:": Optional = None"},{name:"output_attentions",val:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"return_dict",val:": Optional = None"}],parametersDescription:[{anchor:"transformers.Idefics2Model.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.Idefics2Model.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.Idefics2Model.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.Idefics2Model.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.Idefics2Model.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.Idefics2Model.forward.pixel_values",description:'<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)) -- The tensors corresponding to the input images. Pixel values can be obtained using [AutoImageProcessor](/docs/transformers/main/en/model_doc/auto#transformers.AutoImageProcessor). See [CLIPImageProcessor.__call__()](/docs/transformers/main/en/model_doc/fuyu#transformers.FuyuImageProcessor.__call__) for details ([]</code>LlavaProcessor`] uses\n<a href="/docs/transformers/main/en/model_doc/clip#transformers.CLIPImageProcessor">CLIPImageProcessor</a> for processing images).',name:"pixel_values"},{anchor:"transformers.Idefics2Model.forward.pixel_attention_mask",description:`<strong>pixel_attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, image_size, image_size)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding pixel indices.`,name:"pixel_attention_mask"},{anchor:"transformers.Idefics2Model.forward.image_hidden_states",description:`<strong>image_hidden_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>) &#x2014;
The hidden states of the image encoder after modality projection and perceiver resampling.`,name:"image_hidden_states"},{anchor:"transformers.Idefics2Model.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.Idefics2Model.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.Idefics2Model.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.Idefics2Model.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/idefics2/modeling_idefics2.py#L1549"}}),S=new Dt({props:{$$slots:{default:[so]},$$scope:{ctx:j}}}),ae=new fe({props:{title:"Idefics2ForConditionalGeneration",local:"transformers.Idefics2ForConditionalGeneration",headingTag:"h2"}}),re=new G({props:{name:"class transformers.Idefics2ForConditionalGeneration",anchor:"transformers.Idefics2ForConditionalGeneration",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.Idefics2ForConditionalGeneration.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/idefics2#transformers.Idefics2Config">Idefics2Config</a> or <code>Idefics2VisionConfig</code>) &#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/idefics2/modeling_idefics2.py#L1687"}}),ie=new G({props:{name:"forward",anchor:"transformers.Idefics2ForConditionalGeneration.forward",parameters:[{name:"input_ids",val:": LongTensor = None"},{name:"attention_mask",val:": Optional = None"},{name:"position_ids",val:": Optional = None"},{name:"past_key_values",val:": Optional = None"},{name:"inputs_embeds",val:": Optional = None"},{name:"pixel_values",val:": Optional = None"},{name:"pixel_attention_mask",val:": Optional = None"},{name:"image_hidden_states",val:": Optional = None"},{name:"labels",val:": Optional = None"},{name:"use_cache",val:": Optional = None"},{name:"output_attentions",val:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"return_dict",val:": Optional = None"}],parametersDescription:[{anchor:"transformers.Idefics2ForConditionalGeneration.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.Idefics2ForConditionalGeneration.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.Idefics2ForConditionalGeneration.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.Idefics2ForConditionalGeneration.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.Idefics2ForConditionalGeneration.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.Idefics2ForConditionalGeneration.forward.pixel_values",description:'<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)) -- The tensors corresponding to the input images. Pixel values can be obtained using [AutoImageProcessor](/docs/transformers/main/en/model_doc/auto#transformers.AutoImageProcessor). See [CLIPImageProcessor.__call__()](/docs/transformers/main/en/model_doc/fuyu#transformers.FuyuImageProcessor.__call__) for details ([]</code>LlavaProcessor`] uses\n<a href="/docs/transformers/main/en/model_doc/clip#transformers.CLIPImageProcessor">CLIPImageProcessor</a> for processing images).',name:"pixel_values"},{anchor:"transformers.Idefics2ForConditionalGeneration.forward.pixel_attention_mask",description:`<strong>pixel_attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, image_size, image_size)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding pixel indices.`,name:"pixel_attention_mask"},{anchor:"transformers.Idefics2ForConditionalGeneration.forward.image_hidden_states",description:`<strong>image_hidden_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>) &#x2014;
The hidden states of the image encoder after modality projection and perceiver resampling.`,name:"image_hidden_states"},{anchor:"transformers.Idefics2ForConditionalGeneration.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.Idefics2ForConditionalGeneration.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.Idefics2ForConditionalGeneration.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.Idefics2ForConditionalGeneration.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.</p>
<p>Args &#x2014;
labels (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>):
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:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/idefics2/modeling_idefics2.py#L1757",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <code>transformers.models.idefics2.modeling_idefics2.Idefics2CausalLMOutputWithPast</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/idefics2#transformers.Idefics2Config"
>Idefics2Config</a>) and inputs.</p>
<ul>
<li><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).</li>
<li><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).</li>
<li><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>)
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.</li>
<li><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>.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</li>
<li><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>.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</li>
<li><strong>image_hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the image embeddings, <code>(batch_size, num_images, sequence_length, hidden_size)</code>.
image_hidden_states of the model produced by the vision encoder, and optionally by the perceiver</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.models.idefics2.modeling_idefics2.Idefics2CausalLMOutputWithPast</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),q=new Dt({props:{$$slots:{default:[no]},$$scope:{ctx:j}}}),E=new kt({props:{anchor:"transformers.Idefics2ForConditionalGeneration.forward.example",$$slots:{default:[ao]},$$scope:{ctx:j}}}),de=new fe({props:{title:"Idefics2ImageProcessor",local:"transformers.Idefics2ImageProcessor",headingTag:"h2"}}),le=new G({props:{name:"class transformers.Idefics2ImageProcessor",anchor:"transformers.Idefics2ImageProcessor",parameters:[{name:"do_convert_rgb",val:": bool = True"},{name:"do_resize",val:": bool = True"},{name:"size",val:": Dict = None"},{name:"resample",val:": Resampling = <Resampling.BILINEAR: 2>"},{name:"do_rescale",val:": bool = True"},{name:"rescale_factor",val:": float = 0.00392156862745098"},{name:"do_normalize",val:": bool = True"},{name:"image_mean",val:": Union = None"},{name:"image_std",val:": Union = None"},{name:"do_pad",val:": bool = True"},{name:"do_image_splitting",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Idefics2ImageProcessor.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. This is useful if the input image is of a different format e.g. RGBA.
Only has an effect if the input image is in the PIL format.`,name:"do_convert_rgb"},{anchor:"transformers.Idefics2ImageProcessor.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to resize the image. The longest edge of the image is resized to  be &lt;= <code>size[&quot;longest_edge&quot;]</code>, with the
shortest edge resized to keep the input aspect ratio, with a minimum size of <code>size[&quot;shortest_edge&quot;]</code>.`,name:"do_resize"},{anchor:"transformers.Idefics2ImageProcessor.size",description:`<strong>size</strong> (<code>Dict</code>, <em>optional</em>) &#x2014;
Controls the size of the output image. This is a dictionary containing the keys &#x201C;shortest_edge&#x201D; and &#x201C;longest_edge&#x201D;.`,name:"size"},{anchor:"transformers.Idefics2ImageProcessor.resample",description:`<strong>resample</strong> (<code>Resampling</code>, <em>optional</em>, defaults to <code>Resampling.BILINEAR</code>) &#x2014;
Resampling filter to use when resizing the image.`,name:"resample"},{anchor:"transformers.Idefics2ImageProcessor.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to rescale the image. If set to <code>True</code>, the image is rescaled to have pixel values between 0 and 1.`,name:"do_rescale"},{anchor:"transformers.Idefics2ImageProcessor.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1/255</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.Idefics2ImageProcessor.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to normalize the image. If set to <code>True</code>, the image is normalized to have a mean of <code>image_mean</code> and
a standard deviation of <code>image_std</code>.`,name:"do_normalize"},{anchor:"transformers.Idefics2ImageProcessor.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IDEFICS_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.Idefics2ImageProcessor.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IDEFICS_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.Idefics2ImageProcessor.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to pad the images to the largest height and width in the batch and number of images per
sample in the batch, such that the returned tensor is of shape (batch_size, max_num_images, num_channels, max_height, max_width).`,name:"do_pad"},{anchor:"transformers.Idefics2ImageProcessor.do_image_splitting",description:`<strong>do_image_splitting</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to split the image into a sequence 4 equal sub-images concatenated with the original image. That
strategy was first introduced in <a href="https://arxiv.org/abs/2311.06607" rel="nofollow">https://arxiv.org/abs/2311.06607</a>.`,name:"do_image_splitting"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/idefics2/image_processing_idefics2.py#L181"}}),ce=new G({props:{name:"preprocess",anchor:"transformers.Idefics2ImageProcessor.preprocess",parameters:[{name:"images",val:": Union"},{name:"do_convert_rgb",val:": Optional = None"},{name:"do_resize",val:": Optional = None"},{name:"size",val:": Optional = None"},{name:"resample",val:": Resampling = None"},{name:"do_rescale",val:": Optional = None"},{name:"rescale_factor",val:": Optional = None"},{name:"do_normalize",val:": Optional = None"},{name:"image_mean",val:": Union = None"},{name:"image_std",val:": Union = None"},{name:"do_pad",val:": Optional = None"},{name:"do_image_splitting",val:": Optional = None"},{name:"return_tensors",val:": Union = None"},{name:"input_data_format",val:": Optional = None"},{name:"data_format",val:": Optional = <ChannelDimension.FIRST: 'channels_first'>"}],parametersDescription:[{anchor:"transformers.Idefics2ImageProcessor.preprocess.images",description:`<strong>images</strong> (<code>ImageInput</code>) &#x2014;
A list of images to preprocess.`,name:"images"},{anchor:"transformers.Idefics2ImageProcessor.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.Idefics2ImageProcessor.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.Idefics2ImageProcessor.preprocess.size",description:`<strong>size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>self.size</code>) &#x2014;
Size of the image after resizing. Shortest edge of the image is resized to size[&#x201C;shortest_edge&#x201D;], with
the longest edge resized to keep the input aspect ratio.`,name:"size"},{anchor:"transformers.Idefics2ImageProcessor.preprocess.resample",description:`<strong>resample</strong> (<code>int</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.Idefics2ImageProcessor.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.Idefics2ImageProcessor.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.Idefics2ImageProcessor.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.Idefics2ImageProcessor.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.Idefics2ImageProcessor.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.Idefics2ImageProcessor.preprocess.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_pad</code>) &#x2014;
Whether or not to pad the images to the largest height and width in the batch.`,name:"do_pad"},{anchor:"transformers.Idefics2ImageProcessor.preprocess.do_image_splitting",description:`<strong>do_image_splitting</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_image_splitting</code>) &#x2014;
Whether to split the image into a sequence 4 equal sub-images concatenated with the original image. That
strategy was first introduced in <a href="https://arxiv.org/abs/2311.06607" rel="nofollow">https://arxiv.org/abs/2311.06607</a>.`,name:"do_image_splitting"},{anchor:"transformers.Idefics2ImageProcessor.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.Idefics2ImageProcessor.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.Idefics2ImageProcessor.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/idefics2/image_processing_idefics2.py#L425"}}),me=new fe({props:{title:"Idefics2Processor",local:"transformers.Idefics2Processor",headingTag:"h2"}}),pe=new G({props:{name:"class transformers.Idefics2Processor",anchor:"transformers.Idefics2Processor",parameters:[{name:"image_processor",val:""},{name:"tokenizer",val:" = None"},{name:"image_seq_len",val:": int = 64"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Idefics2Processor.image_processor",description:`<strong>image_processor</strong> (<code>Idefics2ImageProcessor</code>) &#x2014;
An instance of <a href="/docs/transformers/main/en/model_doc/idefics2#transformers.Idefics2ImageProcessor">Idefics2ImageProcessor</a>. The image processor is a required input.`,name:"image_processor"},{anchor:"transformers.Idefics2Processor.tokenizer",description:`<strong>tokenizer</strong> (<code>PreTrainedTokenizerBase</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase">PreTrainedTokenizerBase</a>. This should correspond with the model&#x2019;s text model. The tokenizer is a required input.`,name:"tokenizer"},{anchor:"transformers.Idefics2Processor.image_seq_len",description:`<strong>image_seq_len</strong> (<code>int</code>, <em>optional</em>, defaults to 64) &#x2014;
The length of the image sequence i.e. the number of <image> tokens per image in the input.
This parameter is used to build the string from the input prompt and image tokens and should match the
config.perceiver_config.resampler_n_latents value for the model used.</image>`,name:"image_seq_len"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/idefics2/processing_idefics2.py#L44"}}),ge=new G({props:{name:"__call__",anchor:"transformers.Idefics2Processor.__call__",parameters:[{name:"text",val:": Union = None"},{name:"images",val:": Union = None"},{name:"image_seq_len",val:": Optional = None"},{name:"padding",val:": Union = False"},{name:"truncation",val:": Union = None"},{name:"max_length",val:": Optional = None"},{name:"is_split_into_words",val:": bool = False"},{name:"add_special_tokens",val:": bool = True"},{name:"return_tensors",val:": Union = None"}],parametersDescription:[{anchor:"transformers.Idefics2Processor.__call__.text",description:`<strong>text</strong> (<code>Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]]</code>, <em>optional</em>) &#x2014;
The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
(pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
<code>is_split_into_words=True</code> (to lift the ambiguity with a batch of sequences).</p>
<p>Wherever an image token, <code>&lt;image&gt;</code> is encountered it is expanded to
<code>&lt;fake_token_around_image&gt;</code> + <code>&lt;image&gt;</code> <em> <code>image_seq_len</code> </em> <fake_token_around_image>\`.</fake_token_around_image>`,name:"text"},{anchor:"transformers.Idefics2Processor.__call__.images",description:`<strong>images</strong> (<code>PIL.Image.Image</code>, <code>np.ndarray</code>, <code>torch.Tensor</code>, <code>List[PIL.Image.Image]</code>, <code>List[np.ndarray]</code>, <code>List[torch.Tensor]</code>, <em>optional</em>) &#x2014;
The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
tensor. If is of type <code>List[ImageInput]</code>, it&#x2019;s assumed that this is for a single prompt i.e. of batch size 1.`,name:"images"},{anchor:"transformers.Idefics2Processor.__call__.image_seq_len",description:`<strong>image_seq_len</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The length of the image sequence. If not provided, the default value is used.`,name:"image_seq_len"},{anchor:"transformers.Idefics2Processor.__call__.padding",description:`<strong>padding</strong> (<code>Union[bool, str, PaddingStrategy]</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Padding strategy applied to the input ids. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.pad">PreTrainedTokenizerFast.pad()</a> for more information.`,name:"padding"},{anchor:"transformers.Idefics2Processor.__call__.truncation",description:`<strong>truncation</strong> (<code>Union[bool, str, TruncationStrategy]</code>, <em>optional</em>) &#x2014;
Truncation strategy applied to the input ids. See <code>PreTrainedTokenizerFast.truncate</code> for more information.`,name:"truncation"},{anchor:"transformers.Idefics2Processor.__call__.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Maximum length of the returned list and optionally padding/truncation length. See
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizerFast.<strong>call</strong>()</a> for more information.`,name:"max_length"},{anchor:"transformers.Idefics2Processor.__call__.is_split_into_words",description:`<strong>is_split_into_words</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether the input text is split into words or not. If set to <code>True</code>, the tokenizer will skip the
tokenization process and assume the input is already tokenized.`,name:"is_split_into_words"},{anchor:"transformers.Idefics2Processor.__call__.add_special_tokens",description:`<strong>add_special_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to add special tokens or not. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizerFast.<strong>call</strong>()</a> for more information.`,name:"add_special_tokens"},{anchor:"transformers.Idefics2Processor.__call__.return_tensors",description:`<strong>return_tensors</strong> (<code>Union[str, TensorType]</code>, <em>optional</em>) &#x2014;
If set, will return tensors of a particular framework. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizerFast.<strong>call</strong>()</a> for more
information.`,name:"return_tensors"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/idefics2/processing_idefics2.py#L99"}}),X=new kt({props:{anchor:"transformers.Idefics2Processor.__call__.example",$$slots:{default:[ro]},$$scope:{ctx:j}}}),he=new to({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/idefics2.md"}}),{c(){s=l("meta"),I=a(),m=l("p"),p=a(),g(T.$$.fragment),n=a(),g(M.$$.fragment),Fe=a(),L=l("p"),L.innerHTML=zt,Re=a(),Y=l("p"),Y.textContent=jt,Ne=a(),D=l("p"),D.textContent=xt,Pe=a(),Q=l("ul"),Q.innerHTML=Ct,Ge=a(),O=l("p"),O.textContent=$t,Be=a(),g(A.$$.fragment),Se=a(),K=l("p"),K.innerHTML=Wt,qe=a(),g(ee.$$.fragment),Ee=a(),v=l("div"),g(te.$$.fragment),st=a(),ue=l("p"),ue.innerHTML=Zt,nt=a(),_e=l("p"),_e.innerHTML=Ft,at=a(),g(B.$$.fragment),Ve=a(),g(oe.$$.fragment),Xe=a(),J=l("div"),g(se.$$.fragment),rt=a(),ye=l("p"),ye.innerHTML=Rt,it=a(),be=l("p"),be.innerHTML=Nt,dt=a(),w=l("div"),g(ne.$$.fragment),lt=a(),Te=l("p"),Te.innerHTML=Pt,ct=a(),g(S.$$.fragment),mt=a(),Ie=l("p"),Ie.textContent=Gt,pt=a(),Me=l("p"),Me.textContent=Bt,He=a(),g(ae.$$.fragment),Le=a(),U=l("div"),g(re.$$.fragment),gt=a(),we=l("p"),we.innerHTML=St,ht=a(),ve=l("p"),ve.innerHTML=qt,ft=a(),x=l("div"),g(ie.$$.fragment),ut=a(),Je=l("p"),Je.innerHTML=Et,_t=a(),g(q.$$.fragment),yt=a(),g(E.$$.fragment),Ye=a(),g(de.$$.fragment),De=a(),C=l("div"),g(le.$$.fragment),bt=a(),Ue=l("p"),Ue.textContent=Vt,Tt=a(),V=l("div"),g(ce.$$.fragment),It=a(),ke=l("p"),ke.textContent=Xt,Qe=a(),g(me.$$.fragment),Oe=a(),k=l("div"),g(pe.$$.fragment),Mt=a(),ze=l("p"),ze.textContent=Ht,wt=a(),je=l("p"),je.innerHTML=Lt,vt=a(),P=l("div"),g(ge.$$.fragment),Jt=a(),xe=l("p"),xe.textContent=Yt,Ut=a(),g(X.$$.fragment),Ae=a(),g(he.$$.fragment),Ke=a(),We=l("p"),this.h()},l(e){const t=eo("svelte-u9bgzb",document.head);s=c(t,"META",{name:!0,content:!0}),t.forEach(o),I=r(e),m=c(e,"P",{}),R(m).forEach(o),p=r(e),h(T.$$.fragment,e),n=r(e),h(M.$$.fragment,e),Fe=r(e),L=c(e,"P",{"data-svelte-h":!0}),b(L)!=="svelte-lbk984"&&(L.innerHTML=zt),Re=r(e),Y=c(e,"P",{"data-svelte-h":!0}),b(Y)!=="svelte-5h9xv8"&&(Y.textContent=jt),Ne=r(e),D=c(e,"P",{"data-svelte-h":!0}),b(D)!=="svelte-axv494"&&(D.textContent=xt),Pe=r(e),Q=c(e,"UL",{"data-svelte-h":!0}),b(Q)!=="svelte-ejgnpl"&&(Q.innerHTML=Ct),Ge=r(e),O=c(e,"P",{"data-svelte-h":!0}),b(O)!=="svelte-hckg3t"&&(O.textContent=$t),Be=r(e),h(A.$$.fragment,e),Se=r(e),K=c(e,"P",{"data-svelte-h":!0}),b(K)!=="svelte-yuhhqz"&&(K.innerHTML=Wt),qe=r(e),h(ee.$$.fragment,e),Ee=r(e),v=c(e,"DIV",{class:!0});var $=R(v);h(te.$$.fragment,$),st=r($),ue=c($,"P",{"data-svelte-h":!0}),b(ue)!=="svelte-1ngts0f"&&(ue.innerHTML=Zt),nt=r($),_e=c($,"P",{"data-svelte-h":!0}),b(_e)!=="svelte-o55m63"&&(_e.innerHTML=Ft),at=r($),h(B.$$.fragment,$),$.forEach(o),Ve=r(e),h(oe.$$.fragment,e),Xe=r(e),J=c(e,"DIV",{class:!0});var W=R(J);h(se.$$.fragment,W),rt=r(W),ye=c(W,"P",{"data-svelte-h":!0}),b(ye)!=="svelte-1ybhnwc"&&(ye.innerHTML=Rt),it=r(W),be=c(W,"P",{"data-svelte-h":!0}),b(be)!=="svelte-hswkmf"&&(be.innerHTML=Nt),dt=r(W),w=c(W,"DIV",{class:!0});var z=R(w);h(ne.$$.fragment,z),lt=r(z),Te=c(z,"P",{"data-svelte-h":!0}),b(Te)!=="svelte-1ljsomm"&&(Te.innerHTML=Pt),ct=r(z),h(S.$$.fragment,z),mt=r(z),Ie=c(z,"P",{"data-svelte-h":!0}),b(Ie)!=="svelte-felb7u"&&(Ie.textContent=Gt),pt=r(z),Me=c(z,"P",{"data-svelte-h":!0}),b(Me)!=="svelte-58ee4k"&&(Me.textContent=Bt),z.forEach(o),W.forEach(o),He=r(e),h(ae.$$.fragment,e),Le=r(e),U=c(e,"DIV",{class:!0});var Z=R(U);h(re.$$.fragment,Z),gt=r(Z),we=c(Z,"P",{"data-svelte-h":!0}),b(we)!=="svelte-hgurjl"&&(we.innerHTML=St),ht=r(Z),ve=c(Z,"P",{"data-svelte-h":!0}),b(ve)!=="svelte-hswkmf"&&(ve.innerHTML=qt),ft=r(Z),x=c(Z,"DIV",{class:!0});var F=R(x);h(ie.$$.fragment,F),ut=r(F),Je=c(F,"P",{"data-svelte-h":!0}),b(Je)!=="svelte-sq5c5e"&&(Je.innerHTML=Et),_t=r(F),h(q.$$.fragment,F),yt=r(F),h(E.$$.fragment,F),F.forEach(o),Z.forEach(o),Ye=r(e),h(de.$$.fragment,e),De=r(e),C=c(e,"DIV",{class:!0});var Ce=R(C);h(le.$$.fragment,Ce),bt=r(Ce),Ue=c(Ce,"P",{"data-svelte-h":!0}),b(Ue)!=="svelte-1m1ucrf"&&(Ue.textContent=Vt),Tt=r(Ce),V=c(Ce,"DIV",{class:!0});var tt=R(V);h(ce.$$.fragment,tt),It=r(tt),ke=c(tt,"P",{"data-svelte-h":!0}),b(ke)!=="svelte-1xds4wy"&&(ke.textContent=Xt),tt.forEach(o),Ce.forEach(o),Qe=r(e),h(me.$$.fragment,e),Oe=r(e),k=c(e,"DIV",{class:!0});var H=R(k);h(pe.$$.fragment,H),Mt=r(H),ze=c(H,"P",{"data-svelte-h":!0}),b(ze)!=="svelte-1jys543"&&(ze.textContent=Ht),wt=r(H),je=c(H,"P",{"data-svelte-h":!0}),b(je)!=="svelte-1efqgl8"&&(je.innerHTML=Lt),vt=r(H),P=c(H,"DIV",{class:!0});var $e=R(P);h(ge.$$.fragment,$e),Jt=r($e),xe=c($e,"P",{"data-svelte-h":!0}),b(xe)!=="svelte-421t2f"&&(xe.textContent=Yt),Ut=r($e),h(X.$$.fragment,$e),$e.forEach(o),H.forEach(o),Ae=r(e),h(he.$$.fragment,e),Ke=r(e),We=c(e,"P",{}),R(We).forEach(o),this.h()},h(){N(s,"name","hf:doc:metadata"),N(s,"content",lo),N(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(k,"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){i(document.head,s),d(e,I,t),d(e,m,t),d(e,p,t),f(T,e,t),d(e,n,t),f(M,e,t),d(e,Fe,t),d(e,L,t),d(e,Re,t),d(e,Y,t),d(e,Ne,t),d(e,D,t),d(e,Pe,t),d(e,Q,t),d(e,Ge,t),d(e,O,t),d(e,Be,t),f(A,e,t),d(e,Se,t),d(e,K,t),d(e,qe,t),f(ee,e,t),d(e,Ee,t),d(e,v,t),f(te,v,null),i(v,st),i(v,ue),i(v,nt),i(v,_e),i(v,at),f(B,v,null),d(e,Ve,t),f(oe,e,t),d(e,Xe,t),d(e,J,t),f(se,J,null),i(J,rt),i(J,ye),i(J,it),i(J,be),i(J,dt),i(J,w),f(ne,w,null),i(w,lt),i(w,Te),i(w,ct),f(S,w,null),i(w,mt),i(w,Ie),i(w,pt),i(w,Me),d(e,He,t),f(ae,e,t),d(e,Le,t),d(e,U,t),f(re,U,null),i(U,gt),i(U,we),i(U,ht),i(U,ve),i(U,ft),i(U,x),f(ie,x,null),i(x,ut),i(x,Je),i(x,_t),f(q,x,null),i(x,yt),f(E,x,null),d(e,Ye,t),f(de,e,t),d(e,De,t),d(e,C,t),f(le,C,null),i(C,bt),i(C,Ue),i(C,Tt),i(C,V),f(ce,V,null),i(V,It),i(V,ke),d(e,Qe,t),f(me,e,t),d(e,Oe,t),d(e,k,t),f(pe,k,null),i(k,Mt),i(k,ze),i(k,wt),i(k,je),i(k,vt),i(k,P),f(ge,P,null),i(P,Jt),i(P,xe),i(P,Ut),f(X,P,null),d(e,Ae,t),f(he,e,t),d(e,Ke,t),d(e,We,t),et=!0},p(e,[t]){const $={};t&2&&($.$$scope={dirty:t,ctx:e}),B.$set($);const W={};t&2&&(W.$$scope={dirty:t,ctx:e}),S.$set(W);const z={};t&2&&(z.$$scope={dirty:t,ctx:e}),q.$set(z);const Z={};t&2&&(Z.$$scope={dirty:t,ctx:e}),E.$set(Z);const F={};t&2&&(F.$$scope={dirty:t,ctx:e}),X.$set(F)},i(e){et||(u(T.$$.fragment,e),u(M.$$.fragment,e),u(A.$$.fragment,e),u(ee.$$.fragment,e),u(te.$$.fragment,e),u(B.$$.fragment,e),u(oe.$$.fragment,e),u(se.$$.fragment,e),u(ne.$$.fragment,e),u(S.$$.fragment,e),u(ae.$$.fragment,e),u(re.$$.fragment,e),u(ie.$$.fragment,e),u(q.$$.fragment,e),u(E.$$.fragment,e),u(de.$$.fragment,e),u(le.$$.fragment,e),u(ce.$$.fragment,e),u(me.$$.fragment,e),u(pe.$$.fragment,e),u(ge.$$.fragment,e),u(X.$$.fragment,e),u(he.$$.fragment,e),et=!0)},o(e){_(T.$$.fragment,e),_(M.$$.fragment,e),_(A.$$.fragment,e),_(ee.$$.fragment,e),_(te.$$.fragment,e),_(B.$$.fragment,e),_(oe.$$.fragment,e),_(se.$$.fragment,e),_(ne.$$.fragment,e),_(S.$$.fragment,e),_(ae.$$.fragment,e),_(re.$$.fragment,e),_(ie.$$.fragment,e),_(q.$$.fragment,e),_(E.$$.fragment,e),_(de.$$.fragment,e),_(le.$$.fragment,e),_(ce.$$.fragment,e),_(me.$$.fragment,e),_(pe.$$.fragment,e),_(ge.$$.fragment,e),_(X.$$.fragment,e),_(he.$$.fragment,e),et=!1},d(e){e&&(o(I),o(m),o(p),o(n),o(Fe),o(L),o(Re),o(Y),o(Ne),o(D),o(Pe),o(Q),o(Ge),o(O),o(Be),o(Se),o(K),o(qe),o(Ee),o(v),o(Ve),o(Xe),o(J),o(He),o(Le),o(U),o(Ye),o(De),o(C),o(Qe),o(Oe),o(k),o(Ae),o(Ke),o(We)),o(s),y(T,e),y(M,e),y(A,e),y(ee,e),y(te),y(B),y(oe,e),y(se),y(ne),y(S),y(ae,e),y(re),y(ie),y(q),y(E),y(de,e),y(le),y(ce),y(me,e),y(pe),y(ge),y(X),y(he,e)}}}const lo='{"title":"Idefics2","local":"idefics2","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Idefics2Config","local":"transformers.Idefics2Config","sections":[],"depth":2},{"title":"Idefics2Model","local":"transformers.Idefics2Model","sections":[],"depth":2},{"title":"Idefics2ForConditionalGeneration","local":"transformers.Idefics2ForConditionalGeneration","sections":[],"depth":2},{"title":"Idefics2ImageProcessor","local":"transformers.Idefics2ImageProcessor","sections":[],"depth":2},{"title":"Idefics2Processor","local":"transformers.Idefics2Processor","sections":[],"depth":2}],"depth":1}';function co(j){return Ot(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class yo extends At{constructor(s){super(),Kt(this,s,co,io,Qt,{})}}export{yo as component};
