import{S as wm,i as Tm,s as Bm,e as a,k as m,w as y,t as n,M as $m,c as s,d as o,m as f,a as l,x as M,h as r,b as c,N as km,G as e,g as _,y as w,q as T,o as B,B as $,v as jm,L as Ee}from"../../chunks/vendor-hf-doc-builder.js";import{T as hn}from"../../chunks/Tip-hf-doc-builder.js";import{D as Z}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Ce}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as O}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Je}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Jm(j){let d,v,g,h,b;return h=new Ce({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMCglMEElMjAlMjAlMjAlMjBCbGlwMlZpc2lvbkNvbmZpZyUyQyUwQSUyMCUyMCUyMCUyMEJsaXAyUUZvcm1lckNvbmZpZyUyQyUwQSUyMCUyMCUyMCUyME9QVENvbmZpZyUyQyUwQSUyMCUyMCUyMCUyMEJsaXAyQ29uZmlnJTJDJTBBJTIwJTIwJTIwJTIwQmxpcDJGb3JDb25kaXRpb25hbEdlbmVyYXRpb24lMkMlMEEpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMEJsaXAyQ29uZmlnJTIwd2l0aCUyMFNhbGVzZm9yY2UlMkZibGlwMi1vcHQtMi43YiUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBCbGlwMkNvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMEJsaXAyRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUyMGZyb20lMjB0aGUlMjBTYWxlc2ZvcmNlJTJGYmxpcDItb3B0LTIuN2IlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFtb2RlbCUyMCUzRCUyMEJsaXAyRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uKGNvbmZpZ3VyYXRpb24pJTBBJTBBJTIzJTIwQWNjZXNzaW5nJTIwdGhlJTIwbW9kZWwlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMG1vZGVsLmNvbmZpZyUwQSUwQSUyMyUyMFdlJTIwY2FuJTIwYWxzbyUyMGluaXRpYWxpemUlMjBhJTIwQmxpcDJDb25maWclMjBmcm9tJTIwYSUyMEJsaXAyVmlzaW9uQ29uZmlnJTJDJTIwQmxpcDJRRm9ybWVyQ29uZmlnJTIwYW5kJTIwYW55JTIwUHJldHJhaW5lZENvbmZpZyUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMEJMSVAtMiUyMHZpc2lvbiUyQyUyMEJMSVAtMiUyMFEtRm9ybWVyJTIwYW5kJTIwbGFuZ3VhZ2UlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb25zJTBBdmlzaW9uX2NvbmZpZyUyMCUzRCUyMEJsaXAyVmlzaW9uQ29uZmlnKCklMEFxZm9ybWVyX2NvbmZpZyUyMCUzRCUyMEJsaXAyUUZvcm1lckNvbmZpZygpJTBBdGV4dF9jb25maWclMjAlM0QlMjBPUFRDb25maWcoKSUwQSUwQWNvbmZpZyUyMCUzRCUyMEJsaXAyQ29uZmlnLmZyb21fdGV4dF92aXNpb25fY29uZmlncyh2aXNpb25fY29uZmlnJTJDJTIwcWZvcm1lcl9jb25maWclMkMlMjB0ZXh0X2NvbmZpZyk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> (
<span class="hljs-meta">... </span>    Blip2VisionConfig,
<span class="hljs-meta">... </span>    Blip2QFormerConfig,
<span class="hljs-meta">... </span>    OPTConfig,
<span class="hljs-meta">... </span>    Blip2Config,
<span class="hljs-meta">... </span>    Blip2ForConditionalGeneration,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Blip2Config with Salesforce/blip2-opt-2.7b style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = Blip2Config()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Blip2ForConditionalGeneration (with random weights) from the Salesforce/blip2-opt-2.7b style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Blip2ForConditionalGeneration(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

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># We can also initialize a Blip2Config from a Blip2VisionConfig, Blip2QFormerConfig and any PretrainedConfig</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing BLIP-2 vision, BLIP-2 Q-Former and language model configurations</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>vision_config = Blip2VisionConfig()
<span class="hljs-meta">&gt;&gt;&gt; </span>qformer_config = Blip2QFormerConfig()
<span class="hljs-meta">&gt;&gt;&gt; </span>text_config = OPTConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span>config = Blip2Config.from_text_vision_configs(vision_config, qformer_config, text_config)`}}),{c(){d=a("p"),v=n("Example:"),g=m(),y(h.$$.fragment)},l(i){d=s(i,"P",{});var p=l(d);v=r(p,"Example:"),p.forEach(o),g=f(i),M(h.$$.fragment,i)},m(i,p){_(i,d,p),e(d,v),_(i,g,p),w(h,i,p),b=!0},p:Ee,i(i){b||(T(h.$$.fragment,i),b=!0)},o(i){B(h.$$.fragment,i),b=!1},d(i){i&&o(d),i&&o(g),$(h,i)}}}function Em(j){let d,v,g,h,b;return h=new Ce({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJsaXAyVmlzaW9uQ29uZmlnJTJDJTIwQmxpcDJWaXNpb25Nb2RlbCUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBCbGlwMlZpc2lvbkNvbmZpZyUyMHdpdGglMjBTYWxlc2ZvcmNlJTJGYmxpcDItb3B0LTIuN2IlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwQmxpcDJWaXNpb25Db25maWcoKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBCbGlwMlZpc2lvbk1vZGVsJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUyMGZyb20lMjB0aGUlMjBTYWxlc2ZvcmNlJTJGYmxpcDItb3B0LTIuN2IlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFtb2RlbCUyMCUzRCUyMEJsaXAyVmlzaW9uTW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Blip2VisionConfig, Blip2VisionModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Blip2VisionConfig with Salesforce/blip2-opt-2.7b style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = Blip2VisionConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Blip2VisionModel (with random weights) from the Salesforce/blip2-opt-2.7b style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Blip2VisionModel(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`}}),{c(){d=a("p"),v=n("Example:"),g=m(),y(h.$$.fragment)},l(i){d=s(i,"P",{});var p=l(d);v=r(p,"Example:"),p.forEach(o),g=f(i),M(h.$$.fragment,i)},m(i,p){_(i,d,p),e(d,v),_(i,g,p),w(h,i,p),b=!0},p:Ee,i(i){b||(T(h.$$.fragment,i),b=!0)},o(i){B(h.$$.fragment,i),b=!1},d(i){i&&o(d),i&&o(g),$(h,i)}}}function Cm(j){let d,v,g,h,b;return h=new Ce({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJsaXAyUUZvcm1lckNvbmZpZyUyQyUyMEJsaXAyUUZvcm1lck1vZGVsJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMEJMSVAtMiUyMFNhbGVzZm9yY2UlMkZibGlwMi1vcHQtMi43YiUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBCbGlwMlFGb3JtZXJDb25maWcoKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBtb2RlbCUyMCh3aXRoJTIwcmFuZG9tJTIwd2VpZ2h0cyklMjBmcm9tJTIwdGhlJTIwU2FsZXNmb3JjZSUyRmJsaXAyLW9wdC0yLjdiJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBCbGlwMlFGb3JtZXJNb2RlbChjb25maWd1cmF0aW9uKSUwQSUyMyUyMEFjY2Vzc2luZyUyMHRoZSUyMG1vZGVsJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBtb2RlbC5jb25maWc=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Blip2QFormerConfig, Blip2QFormerModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a BLIP-2 Salesforce/blip2-opt-2.7b style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = Blip2QFormerConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the Salesforce/blip2-opt-2.7b style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Blip2QFormerModel(configuration)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`}}),{c(){d=a("p"),v=n("Examples:"),g=m(),y(h.$$.fragment)},l(i){d=s(i,"P",{});var p=l(d);v=r(p,"Examples:"),p.forEach(o),g=f(i),M(h.$$.fragment,i)},m(i,p){_(i,d,p),e(d,v),_(i,g,p),w(h,i,p),b=!0},p:Ee,i(i){b||(T(h.$$.fragment,i),b=!0)},o(i){B(h.$$.fragment,i),b=!1},d(i){i&&o(d),i&&o(g),$(h,i)}}}function Um(j){let d,v,g,h,b;return{c(){d=a("p"),v=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=a("code"),h=n("Module"),b=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(i){d=s(i,"P",{});var p=l(d);v=r(p,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=s(p,"CODE",{});var E=l(g);h=r(E,"Module"),E.forEach(o),b=r(p,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),p.forEach(o)},m(i,p){_(i,d,p),e(d,v),e(d,g),e(g,h),e(d,b)},d(i){i&&o(d)}}}function Im(j){let d,v,g,h,b;return{c(){d=a("p"),v=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=a("code"),h=n("Module"),b=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(i){d=s(i,"P",{});var p=l(d);v=r(p,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=s(p,"CODE",{});var E=l(g);h=r(E,"Module"),E.forEach(o),b=r(p,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),p.forEach(o)},m(i,p){_(i,d,p),e(d,v),e(d,g),e(g,h),e(d,b)},d(i){i&&o(d)}}}function Zm(j){let d,v,g,h,b;return h=new Ce({props:{code:"ZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQmxpcDJQcm9jZXNzb3IlMkMlMjBCbGlwMk1vZGVsJTBBaW1wb3J0JTIwdG9yY2glMEElMEFkZXZpY2UlMjAlM0QlMjAlMjJjdWRhJTIyJTIwaWYlMjB0b3JjaC5jdWRhLmlzX2F2YWlsYWJsZSgpJTIwZWxzZSUyMCUyMmNwdSUyMiUwQSUwQXByb2Nlc3NvciUyMCUzRCUyMEJsaXAyUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJTYWxlc2ZvcmNlJTJGYmxpcDItb3B0LTIuN2IlMjIpJTBBbW9kZWwlMjAlM0QlMjBCbGlwMk1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJTYWxlc2ZvcmNlJTJGYmxpcDItb3B0LTIuN2IlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBbW9kZWwudG8oZGV2aWNlKSUwQXVybCUyMCUzRCUyMCUyMmh0dHAlM0ElMkYlMkZpbWFnZXMuY29jb2RhdGFzZXQub3JnJTJGdmFsMjAxNyUyRjAwMDAwMDAzOTc2OS5qcGclMjIlMEFpbWFnZSUyMCUzRCUyMEltYWdlLm9wZW4ocmVxdWVzdHMuZ2V0KHVybCUyQyUyMHN0cmVhbSUzRFRydWUpLnJhdyklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJRdWVzdGlvbiUzQSUyMGhvdyUyMG1hbnklMjBjYXRzJTIwYXJlJTIwdGhlcmUlM0YlMjBBbnN3ZXIlM0ElMjIlMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IoaW1hZ2VzJTNEaW1hZ2UlMkMlMjB0ZXh0JTNEcHJvbXB0JTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikudG8oZGV2aWNlJTJDJTIwdG9yY2guZmxvYXQxNiklMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMp",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> Blip2Processor, Blip2Model
<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>processor = Blip2Processor.from_pretrained(<span class="hljs-string">&quot;Salesforce/blip2-opt-2.7b&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Blip2Model.from_pretrained(<span class="hljs-string">&quot;Salesforce/blip2-opt-2.7b&quot;</span>, torch_dtype=torch.float16)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;Question: how many cats are there? Answer:&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(images=image, text=prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).to(device, torch.float16)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)`}}),{c(){d=a("p"),v=n("Examples:"),g=m(),y(h.$$.fragment)},l(i){d=s(i,"P",{});var p=l(d);v=r(p,"Examples:"),p.forEach(o),g=f(i),M(h.$$.fragment,i)},m(i,p){_(i,d,p),e(d,v),_(i,g,p),w(h,i,p),b=!0},p:Ee,i(i){b||(T(h.$$.fragment,i),b=!0)},o(i){B(h.$$.fragment,i),b=!1},d(i){i&&o(d),i&&o(g),$(h,i)}}}function xm(j){let d,v,g,h,b;return{c(){d=a("p"),v=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=a("code"),h=n("Module"),b=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(i){d=s(i,"P",{});var p=l(d);v=r(p,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=s(p,"CODE",{});var E=l(g);h=r(E,"Module"),E.forEach(o),b=r(p,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),p.forEach(o)},m(i,p){_(i,d,p),e(d,v),e(d,g),e(g,h),e(d,b)},d(i){i&&o(d)}}}function zm(j){let d,v,g,h,b;return h=new Ce({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMEJsaXAyTW9kZWwlMEElMEFkZXZpY2UlMjAlM0QlMjAlMjJjdWRhJTIyJTIwaWYlMjB0b3JjaC5jdWRhLmlzX2F2YWlsYWJsZSgpJTIwZWxzZSUyMCUyMmNwdSUyMiUwQSUwQW1vZGVsJTIwJTNEJTIwQmxpcDJNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyU2FsZXNmb3JjZSUyRmJsaXAyLW9wdC0yLjdiJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KSUwQSUwQW1vZGVsLnRvKGRldmljZSklMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJTYWxlc2ZvcmNlJTJGYmxpcDItb3B0LTIuN2IlMjIpJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCU1QiUyMmElMjBwaG90byUyMG9mJTIwYSUyMGNhdCUyMiUyQyUyMCUyMmElMjBwaG90byUyMG9mJTIwYSUyMGRvZyUyMiU1RCUyQyUyMHBhZGRpbmclM0RUcnVlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikudG8oZGV2aWNlKSUwQXRleHRfZmVhdHVyZXMlMjAlM0QlMjBtb2RlbC5nZXRfdGV4dF9mZWF0dXJlcygqKmlucHV0cyk=",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> AutoTokenizer, Blip2Model

<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 = Blip2Model.from_pretrained(<span class="hljs-string">&quot;Salesforce/blip2-opt-2.7b&quot;</span>, torch_dtype=torch.float16)

<span class="hljs-meta">&gt;&gt;&gt; </span>model.to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;Salesforce/blip2-opt-2.7b&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer([<span class="hljs-string">&quot;a photo of a cat&quot;</span>, <span class="hljs-string">&quot;a photo of a dog&quot;</span>], padding=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span>text_features = model.get_text_features(**inputs)`}}),{c(){d=a("p"),v=n("Examples:"),g=m(),y(h.$$.fragment)},l(i){d=s(i,"P",{});var p=l(d);v=r(p,"Examples:"),p.forEach(o),g=f(i),M(h.$$.fragment,i)},m(i,p){_(i,d,p),e(d,v),_(i,g,p),w(h,i,p),b=!0},p:Ee,i(i){b||(T(h.$$.fragment,i),b=!0)},o(i){B(h.$$.fragment,i),b=!1},d(i){i&&o(d),i&&o(g),$(h,i)}}}function Pm(j){let d,v,g,h,b;return{c(){d=a("p"),v=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=a("code"),h=n("Module"),b=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(i){d=s(i,"P",{});var p=l(d);v=r(p,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=s(p,"CODE",{});var E=l(g);h=r(E,"Module"),E.forEach(o),b=r(p,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),p.forEach(o)},m(i,p){_(i,d,p),e(d,v),e(d,g),e(g,h),e(d,b)},d(i){i&&o(d)}}}function Wm(j){let d,v,g,h,b;return h=new Ce({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFpbXBvcnQlMjByZXF1ZXN0cyUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBBdXRvUHJvY2Vzc29yJTJDJTIwQmxpcDJNb2RlbCUwQSUwQWRldmljZSUyMCUzRCUyMCUyMmN1ZGElMjIlMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwJTIyY3B1JTIyJTBBJTBBbW9kZWwlMjAlM0QlMjBCbGlwMk1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJTYWxlc2ZvcmNlJTJGYmxpcDItb3B0LTIuN2IlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBJTBBbW9kZWwudG8oZGV2aWNlKSUwQXByb2Nlc3NvciUyMCUzRCUyMEF1dG9Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMlNhbGVzZm9yY2UlMkZibGlwMi1vcHQtMi43YiUyMiklMEF1cmwlMjAlM0QlMjAlMjJodHRwJTNBJTJGJTJGaW1hZ2VzLmNvY29kYXRhc2V0Lm9yZyUyRnZhbDIwMTclMkYwMDAwMDAwMzk3NjkuanBnJTIyJTBBaW1hZ2UlMjAlM0QlMjBJbWFnZS5vcGVuKHJlcXVlc3RzLmdldCh1cmwlMkMlMjBzdHJlYW0lM0RUcnVlKS5yYXcpJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKGltYWdlcyUzRGltYWdlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikudG8oZGV2aWNlJTJDJTIwdG9yY2guZmxvYXQxNiklMEFpbWFnZV9vdXRwdXRzJTIwJTNEJTIwbW9kZWwuZ2V0X2ltYWdlX2ZlYXR1cmVzKCoqaW5wdXRzKQ==",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> 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, Blip2Model

<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 = Blip2Model.from_pretrained(<span class="hljs-string">&quot;Salesforce/blip2-opt-2.7b&quot;</span>, torch_dtype=torch.float16)

<span class="hljs-meta">&gt;&gt;&gt; </span>model.to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;Salesforce/blip2-opt-2.7b&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(images=image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).to(device, torch.float16)
<span class="hljs-meta">&gt;&gt;&gt; </span>image_outputs = model.get_image_features(**inputs)`}}),{c(){d=a("p"),v=n("Examples:"),g=m(),y(h.$$.fragment)},l(i){d=s(i,"P",{});var p=l(d);v=r(p,"Examples:"),p.forEach(o),g=f(i),M(h.$$.fragment,i)},m(i,p){_(i,d,p),e(d,v),_(i,g,p),w(h,i,p),b=!0},p:Ee,i(i){b||(T(h.$$.fragment,i),b=!0)},o(i){B(h.$$.fragment,i),b=!1},d(i){i&&o(d),i&&o(g),$(h,i)}}}function Fm(j){let d,v,g,h,b;return{c(){d=a("p"),v=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=a("code"),h=n("Module"),b=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(i){d=s(i,"P",{});var p=l(d);v=r(p,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=s(p,"CODE",{});var E=l(g);h=r(E,"Module"),E.forEach(o),b=r(p,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),p.forEach(o)},m(i,p){_(i,d,p),e(d,v),e(d,g),e(g,h),e(d,b)},d(i){i&&o(d)}}}function Nm(j){let d,v,g,h,b;return h=new Ce({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFpbXBvcnQlMjByZXF1ZXN0cyUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBCbGlwMlByb2Nlc3NvciUyQyUyMEJsaXAyTW9kZWwlMEElMEFkZXZpY2UlMjAlM0QlMjAlMjJjdWRhJTIyJTIwaWYlMjB0b3JjaC5jdWRhLmlzX2F2YWlsYWJsZSgpJTIwZWxzZSUyMCUyMmNwdSUyMiUwQSUwQXByb2Nlc3NvciUyMCUzRCUyMEJsaXAyUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJTYWxlc2ZvcmNlJTJGYmxpcDItb3B0LTIuN2IlMjIpJTBBbW9kZWwlMjAlM0QlMjBCbGlwMk1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJTYWxlc2ZvcmNlJTJGYmxpcDItb3B0LTIuN2IlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBbW9kZWwudG8oZGV2aWNlKSUwQXVybCUyMCUzRCUyMCUyMmh0dHAlM0ElMkYlMkZpbWFnZXMuY29jb2RhdGFzZXQub3JnJTJGdmFsMjAxNyUyRjAwMDAwMDAzOTc2OS5qcGclMjIlMEFpbWFnZSUyMCUzRCUyMEltYWdlLm9wZW4ocmVxdWVzdHMuZ2V0KHVybCUyQyUyMHN0cmVhbSUzRFRydWUpLnJhdyklMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IoaW1hZ2VzJTNEaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS50byhkZXZpY2UlMkMlMjB0b3JjaC5mbG9hdDE2KSUwQXFmb3JtZXJfb3V0cHV0cyUyMCUzRCUyMG1vZGVsLmdldF9xZm9ybWVyX2ZlYXR1cmVzKCoqaW5wdXRzKQ==",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> 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> Blip2Processor, Blip2Model

<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>processor = Blip2Processor.from_pretrained(<span class="hljs-string">&quot;Salesforce/blip2-opt-2.7b&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Blip2Model.from_pretrained(<span class="hljs-string">&quot;Salesforce/blip2-opt-2.7b&quot;</span>, torch_dtype=torch.float16)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(images=image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).to(device, torch.float16)
<span class="hljs-meta">&gt;&gt;&gt; </span>qformer_outputs = model.get_qformer_features(**inputs)`}}),{c(){d=a("p"),v=n("Examples:"),g=m(),y(h.$$.fragment)},l(i){d=s(i,"P",{});var p=l(d);v=r(p,"Examples:"),p.forEach(o),g=f(i),M(h.$$.fragment,i)},m(i,p){_(i,d,p),e(d,v),_(i,g,p),w(h,i,p),b=!0},p:Ee,i(i){b||(T(h.$$.fragment,i),b=!0)},o(i){B(h.$$.fragment,i),b=!1},d(i){i&&o(d),i&&o(g),$(h,i)}}}function Qm(j){let d,v,g,h,b;return{c(){d=a("p"),v=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=a("code"),h=n("Module"),b=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(i){d=s(i,"P",{});var p=l(d);v=r(p,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=s(p,"CODE",{});var E=l(g);h=r(E,"Module"),E.forEach(o),b=r(p,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),p.forEach(o)},m(i,p){_(i,d,p),e(d,v),e(d,g),e(g,h),e(d,b)},d(i){i&&o(d)}}}function Gm(j){let d,v,g,h,b;return h=new Ce({props:{code:"ZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQmxpcDJQcm9jZXNzb3IlMkMlMjBCbGlwMkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQWltcG9ydCUyMHRvcmNoJTBBJTBBZGV2aWNlJTIwJTNEJTIwJTIyY3VkYSUyMiUyMGlmJTIwdG9yY2guY3VkYS5pc19hdmFpbGFibGUoKSUyMGVsc2UlMjAlMjJjcHUlMjIlMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBCbGlwMlByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyU2FsZXNmb3JjZSUyRmJsaXAyLW9wdC0yLjdiJTIyKSUwQW1vZGVsJTIwJTNEJTIwQmxpcDJGb3JDb25kaXRpb25hbEdlbmVyYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMlNhbGVzZm9yY2UlMkZibGlwMi1vcHQtMi43YiUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSklMEFtb2RlbC50byhkZXZpY2UpJTBBdXJsJTIwJTNEJTIwJTIyaHR0cCUzQSUyRiUyRmltYWdlcy5jb2NvZGF0YXNldC5vcmclMkZ2YWwyMDE3JTJGMDAwMDAwMDM5NzY5LmpwZyUyMiUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQodXJsJTJDJTIwc3RyZWFtJTNEVHJ1ZSkucmF3KSUwQSUwQWlucHV0cyUyMCUzRCUyMHByb2Nlc3NvcihpbWFnZXMlM0RpbWFnZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpLnRvKGRldmljZSUyQyUyMHRvcmNoLmZsb2F0MTYpJTBBJTBBZ2VuZXJhdGVkX2lkcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzKSUwQWdlbmVyYXRlZF90ZXh0JTIwJTNEJTIwcHJvY2Vzc29yLmJhdGNoX2RlY29kZShnZW5lcmF0ZWRfaWRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpJTVCMCU1RC5zdHJpcCgpJTBBcHJpbnQoZ2VuZXJhdGVkX3RleHQp",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> Blip2Processor, Blip2ForConditionalGeneration
<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>processor = Blip2Processor.from_pretrained(<span class="hljs-string">&quot;Salesforce/blip2-opt-2.7b&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Blip2ForConditionalGeneration.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;Salesforce/blip2-opt-2.7b&quot;</span>, torch_dtype=torch.float16
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(images=image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).to(device, torch.float16)

<span class="hljs-meta">&gt;&gt;&gt; </span>generated_ids = model.generate(**inputs)
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_text = processor.batch_decode(generated_ids, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>].strip()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(generated_text)
two cats laying on a couch`}}),{c(){d=a("p"),v=n("Image captioning (without providing a text prompt):"),g=m(),y(h.$$.fragment)},l(i){d=s(i,"P",{});var p=l(d);v=r(p,"Image captioning (without providing a text prompt):"),p.forEach(o),g=f(i),M(h.$$.fragment,i)},m(i,p){_(i,d,p),e(d,v),_(i,g,p),w(h,i,p),b=!0},p:Ee,i(i){b||(T(h.$$.fragment,i),b=!0)},o(i){B(h.$$.fragment,i),b=!1},d(i){i&&o(d),i&&o(g),$(h,i)}}}function qm(j){let d,v,g,h,b;return h=new Ce({props:{code:"ZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQmxpcDJQcm9jZXNzb3IlMkMlMjBCbGlwMkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQWltcG9ydCUyMHRvcmNoJTBBJTBBZGV2aWNlJTIwJTNEJTIwJTIyY3VkYSUyMiUyMGlmJTIwdG9yY2guY3VkYS5pc19hdmFpbGFibGUoKSUyMGVsc2UlMjAlMjJjcHUlMjIlMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBCbGlwMlByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyU2FsZXNmb3JjZSUyRmJsaXAyLW9wdC0yLjdiJTIyKSUwQW1vZGVsJTIwJTNEJTIwQmxpcDJGb3JDb25kaXRpb25hbEdlbmVyYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMlNhbGVzZm9yY2UlMkZibGlwMi1vcHQtMi43YiUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSklMEFtb2RlbC50byhkZXZpY2UpJTBBdXJsJTIwJTNEJTIwJTIyaHR0cCUzQSUyRiUyRmltYWdlcy5jb2NvZGF0YXNldC5vcmclMkZ2YWwyMDE3JTJGMDAwMDAwMDM5NzY5LmpwZyUyMiUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQodXJsJTJDJTIwc3RyZWFtJTNEVHJ1ZSkucmF3KSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMlF1ZXN0aW9uJTNBJTIwaG93JTIwbWFueSUyMGNhdHMlMjBhcmUlMjB0aGVyZSUzRiUyMEFuc3dlciUzQSUyMiUwQWlucHV0cyUyMCUzRCUyMHByb2Nlc3NvcihpbWFnZXMlM0RpbWFnZSUyQyUyMHRleHQlM0Rwcm9tcHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS50byhkZXZpY2UlMkMlMjB0b3JjaC5mbG9hdDE2KSUwQSUwQWdlbmVyYXRlZF9pZHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSgqKmlucHV0cyklMEFnZW5lcmF0ZWRfdGV4dCUyMCUzRCUyMHByb2Nlc3Nvci5iYXRjaF9kZWNvZGUoZ2VuZXJhdGVkX2lkcyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSU1QjAlNUQuc3RyaXAoKSUwQXByaW50KGdlbmVyYXRlZF90ZXh0KQ==",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> Blip2Processor, Blip2ForConditionalGeneration
<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>processor = Blip2Processor.from_pretrained(<span class="hljs-string">&quot;Salesforce/blip2-opt-2.7b&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Blip2ForConditionalGeneration.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;Salesforce/blip2-opt-2.7b&quot;</span>, torch_dtype=torch.float16
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;Question: how many cats are there? Answer:&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(images=image, text=prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).to(device, torch.float16)

<span class="hljs-meta">&gt;&gt;&gt; </span>generated_ids = model.generate(**inputs)
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_text = processor.batch_decode(generated_ids, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>].strip()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(generated_text)
two`}}),{c(){d=a("p"),v=n("Visual question answering (prompt = question):"),g=m(),y(h.$$.fragment)},l(i){d=s(i,"P",{});var p=l(d);v=r(p,"Visual question answering (prompt = question):"),p.forEach(o),g=f(i),M(h.$$.fragment,i)},m(i,p){_(i,d,p),e(d,v),_(i,g,p),w(h,i,p),b=!0},p:Ee,i(i){b||(T(h.$$.fragment,i),b=!0)},o(i){B(h.$$.fragment,i),b=!1},d(i){i&&o(d),i&&o(g),$(h,i)}}}function Vm(j){let d,v,g,h,b,i,p,E,Pa,Ur,se,Ue,un,ht,Wa,gn,Fa,Ir,H,Na,ut,Qa,Ga,gt,qa,Va,Zr,bo,Sa,xr,vo,_n,Aa,zr,yo,Ra,Pr,Ie,_t,Xa,bn,La,Da,Ya,bt,Oa,Mo,Ha,Ka,Wr,Ze,$c,Fr,vt,es,wo,ts,Nr,K,os,yt,ns,rs,Mt,as,ss,Qr,le,xe,vn,wt,ls,yn,is,Gr,To,ds,qr,Bo,Tt,cs,Bt,ps,ms,Vr,$o,fs,Sr,ie,ze,Mn,$t,hs,wn,us,Ar,W,kt,gs,ee,ko,_s,bs,jo,vs,ys,jt,Ms,ws,Ts,de,Bs,Jo,$s,ks,Eo,js,Js,Es,Pe,Cs,We,Jt,Us,Et,Is,Co,Zs,xs,Rr,ce,Fe,Tn,Ct,zs,Bn,Ps,Xr,G,Ut,Ws,pe,Fs,Uo,Ns,Qs,It,Gs,qs,Vs,me,Ss,Io,As,Rs,Zo,Xs,Ls,Ds,Ne,Lr,fe,Qe,$n,Zt,Ys,kn,Os,Dr,q,xt,Hs,V,Ks,xo,el,tl,zt,ol,nl,zo,rl,al,Po,sl,ll,il,he,dl,Wo,cl,pl,Fo,ml,fl,hl,Ge,Yr,ue,qe,jn,Pt,ul,Jn,gl,Or,F,Wt,_l,En,bl,vl,N,No,yl,Ml,Qo,wl,Tl,Go,Bl,$l,Cn,kl,jl,qo,Jl,El,Cl,Ve,Ft,Ul,Nt,Il,Vo,Zl,xl,zl,Se,Qt,Pl,Gt,Wl,So,Fl,Nl,Hr,ge,Ae,Un,qt,Ql,In,Gl,Kr,_e,Vt,ql,te,St,Vl,be,Sl,Ao,Al,Rl,Zn,Xl,Ll,Dl,Re,ea,ve,Xe,xn,At,Yl,zn,Ol,ta,D,Rt,Hl,Pn,Kl,ei,oe,Xt,ti,U,oi,Wn,ni,ri,Fn,ai,si,Nn,li,ii,Qn,di,ci,Gn,pi,mi,qn,fi,hi,Vn,ui,gi,_i,Lt,Dt,bi,Sn,vi,yi,Mi,k,wi,An,Ti,Bi,Rn,$i,ki,Xn,ji,Ji,Ln,Ei,Ci,Dn,Ui,Ii,Yn,Zi,xi,On,zi,Pi,Hn,Wi,Fi,Kn,Ni,Qi,er,Gi,qi,tr,Vi,Si,or,Ai,Ri,nr,Xi,Li,rr,Di,Yi,oa,ye,Le,ar,Yt,Oi,sr,Hi,na,C,Ot,Ki,lr,ed,td,Ht,od,Ro,nd,rd,ad,Kt,sd,eo,ld,id,dd,S,to,cd,Me,pd,Xo,md,fd,ir,hd,ud,gd,De,_d,Ye,bd,A,oo,vd,we,yd,Lo,Md,wd,dr,Td,Bd,$d,Oe,kd,He,jd,R,no,Jd,Te,Ed,Do,Cd,Ud,cr,Id,Zd,xd,Ke,zd,et,Pd,X,ro,Wd,Be,Fd,Yo,Nd,Qd,pr,Gd,qd,Vd,tt,Sd,ot,ra,$e,nt,mr,ao,Ad,fr,Rd,aa,I,so,Xd,hr,Ld,Dd,lo,Yd,ur,Od,Hd,Kd,io,ec,Oo,tc,oc,nc,co,rc,po,ac,sc,lc,x,mo,ic,ke,dc,Ho,cc,pc,gr,mc,fc,hc,rt,uc,_r,gc,_c,at,bc,st,vc,lt,fo,yc,ho,Mc,br,wc,Tc,sa;return i=new O({}),ht=new O({}),wt=new O({}),$t=new O({}),kt=new Z({props:{name:"class transformers.Blip2Config",anchor:"transformers.Blip2Config",parameters:[{name:"vision_config",val:" = None"},{name:"qformer_config",val:" = None"},{name:"text_config",val:" = None"},{name:"num_query_tokens",val:" = 32"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Blip2Config.vision_config",description:`<strong>vision_config</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
Dictionary of configuration options used to initialize <a href="/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2VisionConfig">Blip2VisionConfig</a>.`,name:"vision_config"},{anchor:"transformers.Blip2Config.qformer_config",description:`<strong>qformer_config</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
Dictionary of configuration options used to initialize <a href="/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2QFormerConfig">Blip2QFormerConfig</a>.`,name:"qformer_config"},{anchor:"transformers.Blip2Config.text_config",description:`<strong>text_config</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
Dictionary of configuration options used to initialize any <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a>.`,name:"text_config"},{anchor:"transformers.Blip2Config.num_query_tokens",description:`<strong>num_query_tokens</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
The number of query tokens passed through the Transformer.`,name:"num_query_tokens"},{anchor:"transformers.Blip2Config.kwargs",description:`<strong>kwargs</strong> (<em>optional</em>) &#x2014;
Dictionary of keyword arguments.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/blip_2/configuration_blip_2.py#L250"}}),Pe=new Je({props:{anchor:"transformers.Blip2Config.example",$$slots:{default:[Jm]},$$scope:{ctx:j}}}),Jt=new Z({props:{name:"from_vision_qformer_text_configs",anchor:"transformers.Blip2Config.from_vision_qformer_text_configs",parameters:[{name:"vision_config",val:": Blip2VisionConfig"},{name:"qformer_config",val:": Blip2QFormerConfig"},{name:"text_config",val:": PretrainedConfig"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/blip_2/configuration_blip_2.py#L334",returnDescription:`
<p>An instance of a configuration object</p>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2Config"
>Blip2Config</a></p>
`}}),Ct=new O({}),Ut=new Z({props:{name:"class transformers.Blip2VisionConfig",anchor:"transformers.Blip2VisionConfig",parameters:[{name:"hidden_size",val:" = 1408"},{name:"intermediate_size",val:" = 6144"},{name:"num_hidden_layers",val:" = 39"},{name:"num_attention_heads",val:" = 16"},{name:"image_size",val:" = 224"},{name:"patch_size",val:" = 14"},{name:"hidden_act",val:" = 'gelu'"},{name:"layer_norm_eps",val:" = 1e-05"},{name:"attention_dropout",val:" = 0.0"},{name:"initializer_range",val:" = 1e-10"},{name:"qkv_bias",val:" = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Blip2VisionConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1408) &#x2014;
Dimensionality of the encoder layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.Blip2VisionConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 6144) &#x2014;
Dimensionality of the &#x201C;intermediate&#x201D; (i.e., feed-forward) layer in the Transformer encoder.`,name:"intermediate_size"},{anchor:"transformers.Blip2VisionConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 39) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"num_hidden_layers"},{anchor:"transformers.Blip2VisionConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_attention_heads"},{anchor:"transformers.Blip2VisionConfig.image_size",description:`<strong>image_size</strong> (<code>int</code>, <em>optional</em>, defaults to 224) &#x2014;
The size (resolution) of each image.`,name:"image_size"},{anchor:"transformers.Blip2VisionConfig.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 14) &#x2014;
The size (resolution) of each patch.`,name:"patch_size"},{anchor:"transformers.Blip2VisionConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the encoder and pooler. If string, <code>&quot;gelu&quot;</code>,
<code>&quot;relu&quot;</code>, <code>&quot;selu&quot;</code> and <code>&quot;gelu_new&quot;</code> \`<code>&quot;gelu&quot;</code> are supported. layer_norm_eps (<code>float</code>, <em>optional</em>, defaults
to 1e-5): The epsilon used by the layer normalization layers.`,name:"hidden_act"},{anchor:"transformers.Blip2VisionConfig.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.Blip2VisionConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.Blip2VisionConfig.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 the queries and values in the self-attention layers.`,name:"qkv_bias"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/blip_2/configuration_blip_2.py#L33"}}),Ne=new Je({props:{anchor:"transformers.Blip2VisionConfig.example",$$slots:{default:[Em]},$$scope:{ctx:j}}}),Zt=new O({}),xt=new Z({props:{name:"class transformers.Blip2QFormerConfig",anchor:"transformers.Blip2QFormerConfig",parameters:[{name:"vocab_size",val:" = 30522"},{name:"hidden_size",val:" = 768"},{name:"num_hidden_layers",val:" = 12"},{name:"num_attention_heads",val:" = 12"},{name:"intermediate_size",val:" = 3072"},{name:"hidden_act",val:" = 'gelu'"},{name:"hidden_dropout_prob",val:" = 0.1"},{name:"attention_probs_dropout_prob",val:" = 0.1"},{name:"max_position_embeddings",val:" = 512"},{name:"initializer_range",val:" = 0.02"},{name:"layer_norm_eps",val:" = 1e-12"},{name:"pad_token_id",val:" = 0"},{name:"position_embedding_type",val:" = 'absolute'"},{name:"cross_attention_frequency",val:" = 2"},{name:"encoder_hidden_size",val:" = 1408"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Blip2QFormerConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 30522) &#x2014;
Vocabulary size of the Q-Former model. Defines the number of different tokens that can be represented by
the <code>inputs_ids</code> passed when calling the model.`,name:"vocab_size"},{anchor:"transformers.Blip2QFormerConfig.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.Blip2QFormerConfig.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.Blip2QFormerConfig.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.Blip2QFormerConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 3072) &#x2014;
Dimensionality of the &#x201C;intermediate&#x201D; (often named feed-forward) layer in the Transformer encoder.`,name:"intermediate_size"},{anchor:"transformers.Blip2QFormerConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>Callable</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the encoder and pooler. If string, <code>&quot;gelu&quot;</code>,
<code>&quot;relu&quot;</code>, <code>&quot;silu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"hidden_act"},{anchor:"transformers.Blip2QFormerConfig.hidden_dropout_prob",description:`<strong>hidden_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.`,name:"hidden_dropout_prob"},{anchor:"transformers.Blip2QFormerConfig.attention_probs_dropout_prob",description:`<strong>attention_probs_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout ratio for the attention probabilities.`,name:"attention_probs_dropout_prob"},{anchor:"transformers.Blip2QFormerConfig.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 512) &#x2014;
The maximum sequence length that this model might ever be used with. Typically set this to something large
just in case (e.g., 512 or 1024 or 2048).`,name:"max_position_embeddings"},{anchor:"transformers.Blip2QFormerConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.Blip2QFormerConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-12) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.Blip2QFormerConfig.position_embedding_type",description:`<strong>position_embedding_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;absolute&quot;</code>) &#x2014;
Type of position embedding. Choose one of <code>&quot;absolute&quot;</code>, <code>&quot;relative_key&quot;</code>, <code>&quot;relative_key_query&quot;</code>. For
positional embeddings use <code>&quot;absolute&quot;</code>. For more information on <code>&quot;relative_key&quot;</code>, please refer to
<a href="https://arxiv.org/abs/1803.02155" rel="nofollow">Self-Attention with Relative Position Representations (Shaw et al.)</a>.
For more information on <code>&quot;relative_key_query&quot;</code>, please refer to <em>Method 4</em> in <a href="https://arxiv.org/abs/2009.13658" rel="nofollow">Improve Transformer Models
with Better Relative Position Embeddings (Huang et al.)</a>.`,name:"position_embedding_type"},{anchor:"transformers.Blip2QFormerConfig.cross_attention_frequency",description:`<strong>cross_attention_frequency</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
The frequency of adding cross-attention to the Transformer layers.`,name:"cross_attention_frequency"},{anchor:"transformers.Blip2QFormerConfig.encoder_hidden_size",description:`<strong>encoder_hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1408) &#x2014;
The hidden size of the hidden states for cross-attention.`,name:"encoder_hidden_size"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/blip_2/configuration_blip_2.py#L132"}}),Ge=new Je({props:{anchor:"transformers.Blip2QFormerConfig.example",$$slots:{default:[Cm]},$$scope:{ctx:j}}}),Pt=new O({}),Wt=new Z({props:{name:"class transformers.Blip2Processor",anchor:"transformers.Blip2Processor",parameters:[{name:"image_processor",val:""},{name:"tokenizer",val:""}],parametersDescription:[{anchor:"transformers.Blip2Processor.image_processor",description:`<strong>image_processor</strong> (<code>BlipImageProcessor</code>) &#x2014;
An instance of <a href="/docs/transformers/main/en/model_doc/blip#transformers.BlipImageProcessor">BlipImageProcessor</a>. The image processor is a required input.`,name:"image_processor"},{anchor:"transformers.Blip2Processor.tokenizer",description:"<strong>tokenizer</strong> (<code>AutoTokenizer</code>) &#x2014;\nAn instance of [&#x2018;PreTrainedTokenizer`]. The tokenizer is a required input.",name:"tokenizer"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/blip_2/processing_blip_2.py#L27"}}),Ft=new Z({props:{name:"batch_decode",anchor:"transformers.Blip2Processor.batch_decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/blip_2/processing_blip_2.py#L134"}}),Qt=new Z({props:{name:"decode",anchor:"transformers.Blip2Processor.decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/blip_2/processing_blip_2.py#L142"}}),qt=new O({}),Vt=new Z({props:{name:"class transformers.Blip2VisionModel",anchor:"transformers.Blip2VisionModel",parameters:[{name:"config",val:": Blip2VisionConfig"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/blip_2/modeling_blip_2.py#L511"}}),St=new Z({props:{name:"forward",anchor:"transformers.Blip2VisionModel.forward",parameters:[{name:"pixel_values",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.Blip2VisionModel.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2Processor">Blip2Processor</a>. See <code>Blip2Processor.__call__()</code> for
details.`,name:"pixel_values"},{anchor:"transformers.Blip2VisionModel.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.Blip2VisionModel.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.Blip2VisionModel.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/blip_2/modeling_blip_2.py#L526",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling"
>transformers.modeling_outputs.BaseModelOutputWithPooling</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<code>&lt;class 'transformers.models.blip_2.configuration_blip_2.Blip2VisionConfig'&gt;</code>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>pooler_output</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, hidden_size)</code>) \u2014 Last layer hidden-state of the first token of the sequence (classification token) after further processing
through the layers used for the auxiliary pretraining task. E.g. for BERT-family of models, this returns
the classification token after processing through a linear layer and a tanh activation function. The linear
layer weights are trained from the next sentence prediction (classification) objective during pretraining.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling"
>transformers.modeling_outputs.BaseModelOutputWithPooling</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Re=new hn({props:{$$slots:{default:[Um]},$$scope:{ctx:j}}}),At=new O({}),Rt=new Z({props:{name:"class transformers.Blip2QFormerModel",anchor:"transformers.Blip2QFormerModel",parameters:[{name:"config",val:": Blip2QFormerConfig"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/blip_2/modeling_blip_2.py#L1006"}}),Xt=new Z({props:{name:"forward",anchor:"transformers.Blip2QFormerModel.forward",parameters:[{name:"query_embeds",val:""},{name:"attention_mask",val:" = None"},{name:"head_mask",val:" = None"},{name:"encoder_hidden_states",val:" = None"},{name:"encoder_attention_mask",val:" = None"},{name:"past_key_values",val:" = None"},{name:"use_cache",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/blip_2/modeling_blip_2.py#L1081"}}),Yt=new O({}),Ot=new Z({props:{name:"class transformers.Blip2Model",anchor:"transformers.Blip2Model",parameters:[{name:"config",val:": Blip2Config"}],parametersDescription:[{anchor:"transformers.Blip2Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2Config">Blip2Config</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/blip_2/modeling_blip_2.py#L1202"}}),to=new Z({props:{name:"forward",anchor:"transformers.Blip2Model.forward",parameters:[{name:"pixel_values",val:": FloatTensor"},{name:"input_ids",val:": FloatTensor"},{name:"attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"decoder_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"decoder_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.Blip2Model.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2Processor">Blip2Processor</a>. See <code>Blip2Processor.__call__()</code> for
details.`,name:"pixel_values"},{anchor:"transformers.Blip2Model.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of input sequence tokens in the vocabulary of the language model. Input tokens can optionally be
provided to serve as text prompt, which the language model can continue.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2Processor">Blip2Processor</a>. See <code>Blip2Processor.__call__()</code> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.Blip2Model.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.Blip2Model.forward.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of decoder input sequence tokens in the vocabulary of the language model. Only relevant in case an
encoder-decoder language model (like T5) is used.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/model_doc/perceiver#transformers.PerceiverTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details. <a href="../glossary#decoder-input-ids">What are decoder input IDs?</a>`,name:"decoder_input_ids"},{anchor:"transformers.Blip2Model.forward.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.</p>
<p>Only relevant in case an encoder-decoder language model (like T5) is used.`,name:"decoder_attention_mask"},{anchor:"transformers.Blip2Model.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.Blip2Model.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.Blip2Model.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/blip_2/modeling_blip_2.py#L1425",returnDescription:`
<p>A <code>transformers.models.blip_2.modeling_blip_2.Blip2ForConditionalGenerationModelOutput</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 (<code>&lt;class 'transformers.models.blip_2.configuration_blip_2.Blip2VisionConfig'&gt;</code>) and inputs.</p>
<ul>
<li><strong>loss</strong> (<code>torch.FloatTensor</code>, <em>optional</em>, returned when <code>labels</code> is provided, <code>torch.FloatTensor</code> of shape <code>(1,)</code>) \u2014 Language modeling loss from the language model.</li>
<li><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head of the language model.</li>
<li><strong>vision_outputs</strong> (<code>BaseModelOutputWithPooling</code>) \u2014 Outputs of the vision encoder.</li>
<li><strong>qformer_outputs</strong> (<code>BaseModelOutputWithPoolingAndCrossAttentions</code>) \u2014 Outputs of the Q-Former (Querying Transformer).</li>
<li><strong>language_model_outputs</strong> (<code>CausalLMOutputWithPast</code> or <code>Seq2SeqLMOutput</code>) \u2014 Outputs of the language model.</li>
</ul>
`,returnType:`
<p><code>transformers.models.blip_2.modeling_blip_2.Blip2ForConditionalGenerationModelOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),De=new hn({props:{$$slots:{default:[Im]},$$scope:{ctx:j}}}),Ye=new Je({props:{anchor:"transformers.Blip2Model.forward.example",$$slots:{default:[Zm]},$$scope:{ctx:j}}}),oo=new Z({props:{name:"get_text_features",anchor:"transformers.Blip2Model.get_text_features",parameters:[{name:"input_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"decoder_input_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"decoder_attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"labels",val:": typing.Optional[torch.Tensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.Blip2Model.get_text_features.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. Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/model_doc/perceiver#transformers.PerceiverTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details. <a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.Blip2Model.get_text_features.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>.
<a href="../glossary#attention-mask">What are attention masks?</a></li>
</ul>`,name:"attention_mask"},{anchor:"transformers.Blip2Model.get_text_features.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of decoder input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/model_doc/perceiver#transformers.PerceiverTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#decoder-input-ids">What are decoder input IDs?</a></p>
<p>T5 uses the <code>pad_token_id</code> as the starting token for <code>decoder_input_ids</code> generation. 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>To know more on how to prepare <code>decoder_input_ids</code> for pretraining take a look at <a href="./t5#training">T5
Training</a>.`,name:"decoder_input_ids"},{anchor:"transformers.Blip2Model.get_text_features.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.`,name:"decoder_attention_mask"},{anchor:"transformers.Blip2Model.get_text_features.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.Blip2Model.get_text_features.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.Blip2Model.get_text_features.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/blip_2/modeling_blip_2.py#L1252",returnDescription:`
<p>The language model outputs. If <code>return_dict=True</code>, the output is a <code>CausalLMOutputWithPast</code> that
contains the language model logits, the past key values and the hidden states if
<code>output_hidden_states=True</code>.</p>
`,returnType:`
<p>text_outputs (<code>CausalLMOutputWithPast</code>, or <code>tuple(torch.FloatTensor)</code> if <code>return_dict=False</code>)</p>
`}}),Oe=new hn({props:{$$slots:{default:[xm]},$$scope:{ctx:j}}}),He=new Je({props:{anchor:"transformers.Blip2Model.get_text_features.example",$$slots:{default:[zm]},$$scope:{ctx:j}}}),no=new Z({props:{name:"get_image_features",anchor:"transformers.Blip2Model.get_image_features",parameters:[{name:"pixel_values",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.Blip2Model.get_image_features.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2Processor">Blip2Processor</a>. See <code>Blip2Processor.__call__()</code> for
details.`,name:"pixel_values"},{anchor:"transformers.Blip2Model.get_image_features.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.Blip2Model.get_image_features.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.Blip2Model.get_image_features.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/blip_2/modeling_blip_2.py#L1315",returnDescription:`
<p>The vision model outputs. If <code>return_dict=True</code>, the output is a <code>BaseModelOutputWithPooling</code> that
contains the image features, the pooled image features and the hidden states if
<code>output_hidden_states=True</code>.</p>
`,returnType:`
<p>vision_outputs (<code>BaseModelOutputWithPooling</code> or tuple of <code>torch.FloatTensor</code>)</p>
`}}),Ke=new hn({props:{$$slots:{default:[Pm]},$$scope:{ctx:j}}}),et=new Je({props:{anchor:"transformers.Blip2Model.get_image_features.example",$$slots:{default:[Wm]},$$scope:{ctx:j}}}),ro=new Z({props:{name:"get_qformer_features",anchor:"transformers.Blip2Model.get_qformer_features",parameters:[{name:"pixel_values",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.Blip2Model.get_qformer_features.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2Processor">Blip2Processor</a>. See <code>Blip2Processor.__call__()</code> for
details.`,name:"pixel_values"},{anchor:"transformers.Blip2Model.get_qformer_features.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of input sequence tokens in the vocabulary of the language model. Input tokens can optionally be
provided to serve as text prompt, which the language model can continue.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2Processor">Blip2Processor</a>. See <code>Blip2Processor.__call__()</code> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.Blip2Model.get_qformer_features.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.Blip2Model.get_qformer_features.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of decoder input sequence tokens in the vocabulary of the language model. Only relevant in case an
encoder-decoder language model (like T5) is used.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/model_doc/perceiver#transformers.PerceiverTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details. <a href="../glossary#decoder-input-ids">What are decoder input IDs?</a>`,name:"decoder_input_ids"},{anchor:"transformers.Blip2Model.get_qformer_features.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.</p>
<p>Only relevant in case an encoder-decoder language model (like T5) is used.`,name:"decoder_attention_mask"},{anchor:"transformers.Blip2Model.get_qformer_features.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.Blip2Model.get_qformer_features.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.Blip2Model.get_qformer_features.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/blip_2/modeling_blip_2.py#L1363",returnDescription:`
<p>The vision model outputs. If <code>return_dict=True</code>, the output is a <code>BaseModelOutputWithPooling</code> that
contains the image features, the pooled image features and the hidden states if
<code>output_hidden_states=True</code>.</p>
`,returnType:`
<p>vision_outputs (<code>BaseModelOutputWithPooling</code> or tuple of <code>torch.FloatTensor</code>)</p>
`}}),tt=new hn({props:{$$slots:{default:[Fm]},$$scope:{ctx:j}}}),ot=new Je({props:{anchor:"transformers.Blip2Model.get_qformer_features.example",$$slots:{default:[Nm]},$$scope:{ctx:j}}}),ao=new O({}),so=new Z({props:{name:"class transformers.Blip2ForConditionalGeneration",anchor:"transformers.Blip2ForConditionalGeneration",parameters:[{name:"config",val:": Blip2Config"}],parametersDescription:[{anchor:"transformers.Blip2ForConditionalGeneration.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2Config">Blip2Config</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/blip_2/modeling_blip_2.py#L1562"}}),mo=new Z({props:{name:"forward",anchor:"transformers.Blip2ForConditionalGeneration.forward",parameters:[{name:"pixel_values",val:": FloatTensor"},{name:"input_ids",val:": FloatTensor"},{name:"attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"decoder_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"decoder_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.Blip2ForConditionalGeneration.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2Processor">Blip2Processor</a>. See <code>Blip2Processor.__call__()</code> for
details.`,name:"pixel_values"},{anchor:"transformers.Blip2ForConditionalGeneration.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of input sequence tokens in the vocabulary of the language model. Input tokens can optionally be
provided to serve as text prompt, which the language model can continue.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2Processor">Blip2Processor</a>. See <code>Blip2Processor.__call__()</code> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.Blip2ForConditionalGeneration.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.Blip2ForConditionalGeneration.forward.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of decoder input sequence tokens in the vocabulary of the language model. Only relevant in case an
encoder-decoder language model (like T5) is used.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/model_doc/perceiver#transformers.PerceiverTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details. <a href="../glossary#decoder-input-ids">What are decoder input IDs?</a>`,name:"decoder_input_ids"},{anchor:"transformers.Blip2ForConditionalGeneration.forward.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.</p>
<p>Only relevant in case an encoder-decoder language model (like T5) is used.`,name:"decoder_attention_mask"},{anchor:"transformers.Blip2ForConditionalGeneration.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.Blip2ForConditionalGeneration.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.Blip2ForConditionalGeneration.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/blip_2/modeling_blip_2.py#L1632",returnDescription:`
<p>A <code>transformers.models.blip_2.modeling_blip_2.Blip2ForConditionalGenerationModelOutput</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 (<code>&lt;class 'transformers.models.blip_2.configuration_blip_2.Blip2VisionConfig'&gt;</code>) and inputs.</p>
<ul>
<li><strong>loss</strong> (<code>torch.FloatTensor</code>, <em>optional</em>, returned when <code>labels</code> is provided, <code>torch.FloatTensor</code> of shape <code>(1,)</code>) \u2014 Language modeling loss from the language model.</li>
<li><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head of the language model.</li>
<li><strong>vision_outputs</strong> (<code>BaseModelOutputWithPooling</code>) \u2014 Outputs of the vision encoder.</li>
<li><strong>qformer_outputs</strong> (<code>BaseModelOutputWithPoolingAndCrossAttentions</code>) \u2014 Outputs of the Q-Former (Querying Transformer).</li>
<li><strong>language_model_outputs</strong> (<code>CausalLMOutputWithPast</code> or <code>Seq2SeqLMOutput</code>) \u2014 Outputs of the language model.</li>
</ul>
`,returnType:`
<p><code>transformers.models.blip_2.modeling_blip_2.Blip2ForConditionalGenerationModelOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),rt=new hn({props:{$$slots:{default:[Qm]},$$scope:{ctx:j}}}),at=new Je({props:{anchor:"transformers.Blip2ForConditionalGeneration.forward.example",$$slots:{default:[Gm]},$$scope:{ctx:j}}}),st=new Je({props:{anchor:"transformers.Blip2ForConditionalGeneration.forward.example-2",$$slots:{default:[qm]},$$scope:{ctx:j}}}),fo=new Z({props:{name:"generate",anchor:"transformers.Blip2ForConditionalGeneration.generate",parameters:[{name:"pixel_values",val:": FloatTensor"},{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"**generate_kwargs",val:""}],parametersDescription:[{anchor:"transformers.Blip2ForConditionalGeneration.generate.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape (batch_size, num_channels, height, width)) &#x2014;
Input images to be processed.`,name:"pixel_values"},{anchor:"transformers.Blip2ForConditionalGeneration.generate.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape (batch_size, sequence_length), <em>optional</em>) &#x2014;
The sequence used as a prompt for the generation.`,name:"input_ids"},{anchor:"transformers.Blip2ForConditionalGeneration.generate.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.LongTensor</code> of shape (batch_size, sequence_length), <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices`,name:"attention_mask"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/blip_2/modeling_blip_2.py#L1792",returnDescription:`
<p>A list of strings of length batch_size * num_captions.</p>
`,returnType:`
<p>captions (list)</p>
`}}),{c(){d=a("meta"),v=m(),g=a("h1"),h=a("a"),b=a("span"),y(i.$$.fragment),p=m(),E=a("span"),Pa=n("BLIP-2"),Ur=m(),se=a("h2"),Ue=a("a"),un=a("span"),y(ht.$$.fragment),Wa=m(),gn=a("span"),Fa=n("Overview"),Ir=m(),H=a("p"),Na=n("The BLIP-2 model was proposed in "),ut=a("a"),Qa=n("BLIP-2: Bootstrapping Language-Image Pre-training with Frozen Image Encoders and Large Language Models"),Ga=n(` by
Junnan Li, Dongxu Li, Silvio Savarese, Steven Hoi. BLIP-2 leverages frozen pre-trained image encoders and large language models (LLMs) by training a lightweight, 12-layer Transformer
encoder in between them, achieving state-of-the-art performance on various vision-language tasks. Most notably, BLIP-2 improves upon `),gt=a("a"),qa=n("Flamingo"),Va=n(`, an 80 billion parameter model, by 8.7%
on zero-shot VQAv2 with 54x fewer trainable parameters.`),Zr=m(),bo=a("p"),Sa=n("The abstract from the paper is the following:"),xr=m(),vo=a("p"),_n=a("em"),Aa=n("The cost of vision-and-language pre-training has become increasingly prohibitive due to end-to-end training of large-scale models. This paper proposes BLIP-2, a generic and efficient pre-training strategy that bootstraps vision-language pre-training from off-the-shelf frozen pre-trained image encoders and frozen large language models. BLIP-2 bridges the modality gap with a lightweight Querying Transformer, which is pre-trained in two stages. The first stage bootstraps vision-language representation learning from a frozen image encoder. The second stage bootstraps vision-to-language generative learning from a frozen language model. BLIP-2 achieves state-of-the-art performance on various vision-language tasks, despite having significantly fewer trainable parameters than existing methods. For example, our model outperforms Flamingo80B by 8.7% on zero-shot VQAv2 with 54x fewer trainable parameters. We also demonstrate the model\u2019s emerging capabilities of zero-shot image-to-text generation that can follow natural language instructions."),zr=m(),yo=a("p"),Ra=n("Tips:"),Pr=m(),Ie=a("ul"),_t=a("li"),Xa=n("BLIP-2 can be used for conditional text generation given an image and an optional text prompt. At inference time, it\u2019s recommended to use the "),bn=a("code"),La=n("generate"),Da=n(" method."),Ya=m(),bt=a("li"),Oa=n("One can use "),Mo=a("a"),Ha=n("Blip2Processor"),Ka=n(" to prepare images for the model, and decode the predicted tokens ID\u2019s back to text."),Wr=m(),Ze=a("img"),Fr=m(),vt=a("small"),es=n("BLIP-2 architecture. Taken from the "),wo=a("a"),ts=n("original paper."),Nr=m(),K=a("p"),os=n("This model was contributed by "),yt=a("a"),ns=n("nielsr"),rs=n(`.
The original code can be found `),Mt=a("a"),as=n("here"),ss=n("."),Qr=m(),le=a("h2"),xe=a("a"),vn=a("span"),y(wt.$$.fragment),ls=m(),yn=a("span"),is=n("Resources"),Gr=m(),To=a("p"),ds=n("A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started with BLIP-2."),qr=m(),Bo=a("ul"),Tt=a("li"),cs=n("Demo notebooks for BLIP-2 for image captioning, visual question answering (VQA) and chat-like conversations can be found "),Bt=a("a"),ps=n("here"),ms=n("."),Vr=m(),$o=a("p"),fs=n("If you\u2019re interested in submitting a resource to be included here, please feel free to open a Pull Request and we\u2019ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource."),Sr=m(),ie=a("h2"),ze=a("a"),Mn=a("span"),y($t.$$.fragment),hs=m(),wn=a("span"),us=n("Blip2Config"),Ar=m(),W=a("div"),y(kt.$$.fragment),gs=m(),ee=a("p"),ko=a("a"),_s=n("Blip2Config"),bs=n(" is the configuration class to store the configuration of a "),jo=a("a"),vs=n("Blip2ForConditionalGeneration"),ys=n(`. It is
used to instantiate a BLIP-2 model according to the specified arguments, defining the vision model, Q-Former model
and language model configs. Instantiating a configuration with the defaults will yield a similar configuration to
that of the BLIP-2 `),jt=a("a"),Ms=n("Salesforce/blip2-opt-2.7b"),ws=n(" architecture."),Ts=m(),de=a("p"),Bs=n("Configuration objects inherit from "),Jo=a("a"),$s=n("PretrainedConfig"),ks=n(` and can be used to control the model outputs. Read the
documentation from `),Eo=a("a"),js=n("PretrainedConfig"),Js=n(" for more information."),Es=m(),y(Pe.$$.fragment),Cs=m(),We=a("div"),y(Jt.$$.fragment),Us=m(),Et=a("p"),Is=n("Instantiate a "),Co=a("a"),Zs=n("Blip2Config"),xs=n(` (or a derived class) from a BLIP-2 vision model, Q-Former and language model
configurations.`),Rr=m(),ce=a("h2"),Fe=a("a"),Tn=a("span"),y(Ct.$$.fragment),zs=m(),Bn=a("span"),Ps=n("Blip2VisionConfig"),Xr=m(),G=a("div"),y(Ut.$$.fragment),Ws=m(),pe=a("p"),Fs=n("This is the configuration class to store the configuration of a "),Uo=a("a"),Ns=n("Blip2VisionModel"),Qs=n(`. It is used to instantiate a
BLIP-2 vision encoder according to the specified arguments, defining the model architecture. Instantiating a
configuration defaults will yield a similar configuration to that of the BLIP-2
`),It=a("a"),Gs=n("Salesforce/blip2-opt-2.7b"),qs=n(" architecture."),Vs=m(),me=a("p"),Ss=n("Configuration objects inherit from "),Io=a("a"),As=n("PretrainedConfig"),Rs=n(` and can be used to control the model outputs. Read the
documentation from `),Zo=a("a"),Xs=n("PretrainedConfig"),Ls=n(" for more information."),Ds=m(),y(Ne.$$.fragment),Lr=m(),fe=a("h2"),Qe=a("a"),$n=a("span"),y(Zt.$$.fragment),Ys=m(),kn=a("span"),Os=n("Blip2QFormerConfig"),Dr=m(),q=a("div"),y(xt.$$.fragment),Hs=m(),V=a("p"),Ks=n("This is the configuration class to store the configuration of a "),xo=a("a"),el=n("Blip2QFormerModel"),tl=n(`. It is used to instantiate a
BLIP-2 Querying Transformer (Q-Former) 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 BLIP-2
`),zt=a("a"),ol=n("Salesforce/blip2-opt-2.7b"),nl=n(` architecture. Configuration objects
inherit from `),zo=a("a"),rl=n("PretrainedConfig"),al=n(` and can be used to control the model outputs. Read the documentation from
`),Po=a("a"),sl=n("PretrainedConfig"),ll=n(" for more information."),il=m(),he=a("p"),dl=n("Note that "),Wo=a("a"),cl=n("Blip2QFormerModel"),pl=n(" is very similar to "),Fo=a("a"),ml=n("BertLMHeadModel"),fl=n(" with interleaved cross-attention."),hl=m(),y(Ge.$$.fragment),Yr=m(),ue=a("h2"),qe=a("a"),jn=a("span"),y(Pt.$$.fragment),ul=m(),Jn=a("span"),gl=n("Blip2Processor"),Or=m(),F=a("div"),y(Wt.$$.fragment),_l=m(),En=a("p"),bl=n("Constructs a BLIP-2 processor which wraps a BLIP image processor and an OPT/T5 tokenizer into a single processor."),vl=m(),N=a("p"),No=a("a"),yl=n("BlipProcessor"),Ml=n(" offers all the functionalities of "),Qo=a("a"),wl=n("BlipImageProcessor"),Tl=n(" and "),Go=a("a"),Bl=n("AutoTokenizer"),$l=n(`. See the docstring
of `),Cn=a("code"),kl=n("__call__()"),jl=n(" and "),qo=a("a"),Jl=n("decode()"),El=n(" for more information."),Cl=m(),Ve=a("div"),y(Ft.$$.fragment),Ul=m(),Nt=a("p"),Il=n("This method forwards all its arguments to PreTrainedTokenizer\u2019s "),Vo=a("a"),Zl=n("batch_decode()"),xl=n(`. Please
refer to the docstring of this method for more information.`),zl=m(),Se=a("div"),y(Qt.$$.fragment),Pl=m(),Gt=a("p"),Wl=n("This method forwards all its arguments to PreTrainedTokenizer\u2019s "),So=a("a"),Fl=n("decode()"),Nl=n(`. Please refer
to the docstring of this method for more information.`),Hr=m(),ge=a("h2"),Ae=a("a"),Un=a("span"),y(qt.$$.fragment),Ql=m(),In=a("span"),Gl=n("Blip2VisionModel"),Kr=m(),_e=a("div"),y(Vt.$$.fragment),ql=m(),te=a("div"),y(St.$$.fragment),Vl=m(),be=a("p"),Sl=n("The "),Ao=a("a"),Al=n("Blip2VisionModel"),Rl=n(" forward method, overrides the "),Zn=a("code"),Xl=n("__call__"),Ll=n(" special method."),Dl=m(),y(Re.$$.fragment),ea=m(),ve=a("h2"),Xe=a("a"),xn=a("span"),y(At.$$.fragment),Yl=m(),zn=a("span"),Ol=n("Blip2QFormerModel"),ta=m(),D=a("div"),y(Rt.$$.fragment),Hl=m(),Pn=a("p"),Kl=n("Querying Transformer (Q-Former), used in BLIP-2."),ei=m(),oe=a("div"),y(Xt.$$.fragment),ti=m(),U=a("p"),oi=n("encoder_hidden_states  ("),Wn=a("code"),ni=n("torch.FloatTensor"),ri=n(" of shape "),Fn=a("code"),ai=n("(batch_size, sequence_length, hidden_size)"),si=n(", "),Nn=a("code"),li=n("optional"),ii=n(`):
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if
the model is configured as a decoder.
encoder_attention_mask (`),Qn=a("code"),di=n("torch.FloatTensor"),ci=n(" of shape "),Gn=a("code"),pi=n("(batch_size, sequence_length)"),mi=n(", "),qn=a("code"),fi=n("optional"),hi=n(`):
Mask to avoid performing attention on the padding token indices of the encoder input. This mask is used in
the cross-attention if the model is configured as a decoder. Mask values selected in `),Vn=a("code"),ui=n("[0, 1]"),gi=n(":"),_i=m(),Lt=a("ul"),Dt=a("li"),bi=n("1 for tokens that are "),Sn=a("strong"),vi=n("not masked"),yi=n(","),Mi=m(),k=a("li"),wi=n("0 for tokens that are "),An=a("strong"),Ti=n("masked"),Bi=n(`.
past_key_values (`),Rn=a("code"),$i=n("tuple(tuple(torch.FloatTensor))"),ki=n(" of length "),Xn=a("code"),ji=n("config.n_layers"),Ji=n(` with each tuple having 4 tensors of:
shape `),Ln=a("code"),Ei=n("(batch_size, num_heads, sequence_length - 1, embed_size_per_head)"),Ci=n(`): Contains precomputed key and
value hidden states of the attention blocks. Can be used to speed up decoding. If `),Dn=a("code"),Ui=n("past_key_values"),Ii=n(` are
used, the user can optionally input only the last `),Yn=a("code"),Zi=n("decoder_input_ids"),xi=n(` (those that don\u2019t have their past key
value states given to this model) of shape `),On=a("code"),zi=n("(batch_size, 1)"),Pi=n(" instead of all "),Hn=a("code"),Wi=n("decoder_input_ids"),Fi=n(` of shape
`),Kn=a("code"),Ni=n("(batch_size, sequence_length)"),Qi=n(`.
use_cache (`),er=a("code"),Gi=n("bool"),qi=n(", "),tr=a("code"),Vi=n("optional"),Si=n(`):
If set to `),or=a("code"),Ai=n("True"),Ri=n(", "),nr=a("code"),Xi=n("past_key_values"),Li=n(` key value states are returned and can be used to speed up decoding (see
`),rr=a("code"),Di=n("past_key_values"),Yi=n(")."),oa=m(),ye=a("h2"),Le=a("a"),ar=a("span"),y(Yt.$$.fragment),Oi=m(),sr=a("span"),Hi=n("Blip2Model"),na=m(),C=a("div"),y(Ot.$$.fragment),Ki=m(),lr=a("p"),ed=n(`BLIP-2 Model for generating text and image features. The model consists of a vision encoder, Querying Transformer
(Q-Former) and a language model.`),td=m(),Ht=a("p"),od=n("This model inherits from "),Ro=a("a"),nd=n("PreTrainedModel"),rd=n(`. 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.)`),ad=m(),Kt=a("p"),sd=n("This model is also a PyTorch "),eo=a("a"),ld=n("torch.nn.Module"),id=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),dd=m(),S=a("div"),y(to.$$.fragment),cd=m(),Me=a("p"),pd=n("The "),Xo=a("a"),md=n("Blip2Model"),fd=n(" forward method, overrides the "),ir=a("code"),hd=n("__call__"),ud=n(" special method."),gd=m(),y(De.$$.fragment),_d=m(),y(Ye.$$.fragment),bd=m(),A=a("div"),y(oo.$$.fragment),vd=m(),we=a("p"),yd=n("The "),Lo=a("a"),Md=n("Blip2Model"),wd=n(" forward method, overrides the "),dr=a("code"),Td=n("__call__"),Bd=n(" special method."),$d=m(),y(Oe.$$.fragment),kd=m(),y(He.$$.fragment),jd=m(),R=a("div"),y(no.$$.fragment),Jd=m(),Te=a("p"),Ed=n("The "),Do=a("a"),Cd=n("Blip2Model"),Ud=n(" forward method, overrides the "),cr=a("code"),Id=n("__call__"),Zd=n(" special method."),xd=m(),y(Ke.$$.fragment),zd=m(),y(et.$$.fragment),Pd=m(),X=a("div"),y(ro.$$.fragment),Wd=m(),Be=a("p"),Fd=n("The "),Yo=a("a"),Nd=n("Blip2Model"),Qd=n(" forward method, overrides the "),pr=a("code"),Gd=n("__call__"),qd=n(" special method."),Vd=m(),y(tt.$$.fragment),Sd=m(),y(ot.$$.fragment),ra=m(),$e=a("h2"),nt=a("a"),mr=a("span"),y(ao.$$.fragment),Ad=m(),fr=a("span"),Rd=n("Blip2ForConditionalGeneration"),aa=m(),I=a("div"),y(so.$$.fragment),Xd=m(),hr=a("p"),Ld=n(`BLIP-2 Model for generating text given an image and an optional text prompt. The model consists of a vision
encoder, Querying Transformer (Q-Former) and a language model.`),Dd=m(),lo=a("p"),Yd=n("One can optionally pass "),ur=a("code"),Od=n("input_ids"),Hd=n(` to the model, which serve as a text prompt, to make the language model continue
the prompt. Otherwise, the language model starts generating text from the [BOS] (beginning-of-sequence) token.`),Kd=m(),io=a("p"),ec=n("This model inherits from "),Oo=a("a"),tc=n("PreTrainedModel"),oc=n(`. 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.)`),nc=m(),co=a("p"),rc=n("This model is also a PyTorch "),po=a("a"),ac=n("torch.nn.Module"),sc=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),lc=m(),x=a("div"),y(mo.$$.fragment),ic=m(),ke=a("p"),dc=n("The "),Ho=a("a"),cc=n("Blip2ForConditionalGeneration"),pc=n(" forward method, overrides the "),gr=a("code"),mc=n("__call__"),fc=n(" special method."),hc=m(),y(rt.$$.fragment),uc=m(),_r=a("p"),gc=n("Examples:"),_c=m(),y(at.$$.fragment),bc=m(),y(st.$$.fragment),vc=m(),lt=a("div"),y(fo.$$.fragment),yc=m(),ho=a("p"),Mc=n("Overrides "),br=a("code"),wc=n("generate"),Tc=n(" function to be able to use the model as a conditional generator."),this.h()},l(t){const u=$m('[data-svelte="svelte-1phssyn"]',document.head);d=s(u,"META",{name:!0,content:!0}),u.forEach(o),v=f(t),g=s(t,"H1",{class:!0});var uo=l(g);h=s(uo,"A",{id:!0,class:!0,href:!0});var vr=l(h);b=s(vr,"SPAN",{});var yr=l(b);M(i.$$.fragment,yr),yr.forEach(o),vr.forEach(o),p=f(uo),E=s(uo,"SPAN",{});var Mr=l(E);Pa=r(Mr,"BLIP-2"),Mr.forEach(o),uo.forEach(o),Ur=f(t),se=s(t,"H2",{class:!0});var go=l(se);Ue=s(go,"A",{id:!0,class:!0,href:!0});var wr=l(Ue);un=s(wr,"SPAN",{});var Tr=l(un);M(ht.$$.fragment,Tr),Tr.forEach(o),wr.forEach(o),Wa=f(go),gn=s(go,"SPAN",{});var Br=l(gn);Fa=r(Br,"Overview"),Br.forEach(o),go.forEach(o),Ir=f(t),H=s(t,"P",{});var je=l(H);Na=r(je,"The BLIP-2 model was proposed in "),ut=s(je,"A",{href:!0,rel:!0});var $r=l(ut);Qa=r($r,"BLIP-2: Bootstrapping Language-Image Pre-training with Frozen Image Encoders and Large Language Models"),$r.forEach(o),Ga=r(je,` by
Junnan Li, Dongxu Li, Silvio Savarese, Steven Hoi. BLIP-2 leverages frozen pre-trained image encoders and large language models (LLMs) by training a lightweight, 12-layer Transformer
encoder in between them, achieving state-of-the-art performance on various vision-language tasks. Most notably, BLIP-2 improves upon `),gt=s(je,"A",{href:!0,rel:!0});var kr=l(gt);qa=r(kr,"Flamingo"),kr.forEach(o),Va=r(je,`, an 80 billion parameter model, by 8.7%
on zero-shot VQAv2 with 54x fewer trainable parameters.`),je.forEach(o),Zr=f(t),bo=s(t,"P",{});var jr=l(bo);Sa=r(jr,"The abstract from the paper is the following:"),jr.forEach(o),xr=f(t),vo=s(t,"P",{});var Jr=l(vo);_n=s(Jr,"EM",{});var Er=l(_n);Aa=r(Er,"The cost of vision-and-language pre-training has become increasingly prohibitive due to end-to-end training of large-scale models. This paper proposes BLIP-2, a generic and efficient pre-training strategy that bootstraps vision-language pre-training from off-the-shelf frozen pre-trained image encoders and frozen large language models. BLIP-2 bridges the modality gap with a lightweight Querying Transformer, which is pre-trained in two stages. The first stage bootstraps vision-language representation learning from a frozen image encoder. The second stage bootstraps vision-to-language generative learning from a frozen language model. BLIP-2 achieves state-of-the-art performance on various vision-language tasks, despite having significantly fewer trainable parameters than existing methods. For example, our model outperforms Flamingo80B by 8.7% on zero-shot VQAv2 with 54x fewer trainable parameters. We also demonstrate the model\u2019s emerging capabilities of zero-shot image-to-text generation that can follow natural language instructions."),Er.forEach(o),Jr.forEach(o),zr=f(t),yo=s(t,"P",{});var Cr=l(yo);Ra=r(Cr,"Tips:"),Cr.forEach(o),Pr=f(t),Ie=s(t,"UL",{});var la=l(Ie);_t=s(la,"LI",{});var ia=l(_t);Xa=r(ia,"BLIP-2 can be used for conditional text generation given an image and an optional text prompt. At inference time, it\u2019s recommended to use the "),bn=s(ia,"CODE",{});var kc=l(bn);La=r(kc,"generate"),kc.forEach(o),Da=r(ia," method."),ia.forEach(o),Ya=f(la),bt=s(la,"LI",{});var da=l(bt);Oa=r(da,"One can use "),Mo=s(da,"A",{href:!0});var jc=l(Mo);Ha=r(jc,"Blip2Processor"),jc.forEach(o),Ka=r(da," to prepare images for the model, and decode the predicted tokens ID\u2019s back to text."),da.forEach(o),la.forEach(o),Wr=f(t),Ze=s(t,"IMG",{src:!0,alt:!0,width:!0}),Fr=f(t),vt=s(t,"SMALL",{});var Bc=l(vt);es=r(Bc,"BLIP-2 architecture. Taken from the "),wo=s(Bc,"A",{href:!0});var Jc=l(wo);ts=r(Jc,"original paper."),Jc.forEach(o),Bc.forEach(o),Nr=f(t),K=s(t,"P",{});var Ko=l(K);os=r(Ko,"This model was contributed by "),yt=s(Ko,"A",{href:!0,rel:!0});var Ec=l(yt);ns=r(Ec,"nielsr"),Ec.forEach(o),rs=r(Ko,`.
The original code can be found `),Mt=s(Ko,"A",{href:!0,rel:!0});var Cc=l(Mt);as=r(Cc,"here"),Cc.forEach(o),ss=r(Ko,"."),Ko.forEach(o),Qr=f(t),le=s(t,"H2",{class:!0});var ca=l(le);xe=s(ca,"A",{id:!0,class:!0,href:!0});var Uc=l(xe);vn=s(Uc,"SPAN",{});var Ic=l(vn);M(wt.$$.fragment,Ic),Ic.forEach(o),Uc.forEach(o),ls=f(ca),yn=s(ca,"SPAN",{});var Zc=l(yn);is=r(Zc,"Resources"),Zc.forEach(o),ca.forEach(o),Gr=f(t),To=s(t,"P",{});var xc=l(To);ds=r(xc,"A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started with BLIP-2."),xc.forEach(o),qr=f(t),Bo=s(t,"UL",{});var zc=l(Bo);Tt=s(zc,"LI",{});var pa=l(Tt);cs=r(pa,"Demo notebooks for BLIP-2 for image captioning, visual question answering (VQA) and chat-like conversations can be found "),Bt=s(pa,"A",{href:!0,rel:!0});var Pc=l(Bt);ps=r(Pc,"here"),Pc.forEach(o),ms=r(pa,"."),pa.forEach(o),zc.forEach(o),Vr=f(t),$o=s(t,"P",{});var Wc=l($o);fs=r(Wc,"If you\u2019re interested in submitting a resource to be included here, please feel free to open a Pull Request and we\u2019ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource."),Wc.forEach(o),Sr=f(t),ie=s(t,"H2",{class:!0});var ma=l(ie);ze=s(ma,"A",{id:!0,class:!0,href:!0});var Fc=l(ze);Mn=s(Fc,"SPAN",{});var Nc=l(Mn);M($t.$$.fragment,Nc),Nc.forEach(o),Fc.forEach(o),hs=f(ma),wn=s(ma,"SPAN",{});var Qc=l(wn);us=r(Qc,"Blip2Config"),Qc.forEach(o),ma.forEach(o),Ar=f(t),W=s(t,"DIV",{class:!0});var ne=l(W);M(kt.$$.fragment,ne),gs=f(ne),ee=s(ne,"P",{});var _o=l(ee);ko=s(_o,"A",{href:!0});var Gc=l(ko);_s=r(Gc,"Blip2Config"),Gc.forEach(o),bs=r(_o," is the configuration class to store the configuration of a "),jo=s(_o,"A",{href:!0});var qc=l(jo);vs=r(qc,"Blip2ForConditionalGeneration"),qc.forEach(o),ys=r(_o,`. It is
used to instantiate a BLIP-2 model according to the specified arguments, defining the vision model, Q-Former model
and language model configs. Instantiating a configuration with the defaults will yield a similar configuration to
that of the BLIP-2 `),jt=s(_o,"A",{href:!0,rel:!0});var Vc=l(jt);Ms=r(Vc,"Salesforce/blip2-opt-2.7b"),Vc.forEach(o),ws=r(_o," architecture."),_o.forEach(o),Ts=f(ne),de=s(ne,"P",{});var en=l(de);Bs=r(en,"Configuration objects inherit from "),Jo=s(en,"A",{href:!0});var Sc=l(Jo);$s=r(Sc,"PretrainedConfig"),Sc.forEach(o),ks=r(en,` and can be used to control the model outputs. Read the
documentation from `),Eo=s(en,"A",{href:!0});var Ac=l(Eo);js=r(Ac,"PretrainedConfig"),Ac.forEach(o),Js=r(en," for more information."),en.forEach(o),Es=f(ne),M(Pe.$$.fragment,ne),Cs=f(ne),We=s(ne,"DIV",{class:!0});var fa=l(We);M(Jt.$$.fragment,fa),Us=f(fa),Et=s(fa,"P",{});var ha=l(Et);Is=r(ha,"Instantiate a "),Co=s(ha,"A",{href:!0});var Rc=l(Co);Zs=r(Rc,"Blip2Config"),Rc.forEach(o),xs=r(ha,` (or a derived class) from a BLIP-2 vision model, Q-Former and language model
configurations.`),ha.forEach(o),fa.forEach(o),ne.forEach(o),Rr=f(t),ce=s(t,"H2",{class:!0});var ua=l(ce);Fe=s(ua,"A",{id:!0,class:!0,href:!0});var Xc=l(Fe);Tn=s(Xc,"SPAN",{});var Lc=l(Tn);M(Ct.$$.fragment,Lc),Lc.forEach(o),Xc.forEach(o),zs=f(ua),Bn=s(ua,"SPAN",{});var Dc=l(Bn);Ps=r(Dc,"Blip2VisionConfig"),Dc.forEach(o),ua.forEach(o),Xr=f(t),G=s(t,"DIV",{class:!0});var it=l(G);M(Ut.$$.fragment,it),Ws=f(it),pe=s(it,"P",{});var tn=l(pe);Fs=r(tn,"This is the configuration class to store the configuration of a "),Uo=s(tn,"A",{href:!0});var Yc=l(Uo);Ns=r(Yc,"Blip2VisionModel"),Yc.forEach(o),Qs=r(tn,`. It is used to instantiate a
BLIP-2 vision encoder according to the specified arguments, defining the model architecture. Instantiating a
configuration defaults will yield a similar configuration to that of the BLIP-2
`),It=s(tn,"A",{href:!0,rel:!0});var Oc=l(It);Gs=r(Oc,"Salesforce/blip2-opt-2.7b"),Oc.forEach(o),qs=r(tn," architecture."),tn.forEach(o),Vs=f(it),me=s(it,"P",{});var on=l(me);Ss=r(on,"Configuration objects inherit from "),Io=s(on,"A",{href:!0});var Hc=l(Io);As=r(Hc,"PretrainedConfig"),Hc.forEach(o),Rs=r(on,` and can be used to control the model outputs. Read the
documentation from `),Zo=s(on,"A",{href:!0});var Kc=l(Zo);Xs=r(Kc,"PretrainedConfig"),Kc.forEach(o),Ls=r(on," for more information."),on.forEach(o),Ds=f(it),M(Ne.$$.fragment,it),it.forEach(o),Lr=f(t),fe=s(t,"H2",{class:!0});var ga=l(fe);Qe=s(ga,"A",{id:!0,class:!0,href:!0});var ep=l(Qe);$n=s(ep,"SPAN",{});var tp=l($n);M(Zt.$$.fragment,tp),tp.forEach(o),ep.forEach(o),Ys=f(ga),kn=s(ga,"SPAN",{});var op=l(kn);Os=r(op,"Blip2QFormerConfig"),op.forEach(o),ga.forEach(o),Dr=f(t),q=s(t,"DIV",{class:!0});var dt=l(q);M(xt.$$.fragment,dt),Hs=f(dt),V=s(dt,"P",{});var re=l(V);Ks=r(re,"This is the configuration class to store the configuration of a "),xo=s(re,"A",{href:!0});var np=l(xo);el=r(np,"Blip2QFormerModel"),np.forEach(o),tl=r(re,`. It is used to instantiate a
BLIP-2 Querying Transformer (Q-Former) 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 BLIP-2
`),zt=s(re,"A",{href:!0,rel:!0});var rp=l(zt);ol=r(rp,"Salesforce/blip2-opt-2.7b"),rp.forEach(o),nl=r(re,` architecture. Configuration objects
inherit from `),zo=s(re,"A",{href:!0});var ap=l(zo);rl=r(ap,"PretrainedConfig"),ap.forEach(o),al=r(re,` and can be used to control the model outputs. Read the documentation from
`),Po=s(re,"A",{href:!0});var sp=l(Po);sl=r(sp,"PretrainedConfig"),sp.forEach(o),ll=r(re," for more information."),re.forEach(o),il=f(dt),he=s(dt,"P",{});var nn=l(he);dl=r(nn,"Note that "),Wo=s(nn,"A",{href:!0});var lp=l(Wo);cl=r(lp,"Blip2QFormerModel"),lp.forEach(o),pl=r(nn," is very similar to "),Fo=s(nn,"A",{href:!0});var ip=l(Fo);ml=r(ip,"BertLMHeadModel"),ip.forEach(o),fl=r(nn," with interleaved cross-attention."),nn.forEach(o),hl=f(dt),M(Ge.$$.fragment,dt),dt.forEach(o),Yr=f(t),ue=s(t,"H2",{class:!0});var _a=l(ue);qe=s(_a,"A",{id:!0,class:!0,href:!0});var dp=l(qe);jn=s(dp,"SPAN",{});var cp=l(jn);M(Pt.$$.fragment,cp),cp.forEach(o),dp.forEach(o),ul=f(_a),Jn=s(_a,"SPAN",{});var pp=l(Jn);gl=r(pp,"Blip2Processor"),pp.forEach(o),_a.forEach(o),Or=f(t),F=s(t,"DIV",{class:!0});var ae=l(F);M(Wt.$$.fragment,ae),_l=f(ae),En=s(ae,"P",{});var mp=l(En);bl=r(mp,"Constructs a BLIP-2 processor which wraps a BLIP image processor and an OPT/T5 tokenizer into a single processor."),mp.forEach(o),vl=f(ae),N=s(ae,"P",{});var Y=l(N);No=s(Y,"A",{href:!0});var fp=l(No);yl=r(fp,"BlipProcessor"),fp.forEach(o),Ml=r(Y," offers all the functionalities of "),Qo=s(Y,"A",{href:!0});var hp=l(Qo);wl=r(hp,"BlipImageProcessor"),hp.forEach(o),Tl=r(Y," and "),Go=s(Y,"A",{href:!0});var up=l(Go);Bl=r(up,"AutoTokenizer"),up.forEach(o),$l=r(Y,`. See the docstring
of `),Cn=s(Y,"CODE",{});var gp=l(Cn);kl=r(gp,"__call__()"),gp.forEach(o),jl=r(Y," and "),qo=s(Y,"A",{href:!0});var _p=l(qo);Jl=r(_p,"decode()"),_p.forEach(o),El=r(Y," for more information."),Y.forEach(o),Cl=f(ae),Ve=s(ae,"DIV",{class:!0});var ba=l(Ve);M(Ft.$$.fragment,ba),Ul=f(ba),Nt=s(ba,"P",{});var va=l(Nt);Il=r(va,"This method forwards all its arguments to PreTrainedTokenizer\u2019s "),Vo=s(va,"A",{href:!0});var bp=l(Vo);Zl=r(bp,"batch_decode()"),bp.forEach(o),xl=r(va,`. Please
refer to the docstring of this method for more information.`),va.forEach(o),ba.forEach(o),zl=f(ae),Se=s(ae,"DIV",{class:!0});var ya=l(Se);M(Qt.$$.fragment,ya),Pl=f(ya),Gt=s(ya,"P",{});var Ma=l(Gt);Wl=r(Ma,"This method forwards all its arguments to PreTrainedTokenizer\u2019s "),So=s(Ma,"A",{href:!0});var vp=l(So);Fl=r(vp,"decode()"),vp.forEach(o),Nl=r(Ma,`. Please refer
to the docstring of this method for more information.`),Ma.forEach(o),ya.forEach(o),ae.forEach(o),Hr=f(t),ge=s(t,"H2",{class:!0});var wa=l(ge);Ae=s(wa,"A",{id:!0,class:!0,href:!0});var yp=l(Ae);Un=s(yp,"SPAN",{});var Mp=l(Un);M(qt.$$.fragment,Mp),Mp.forEach(o),yp.forEach(o),Ql=f(wa),In=s(wa,"SPAN",{});var wp=l(In);Gl=r(wp,"Blip2VisionModel"),wp.forEach(o),wa.forEach(o),Kr=f(t),_e=s(t,"DIV",{class:!0});var Ta=l(_e);M(Vt.$$.fragment,Ta),ql=f(Ta),te=s(Ta,"DIV",{class:!0});var rn=l(te);M(St.$$.fragment,rn),Vl=f(rn),be=s(rn,"P",{});var an=l(be);Sl=r(an,"The "),Ao=s(an,"A",{href:!0});var Tp=l(Ao);Al=r(Tp,"Blip2VisionModel"),Tp.forEach(o),Rl=r(an," forward method, overrides the "),Zn=s(an,"CODE",{});var Bp=l(Zn);Xl=r(Bp,"__call__"),Bp.forEach(o),Ll=r(an," special method."),an.forEach(o),Dl=f(rn),M(Re.$$.fragment,rn),rn.forEach(o),Ta.forEach(o),ea=f(t),ve=s(t,"H2",{class:!0});var Ba=l(ve);Xe=s(Ba,"A",{id:!0,class:!0,href:!0});var $p=l(Xe);xn=s($p,"SPAN",{});var kp=l(xn);M(At.$$.fragment,kp),kp.forEach(o),$p.forEach(o),Yl=f(Ba),zn=s(Ba,"SPAN",{});var jp=l(zn);Ol=r(jp,"Blip2QFormerModel"),jp.forEach(o),Ba.forEach(o),ta=f(t),D=s(t,"DIV",{class:!0});var sn=l(D);M(Rt.$$.fragment,sn),Hl=f(sn),Pn=s(sn,"P",{});var Jp=l(Pn);Kl=r(Jp,"Querying Transformer (Q-Former), used in BLIP-2."),Jp.forEach(o),ei=f(sn),oe=s(sn,"DIV",{class:!0});var ln=l(oe);M(Xt.$$.fragment,ln),ti=f(ln),U=s(ln,"P",{});var z=l(U);oi=r(z,"encoder_hidden_states  ("),Wn=s(z,"CODE",{});var Ep=l(Wn);ni=r(Ep,"torch.FloatTensor"),Ep.forEach(o),ri=r(z," of shape "),Fn=s(z,"CODE",{});var Cp=l(Fn);ai=r(Cp,"(batch_size, sequence_length, hidden_size)"),Cp.forEach(o),si=r(z,", "),Nn=s(z,"CODE",{});var Up=l(Nn);li=r(Up,"optional"),Up.forEach(o),ii=r(z,`):
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if
the model is configured as a decoder.
encoder_attention_mask (`),Qn=s(z,"CODE",{});var Ip=l(Qn);di=r(Ip,"torch.FloatTensor"),Ip.forEach(o),ci=r(z," of shape "),Gn=s(z,"CODE",{});var Zp=l(Gn);pi=r(Zp,"(batch_size, sequence_length)"),Zp.forEach(o),mi=r(z,", "),qn=s(z,"CODE",{});var xp=l(qn);fi=r(xp,"optional"),xp.forEach(o),hi=r(z,`):
Mask to avoid performing attention on the padding token indices of the encoder input. This mask is used in
the cross-attention if the model is configured as a decoder. Mask values selected in `),Vn=s(z,"CODE",{});var zp=l(Vn);ui=r(zp,"[0, 1]"),zp.forEach(o),gi=r(z,":"),z.forEach(o),_i=f(ln),Lt=s(ln,"UL",{});var $a=l(Lt);Dt=s($a,"LI",{});var ka=l(Dt);bi=r(ka,"1 for tokens that are "),Sn=s(ka,"STRONG",{});var Pp=l(Sn);vi=r(Pp,"not masked"),Pp.forEach(o),yi=r(ka,","),ka.forEach(o),Mi=f($a),k=s($a,"LI",{});var J=l(k);wi=r(J,"0 for tokens that are "),An=s(J,"STRONG",{});var Wp=l(An);Ti=r(Wp,"masked"),Wp.forEach(o),Bi=r(J,`.
past_key_values (`),Rn=s(J,"CODE",{});var Fp=l(Rn);$i=r(Fp,"tuple(tuple(torch.FloatTensor))"),Fp.forEach(o),ki=r(J," of length "),Xn=s(J,"CODE",{});var Np=l(Xn);ji=r(Np,"config.n_layers"),Np.forEach(o),Ji=r(J,` with each tuple having 4 tensors of:
shape `),Ln=s(J,"CODE",{});var Qp=l(Ln);Ei=r(Qp,"(batch_size, num_heads, sequence_length - 1, embed_size_per_head)"),Qp.forEach(o),Ci=r(J,`): Contains precomputed key and
value hidden states of the attention blocks. Can be used to speed up decoding. If `),Dn=s(J,"CODE",{});var Gp=l(Dn);Ui=r(Gp,"past_key_values"),Gp.forEach(o),Ii=r(J,` are
used, the user can optionally input only the last `),Yn=s(J,"CODE",{});var qp=l(Yn);Zi=r(qp,"decoder_input_ids"),qp.forEach(o),xi=r(J,` (those that don\u2019t have their past key
value states given to this model) of shape `),On=s(J,"CODE",{});var Vp=l(On);zi=r(Vp,"(batch_size, 1)"),Vp.forEach(o),Pi=r(J," instead of all "),Hn=s(J,"CODE",{});var Sp=l(Hn);Wi=r(Sp,"decoder_input_ids"),Sp.forEach(o),Fi=r(J,` of shape
`),Kn=s(J,"CODE",{});var Ap=l(Kn);Ni=r(Ap,"(batch_size, sequence_length)"),Ap.forEach(o),Qi=r(J,`.
use_cache (`),er=s(J,"CODE",{});var Rp=l(er);Gi=r(Rp,"bool"),Rp.forEach(o),qi=r(J,", "),tr=s(J,"CODE",{});var Xp=l(tr);Vi=r(Xp,"optional"),Xp.forEach(o),Si=r(J,`):
If set to `),or=s(J,"CODE",{});var Lp=l(or);Ai=r(Lp,"True"),Lp.forEach(o),Ri=r(J,", "),nr=s(J,"CODE",{});var Dp=l(nr);Xi=r(Dp,"past_key_values"),Dp.forEach(o),Li=r(J,` key value states are returned and can be used to speed up decoding (see
`),rr=s(J,"CODE",{});var Yp=l(rr);Di=r(Yp,"past_key_values"),Yp.forEach(o),Yi=r(J,")."),J.forEach(o),$a.forEach(o),ln.forEach(o),sn.forEach(o),oa=f(t),ye=s(t,"H2",{class:!0});var ja=l(ye);Le=s(ja,"A",{id:!0,class:!0,href:!0});var Op=l(Le);ar=s(Op,"SPAN",{});var Hp=l(ar);M(Yt.$$.fragment,Hp),Hp.forEach(o),Op.forEach(o),Oi=f(ja),sr=s(ja,"SPAN",{});var Kp=l(sr);Hi=r(Kp,"Blip2Model"),Kp.forEach(o),ja.forEach(o),na=f(t),C=s(t,"DIV",{class:!0});var P=l(C);M(Ot.$$.fragment,P),Ki=f(P),lr=s(P,"P",{});var em=l(lr);ed=r(em,`BLIP-2 Model for generating text and image features. The model consists of a vision encoder, Querying Transformer
(Q-Former) and a language model.`),em.forEach(o),td=f(P),Ht=s(P,"P",{});var Ja=l(Ht);od=r(Ja,"This model inherits from "),Ro=s(Ja,"A",{href:!0});var tm=l(Ro);nd=r(tm,"PreTrainedModel"),tm.forEach(o),rd=r(Ja,`. 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.)`),Ja.forEach(o),ad=f(P),Kt=s(P,"P",{});var Ea=l(Kt);sd=r(Ea,"This model is also a PyTorch "),eo=s(Ea,"A",{href:!0,rel:!0});var om=l(eo);ld=r(om,"torch.nn.Module"),om.forEach(o),id=r(Ea,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ea.forEach(o),dd=f(P),S=s(P,"DIV",{class:!0});var ct=l(S);M(to.$$.fragment,ct),cd=f(ct),Me=s(ct,"P",{});var dn=l(Me);pd=r(dn,"The "),Xo=s(dn,"A",{href:!0});var nm=l(Xo);md=r(nm,"Blip2Model"),nm.forEach(o),fd=r(dn," forward method, overrides the "),ir=s(dn,"CODE",{});var rm=l(ir);hd=r(rm,"__call__"),rm.forEach(o),ud=r(dn," special method."),dn.forEach(o),gd=f(ct),M(De.$$.fragment,ct),_d=f(ct),M(Ye.$$.fragment,ct),ct.forEach(o),bd=f(P),A=s(P,"DIV",{class:!0});var pt=l(A);M(oo.$$.fragment,pt),vd=f(pt),we=s(pt,"P",{});var cn=l(we);yd=r(cn,"The "),Lo=s(cn,"A",{href:!0});var am=l(Lo);Md=r(am,"Blip2Model"),am.forEach(o),wd=r(cn," forward method, overrides the "),dr=s(cn,"CODE",{});var sm=l(dr);Td=r(sm,"__call__"),sm.forEach(o),Bd=r(cn," special method."),cn.forEach(o),$d=f(pt),M(Oe.$$.fragment,pt),kd=f(pt),M(He.$$.fragment,pt),pt.forEach(o),jd=f(P),R=s(P,"DIV",{class:!0});var mt=l(R);M(no.$$.fragment,mt),Jd=f(mt),Te=s(mt,"P",{});var pn=l(Te);Ed=r(pn,"The "),Do=s(pn,"A",{href:!0});var lm=l(Do);Cd=r(lm,"Blip2Model"),lm.forEach(o),Ud=r(pn," forward method, overrides the "),cr=s(pn,"CODE",{});var im=l(cr);Id=r(im,"__call__"),im.forEach(o),Zd=r(pn," special method."),pn.forEach(o),xd=f(mt),M(Ke.$$.fragment,mt),zd=f(mt),M(et.$$.fragment,mt),mt.forEach(o),Pd=f(P),X=s(P,"DIV",{class:!0});var ft=l(X);M(ro.$$.fragment,ft),Wd=f(ft),Be=s(ft,"P",{});var mn=l(Be);Fd=r(mn,"The "),Yo=s(mn,"A",{href:!0});var dm=l(Yo);Nd=r(dm,"Blip2Model"),dm.forEach(o),Qd=r(mn," forward method, overrides the "),pr=s(mn,"CODE",{});var cm=l(pr);Gd=r(cm,"__call__"),cm.forEach(o),qd=r(mn," special method."),mn.forEach(o),Vd=f(ft),M(tt.$$.fragment,ft),Sd=f(ft),M(ot.$$.fragment,ft),ft.forEach(o),P.forEach(o),ra=f(t),$e=s(t,"H2",{class:!0});var Ca=l($e);nt=s(Ca,"A",{id:!0,class:!0,href:!0});var pm=l(nt);mr=s(pm,"SPAN",{});var mm=l(mr);M(ao.$$.fragment,mm),mm.forEach(o),pm.forEach(o),Ad=f(Ca),fr=s(Ca,"SPAN",{});var fm=l(fr);Rd=r(fm,"Blip2ForConditionalGeneration"),fm.forEach(o),Ca.forEach(o),aa=f(t),I=s(t,"DIV",{class:!0});var Q=l(I);M(so.$$.fragment,Q),Xd=f(Q),hr=s(Q,"P",{});var hm=l(hr);Ld=r(hm,`BLIP-2 Model for generating text given an image and an optional text prompt. The model consists of a vision
encoder, Querying Transformer (Q-Former) and a language model.`),hm.forEach(o),Dd=f(Q),lo=s(Q,"P",{});var Ua=l(lo);Yd=r(Ua,"One can optionally pass "),ur=s(Ua,"CODE",{});var um=l(ur);Od=r(um,"input_ids"),um.forEach(o),Hd=r(Ua,` to the model, which serve as a text prompt, to make the language model continue
the prompt. Otherwise, the language model starts generating text from the [BOS] (beginning-of-sequence) token.`),Ua.forEach(o),Kd=f(Q),io=s(Q,"P",{});var Ia=l(io);ec=r(Ia,"This model inherits from "),Oo=s(Ia,"A",{href:!0});var gm=l(Oo);tc=r(gm,"PreTrainedModel"),gm.forEach(o),oc=r(Ia,`. 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.)`),Ia.forEach(o),nc=f(Q),co=s(Q,"P",{});var Za=l(co);rc=r(Za,"This model is also a PyTorch "),po=s(Za,"A",{href:!0,rel:!0});var _m=l(po);ac=r(_m,"torch.nn.Module"),_m.forEach(o),sc=r(Za,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Za.forEach(o),lc=f(Q),x=s(Q,"DIV",{class:!0});var L=l(x);M(mo.$$.fragment,L),ic=f(L),ke=s(L,"P",{});var fn=l(ke);dc=r(fn,"The "),Ho=s(fn,"A",{href:!0});var bm=l(Ho);cc=r(bm,"Blip2ForConditionalGeneration"),bm.forEach(o),pc=r(fn," forward method, overrides the "),gr=s(fn,"CODE",{});var vm=l(gr);mc=r(vm,"__call__"),vm.forEach(o),fc=r(fn," special method."),fn.forEach(o),hc=f(L),M(rt.$$.fragment,L),uc=f(L),_r=s(L,"P",{});var ym=l(_r);gc=r(ym,"Examples:"),ym.forEach(o),_c=f(L),M(at.$$.fragment,L),bc=f(L),M(st.$$.fragment,L),L.forEach(o),vc=f(Q),lt=s(Q,"DIV",{class:!0});var xa=l(lt);M(fo.$$.fragment,xa),yc=f(xa),ho=s(xa,"P",{});var za=l(ho);Mc=r(za,"Overrides "),br=s(za,"CODE",{});var Mm=l(br);wc=r(Mm,"generate"),Mm.forEach(o),Tc=r(za," function to be able to use the model as a conditional generator."),za.forEach(o),xa.forEach(o),Q.forEach(o),this.h()},h(){c(d,"name","hf:doc:metadata"),c(d,"content",JSON.stringify(Sm)),c(h,"id","blip2"),c(h,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(h,"href","#blip2"),c(g,"class","relative group"),c(Ue,"id","overview"),c(Ue,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Ue,"href","#overview"),c(se,"class","relative group"),c(ut,"href","https://arxiv.org/abs/2301.12597"),c(ut,"rel","nofollow"),c(gt,"href","https://arxiv.org/abs/2204.14198"),c(gt,"rel","nofollow"),c(Mo,"href","/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2Processor"),km(Ze.src,$c="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/blip2_architecture.jpg")||c(Ze,"src",$c),c(Ze,"alt","drawing"),c(Ze,"width","600"),c(wo,"href","https://arxiv.org/abs/2301.12597"),c(yt,"href","https://huggingface.co/nielsr"),c(yt,"rel","nofollow"),c(Mt,"href","https://github.com/salesforce/LAVIS/tree/5ee63d688ba4cebff63acee04adaef2dee9af207"),c(Mt,"rel","nofollow"),c(xe,"id","resources"),c(xe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(xe,"href","#resources"),c(le,"class","relative group"),c(Bt,"href","https://github.com/NielsRogge/Transformers-Tutorials/tree/master/BLIP-2"),c(Bt,"rel","nofollow"),c(ze,"id","transformers.Blip2Config"),c(ze,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(ze,"href","#transformers.Blip2Config"),c(ie,"class","relative group"),c(ko,"href","/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2Config"),c(jo,"href","/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2ForConditionalGeneration"),c(jt,"href","https://huggingface.co/Salesforce/blip2-opt-2.7b"),c(jt,"rel","nofollow"),c(Jo,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),c(Eo,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),c(Co,"href","/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2Config"),c(We,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Fe,"id","transformers.Blip2VisionConfig"),c(Fe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Fe,"href","#transformers.Blip2VisionConfig"),c(ce,"class","relative group"),c(Uo,"href","/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2VisionModel"),c(It,"href","https://huggingface.co/Salesforce/blip2-opt-2.7b"),c(It,"rel","nofollow"),c(Io,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),c(Zo,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),c(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Qe,"id","transformers.Blip2QFormerConfig"),c(Qe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Qe,"href","#transformers.Blip2QFormerConfig"),c(fe,"class","relative group"),c(xo,"href","/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2QFormerModel"),c(zt,"href","https://huggingface.co/Salesforce/blip2-opt-2.7b"),c(zt,"rel","nofollow"),c(zo,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),c(Po,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),c(Wo,"href","/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2QFormerModel"),c(Fo,"href","/docs/transformers/main/en/model_doc/bert#transformers.BertLMHeadModel"),c(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(qe,"id","transformers.Blip2Processor"),c(qe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(qe,"href","#transformers.Blip2Processor"),c(ue,"class","relative group"),c(No,"href","/docs/transformers/main/en/model_doc/blip#transformers.BlipProcessor"),c(Qo,"href","/docs/transformers/main/en/model_doc/blip#transformers.BlipImageProcessor"),c(Go,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer"),c(qo,"href","/docs/transformers/main/en/model_doc/blip#transformers.BlipProcessor.decode"),c(Vo,"href","/docs/transformers/main/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.batch_decode"),c(Ve,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(So,"href","/docs/transformers/main/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.decode"),c(Se,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Ae,"id","transformers.Blip2VisionModel"),c(Ae,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Ae,"href","#transformers.Blip2VisionModel"),c(ge,"class","relative group"),c(Ao,"href","/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2VisionModel"),c(te,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(_e,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Xe,"id","transformers.Blip2QFormerModel"),c(Xe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Xe,"href","#transformers.Blip2QFormerModel"),c(ve,"class","relative group"),c(oe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Le,"id","transformers.Blip2Model"),c(Le,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Le,"href","#transformers.Blip2Model"),c(ye,"class","relative group"),c(Ro,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),c(eo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(eo,"rel","nofollow"),c(Xo,"href","/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2Model"),c(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Lo,"href","/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2Model"),c(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Do,"href","/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2Model"),c(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Yo,"href","/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2Model"),c(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(nt,"id","transformers.Blip2ForConditionalGeneration"),c(nt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(nt,"href","#transformers.Blip2ForConditionalGeneration"),c($e,"class","relative group"),c(Oo,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),c(po,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(po,"rel","nofollow"),c(Ho,"href","/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2ForConditionalGeneration"),c(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(lt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,u){e(document.head,d),_(t,v,u),_(t,g,u),e(g,h),e(h,b),w(i,b,null),e(g,p),e(g,E),e(E,Pa),_(t,Ur,u),_(t,se,u),e(se,Ue),e(Ue,un),w(ht,un,null),e(se,Wa),e(se,gn),e(gn,Fa),_(t,Ir,u),_(t,H,u),e(H,Na),e(H,ut),e(ut,Qa),e(H,Ga),e(H,gt),e(gt,qa),e(H,Va),_(t,Zr,u),_(t,bo,u),e(bo,Sa),_(t,xr,u),_(t,vo,u),e(vo,_n),e(_n,Aa),_(t,zr,u),_(t,yo,u),e(yo,Ra),_(t,Pr,u),_(t,Ie,u),e(Ie,_t),e(_t,Xa),e(_t,bn),e(bn,La),e(_t,Da),e(Ie,Ya),e(Ie,bt),e(bt,Oa),e(bt,Mo),e(Mo,Ha),e(bt,Ka),_(t,Wr,u),_(t,Ze,u),_(t,Fr,u),_(t,vt,u),e(vt,es),e(vt,wo),e(wo,ts),_(t,Nr,u),_(t,K,u),e(K,os),e(K,yt),e(yt,ns),e(K,rs),e(K,Mt),e(Mt,as),e(K,ss),_(t,Qr,u),_(t,le,u),e(le,xe),e(xe,vn),w(wt,vn,null),e(le,ls),e(le,yn),e(yn,is),_(t,Gr,u),_(t,To,u),e(To,ds),_(t,qr,u),_(t,Bo,u),e(Bo,Tt),e(Tt,cs),e(Tt,Bt),e(Bt,ps),e(Tt,ms),_(t,Vr,u),_(t,$o,u),e($o,fs),_(t,Sr,u),_(t,ie,u),e(ie,ze),e(ze,Mn),w($t,Mn,null),e(ie,hs),e(ie,wn),e(wn,us),_(t,Ar,u),_(t,W,u),w(kt,W,null),e(W,gs),e(W,ee),e(ee,ko),e(ko,_s),e(ee,bs),e(ee,jo),e(jo,vs),e(ee,ys),e(ee,jt),e(jt,Ms),e(ee,ws),e(W,Ts),e(W,de),e(de,Bs),e(de,Jo),e(Jo,$s),e(de,ks),e(de,Eo),e(Eo,js),e(de,Js),e(W,Es),w(Pe,W,null),e(W,Cs),e(W,We),w(Jt,We,null),e(We,Us),e(We,Et),e(Et,Is),e(Et,Co),e(Co,Zs),e(Et,xs),_(t,Rr,u),_(t,ce,u),e(ce,Fe),e(Fe,Tn),w(Ct,Tn,null),e(ce,zs),e(ce,Bn),e(Bn,Ps),_(t,Xr,u),_(t,G,u),w(Ut,G,null),e(G,Ws),e(G,pe),e(pe,Fs),e(pe,Uo),e(Uo,Ns),e(pe,Qs),e(pe,It),e(It,Gs),e(pe,qs),e(G,Vs),e(G,me),e(me,Ss),e(me,Io),e(Io,As),e(me,Rs),e(me,Zo),e(Zo,Xs),e(me,Ls),e(G,Ds),w(Ne,G,null),_(t,Lr,u),_(t,fe,u),e(fe,Qe),e(Qe,$n),w(Zt,$n,null),e(fe,Ys),e(fe,kn),e(kn,Os),_(t,Dr,u),_(t,q,u),w(xt,q,null),e(q,Hs),e(q,V),e(V,Ks),e(V,xo),e(xo,el),e(V,tl),e(V,zt),e(zt,ol),e(V,nl),e(V,zo),e(zo,rl),e(V,al),e(V,Po),e(Po,sl),e(V,ll),e(q,il),e(q,he),e(he,dl),e(he,Wo),e(Wo,cl),e(he,pl),e(he,Fo),e(Fo,ml),e(he,fl),e(q,hl),w(Ge,q,null),_(t,Yr,u),_(t,ue,u),e(ue,qe),e(qe,jn),w(Pt,jn,null),e(ue,ul),e(ue,Jn),e(Jn,gl),_(t,Or,u),_(t,F,u),w(Wt,F,null),e(F,_l),e(F,En),e(En,bl),e(F,vl),e(F,N),e(N,No),e(No,yl),e(N,Ml),e(N,Qo),e(Qo,wl),e(N,Tl),e(N,Go),e(Go,Bl),e(N,$l),e(N,Cn),e(Cn,kl),e(N,jl),e(N,qo),e(qo,Jl),e(N,El),e(F,Cl),e(F,Ve),w(Ft,Ve,null),e(Ve,Ul),e(Ve,Nt),e(Nt,Il),e(Nt,Vo),e(Vo,Zl),e(Nt,xl),e(F,zl),e(F,Se),w(Qt,Se,null),e(Se,Pl),e(Se,Gt),e(Gt,Wl),e(Gt,So),e(So,Fl),e(Gt,Nl),_(t,Hr,u),_(t,ge,u),e(ge,Ae),e(Ae,Un),w(qt,Un,null),e(ge,Ql),e(ge,In),e(In,Gl),_(t,Kr,u),_(t,_e,u),w(Vt,_e,null),e(_e,ql),e(_e,te),w(St,te,null),e(te,Vl),e(te,be),e(be,Sl),e(be,Ao),e(Ao,Al),e(be,Rl),e(be,Zn),e(Zn,Xl),e(be,Ll),e(te,Dl),w(Re,te,null),_(t,ea,u),_(t,ve,u),e(ve,Xe),e(Xe,xn),w(At,xn,null),e(ve,Yl),e(ve,zn),e(zn,Ol),_(t,ta,u),_(t,D,u),w(Rt,D,null),e(D,Hl),e(D,Pn),e(Pn,Kl),e(D,ei),e(D,oe),w(Xt,oe,null),e(oe,ti),e(oe,U),e(U,oi),e(U,Wn),e(Wn,ni),e(U,ri),e(U,Fn),e(Fn,ai),e(U,si),e(U,Nn),e(Nn,li),e(U,ii),e(U,Qn),e(Qn,di),e(U,ci),e(U,Gn),e(Gn,pi),e(U,mi),e(U,qn),e(qn,fi),e(U,hi),e(U,Vn),e(Vn,ui),e(U,gi),e(oe,_i),e(oe,Lt),e(Lt,Dt),e(Dt,bi),e(Dt,Sn),e(Sn,vi),e(Dt,yi),e(Lt,Mi),e(Lt,k),e(k,wi),e(k,An),e(An,Ti),e(k,Bi),e(k,Rn),e(Rn,$i),e(k,ki),e(k,Xn),e(Xn,ji),e(k,Ji),e(k,Ln),e(Ln,Ei),e(k,Ci),e(k,Dn),e(Dn,Ui),e(k,Ii),e(k,Yn),e(Yn,Zi),e(k,xi),e(k,On),e(On,zi),e(k,Pi),e(k,Hn),e(Hn,Wi),e(k,Fi),e(k,Kn),e(Kn,Ni),e(k,Qi),e(k,er),e(er,Gi),e(k,qi),e(k,tr),e(tr,Vi),e(k,Si),e(k,or),e(or,Ai),e(k,Ri),e(k,nr),e(nr,Xi),e(k,Li),e(k,rr),e(rr,Di),e(k,Yi),_(t,oa,u),_(t,ye,u),e(ye,Le),e(Le,ar),w(Yt,ar,null),e(ye,Oi),e(ye,sr),e(sr,Hi),_(t,na,u),_(t,C,u),w(Ot,C,null),e(C,Ki),e(C,lr),e(lr,ed),e(C,td),e(C,Ht),e(Ht,od),e(Ht,Ro),e(Ro,nd),e(Ht,rd),e(C,ad),e(C,Kt),e(Kt,sd),e(Kt,eo),e(eo,ld),e(Kt,id),e(C,dd),e(C,S),w(to,S,null),e(S,cd),e(S,Me),e(Me,pd),e(Me,Xo),e(Xo,md),e(Me,fd),e(Me,ir),e(ir,hd),e(Me,ud),e(S,gd),w(De,S,null),e(S,_d),w(Ye,S,null),e(C,bd),e(C,A),w(oo,A,null),e(A,vd),e(A,we),e(we,yd),e(we,Lo),e(Lo,Md),e(we,wd),e(we,dr),e(dr,Td),e(we,Bd),e(A,$d),w(Oe,A,null),e(A,kd),w(He,A,null),e(C,jd),e(C,R),w(no,R,null),e(R,Jd),e(R,Te),e(Te,Ed),e(Te,Do),e(Do,Cd),e(Te,Ud),e(Te,cr),e(cr,Id),e(Te,Zd),e(R,xd),w(Ke,R,null),e(R,zd),w(et,R,null),e(C,Pd),e(C,X),w(ro,X,null),e(X,Wd),e(X,Be),e(Be,Fd),e(Be,Yo),e(Yo,Nd),e(Be,Qd),e(Be,pr),e(pr,Gd),e(Be,qd),e(X,Vd),w(tt,X,null),e(X,Sd),w(ot,X,null),_(t,ra,u),_(t,$e,u),e($e,nt),e(nt,mr),w(ao,mr,null),e($e,Ad),e($e,fr),e(fr,Rd),_(t,aa,u),_(t,I,u),w(so,I,null),e(I,Xd),e(I,hr),e(hr,Ld),e(I,Dd),e(I,lo),e(lo,Yd),e(lo,ur),e(ur,Od),e(lo,Hd),e(I,Kd),e(I,io),e(io,ec),e(io,Oo),e(Oo,tc),e(io,oc),e(I,nc),e(I,co),e(co,rc),e(co,po),e(po,ac),e(co,sc),e(I,lc),e(I,x),w(mo,x,null),e(x,ic),e(x,ke),e(ke,dc),e(ke,Ho),e(Ho,cc),e(ke,pc),e(ke,gr),e(gr,mc),e(ke,fc),e(x,hc),w(rt,x,null),e(x,uc),e(x,_r),e(_r,gc),e(x,_c),w(at,x,null),e(x,bc),w(st,x,null),e(I,vc),e(I,lt),w(fo,lt,null),e(lt,yc),e(lt,ho),e(ho,Mc),e(ho,br),e(br,wc),e(ho,Tc),sa=!0},p(t,[u]){const uo={};u&2&&(uo.$$scope={dirty:u,ctx:t}),Pe.$set(uo);const vr={};u&2&&(vr.$$scope={dirty:u,ctx:t}),Ne.$set(vr);const yr={};u&2&&(yr.$$scope={dirty:u,ctx:t}),Ge.$set(yr);const Mr={};u&2&&(Mr.$$scope={dirty:u,ctx:t}),Re.$set(Mr);const go={};u&2&&(go.$$scope={dirty:u,ctx:t}),De.$set(go);const wr={};u&2&&(wr.$$scope={dirty:u,ctx:t}),Ye.$set(wr);const Tr={};u&2&&(Tr.$$scope={dirty:u,ctx:t}),Oe.$set(Tr);const Br={};u&2&&(Br.$$scope={dirty:u,ctx:t}),He.$set(Br);const je={};u&2&&(je.$$scope={dirty:u,ctx:t}),Ke.$set(je);const $r={};u&2&&($r.$$scope={dirty:u,ctx:t}),et.$set($r);const kr={};u&2&&(kr.$$scope={dirty:u,ctx:t}),tt.$set(kr);const jr={};u&2&&(jr.$$scope={dirty:u,ctx:t}),ot.$set(jr);const Jr={};u&2&&(Jr.$$scope={dirty:u,ctx:t}),rt.$set(Jr);const Er={};u&2&&(Er.$$scope={dirty:u,ctx:t}),at.$set(Er);const Cr={};u&2&&(Cr.$$scope={dirty:u,ctx:t}),st.$set(Cr)},i(t){sa||(T(i.$$.fragment,t),T(ht.$$.fragment,t),T(wt.$$.fragment,t),T($t.$$.fragment,t),T(kt.$$.fragment,t),T(Pe.$$.fragment,t),T(Jt.$$.fragment,t),T(Ct.$$.fragment,t),T(Ut.$$.fragment,t),T(Ne.$$.fragment,t),T(Zt.$$.fragment,t),T(xt.$$.fragment,t),T(Ge.$$.fragment,t),T(Pt.$$.fragment,t),T(Wt.$$.fragment,t),T(Ft.$$.fragment,t),T(Qt.$$.fragment,t),T(qt.$$.fragment,t),T(Vt.$$.fragment,t),T(St.$$.fragment,t),T(Re.$$.fragment,t),T(At.$$.fragment,t),T(Rt.$$.fragment,t),T(Xt.$$.fragment,t),T(Yt.$$.fragment,t),T(Ot.$$.fragment,t),T(to.$$.fragment,t),T(De.$$.fragment,t),T(Ye.$$.fragment,t),T(oo.$$.fragment,t),T(Oe.$$.fragment,t),T(He.$$.fragment,t),T(no.$$.fragment,t),T(Ke.$$.fragment,t),T(et.$$.fragment,t),T(ro.$$.fragment,t),T(tt.$$.fragment,t),T(ot.$$.fragment,t),T(ao.$$.fragment,t),T(so.$$.fragment,t),T(mo.$$.fragment,t),T(rt.$$.fragment,t),T(at.$$.fragment,t),T(st.$$.fragment,t),T(fo.$$.fragment,t),sa=!0)},o(t){B(i.$$.fragment,t),B(ht.$$.fragment,t),B(wt.$$.fragment,t),B($t.$$.fragment,t),B(kt.$$.fragment,t),B(Pe.$$.fragment,t),B(Jt.$$.fragment,t),B(Ct.$$.fragment,t),B(Ut.$$.fragment,t),B(Ne.$$.fragment,t),B(Zt.$$.fragment,t),B(xt.$$.fragment,t),B(Ge.$$.fragment,t),B(Pt.$$.fragment,t),B(Wt.$$.fragment,t),B(Ft.$$.fragment,t),B(Qt.$$.fragment,t),B(qt.$$.fragment,t),B(Vt.$$.fragment,t),B(St.$$.fragment,t),B(Re.$$.fragment,t),B(At.$$.fragment,t),B(Rt.$$.fragment,t),B(Xt.$$.fragment,t),B(Yt.$$.fragment,t),B(Ot.$$.fragment,t),B(to.$$.fragment,t),B(De.$$.fragment,t),B(Ye.$$.fragment,t),B(oo.$$.fragment,t),B(Oe.$$.fragment,t),B(He.$$.fragment,t),B(no.$$.fragment,t),B(Ke.$$.fragment,t),B(et.$$.fragment,t),B(ro.$$.fragment,t),B(tt.$$.fragment,t),B(ot.$$.fragment,t),B(ao.$$.fragment,t),B(so.$$.fragment,t),B(mo.$$.fragment,t),B(rt.$$.fragment,t),B(at.$$.fragment,t),B(st.$$.fragment,t),B(fo.$$.fragment,t),sa=!1},d(t){o(d),t&&o(v),t&&o(g),$(i),t&&o(Ur),t&&o(se),$(ht),t&&o(Ir),t&&o(H),t&&o(Zr),t&&o(bo),t&&o(xr),t&&o(vo),t&&o(zr),t&&o(yo),t&&o(Pr),t&&o(Ie),t&&o(Wr),t&&o(Ze),t&&o(Fr),t&&o(vt),t&&o(Nr),t&&o(K),t&&o(Qr),t&&o(le),$(wt),t&&o(Gr),t&&o(To),t&&o(qr),t&&o(Bo),t&&o(Vr),t&&o($o),t&&o(Sr),t&&o(ie),$($t),t&&o(Ar),t&&o(W),$(kt),$(Pe),$(Jt),t&&o(Rr),t&&o(ce),$(Ct),t&&o(Xr),t&&o(G),$(Ut),$(Ne),t&&o(Lr),t&&o(fe),$(Zt),t&&o(Dr),t&&o(q),$(xt),$(Ge),t&&o(Yr),t&&o(ue),$(Pt),t&&o(Or),t&&o(F),$(Wt),$(Ft),$(Qt),t&&o(Hr),t&&o(ge),$(qt),t&&o(Kr),t&&o(_e),$(Vt),$(St),$(Re),t&&o(ea),t&&o(ve),$(At),t&&o(ta),t&&o(D),$(Rt),$(Xt),t&&o(oa),t&&o(ye),$(Yt),t&&o(na),t&&o(C),$(Ot),$(to),$(De),$(Ye),$(oo),$(Oe),$(He),$(no),$(Ke),$(et),$(ro),$(tt),$(ot),t&&o(ra),t&&o($e),$(ao),t&&o(aa),t&&o(I),$(so),$(mo),$(rt),$(at),$(st),$(fo)}}}const Sm={local:"blip2",sections:[{local:"overview",title:"Overview"},{local:"resources",title:"Resources"},{local:"transformers.Blip2Config",title:"Blip2Config"},{local:"transformers.Blip2VisionConfig",title:"Blip2VisionConfig"},{local:"transformers.Blip2QFormerConfig",title:"Blip2QFormerConfig"},{local:"transformers.Blip2Processor",title:"Blip2Processor"},{local:"transformers.Blip2VisionModel",title:"Blip2VisionModel"},{local:"transformers.Blip2QFormerModel",title:"Blip2QFormerModel"},{local:"transformers.Blip2Model",title:"Blip2Model"},{local:"transformers.Blip2ForConditionalGeneration",title:"Blip2ForConditionalGeneration"}],title:"BLIP-2"};function Am(j){return jm(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Hm extends wm{constructor(d){super();Tm(this,d,Am,Vm,Bm,{})}}export{Hm as default,Sm as metadata};
