import{S as wm,i as Tm,s as Bm,e as r,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 a,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=r("p"),v=n("Example:"),g=m(),y(h.$$.fragment)},l(i){d=s(i,"P",{});var p=l(d);v=a(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=r("p"),v=n("Example:"),g=m(),y(h.$$.fragment)},l(i){d=s(i,"P",{});var p=l(d);v=a(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=r("p"),v=n("Examples:"),g=m(),y(h.$$.fragment)},l(i){d=s(i,"P",{});var p=l(d);v=a(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=r("p"),v=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=r("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=a(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=a(E,"Module"),E.forEach(o),b=a(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=r("p"),v=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=r("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=a(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=a(E,"Module"),E.forEach(o),b=a(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=r("p"),v=n("Examples:"),g=m(),y(h.$$.fragment)},l(i){d=s(i,"P",{});var p=l(d);v=a(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=r("p"),v=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=r("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=a(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=a(E,"Module"),E.forEach(o),b=a(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=r("p"),v=n("Examples:"),g=m(),y(h.$$.fragment)},l(i){d=s(i,"P",{});var p=l(d);v=a(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=r("p"),v=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=r("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=a(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=a(E,"Module"),E.forEach(o),b=a(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 Pm(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=r("p"),v=n("Examples:"),g=m(),y(h.$$.fragment)},l(i){d=s(i,"P",{});var p=l(d);v=a(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 Wm(j){let d,v,g,h,b;return{c(){d=r("p"),v=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=r("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=a(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=a(E,"Module"),E.forEach(o),b=a(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=r("p"),v=n("Examples:"),g=m(),y(h.$$.fragment)},l(i){d=s(i,"P",{});var p=l(d);v=a(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=r("p"),v=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=r("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=a(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=a(E,"Module"),E.forEach(o),b=a(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=r("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=a(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=r("p"),v=n("Visual question answering (prompt = question):"),g=m(),y(h.$$.fragment)},l(i){d=s(i,"P",{});var p=l(d);v=a(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,Fr,Ua,se,Ue,un,ht,Pr,gn,Wr,Ia,H,Nr,ut,Qr,Gr,gt,qr,Vr,Za,bo,Sr,xa,vo,_n,Ar,za,yo,Rr,Fa,Ie,_t,Xr,bn,Lr,Dr,Yr,bt,Or,Mo,Hr,Kr,Pa,Ze,$c,Wa,vt,es,wo,ts,Na,K,os,yt,ns,as,Mt,rs,ss,Qa,le,xe,vn,wt,ls,yn,is,Ga,To,ds,qa,Bo,Tt,cs,Bt,ps,ms,Va,$o,fs,Sa,ie,ze,Mn,$t,hs,wn,us,Aa,P,kt,gs,ee,ko,_s,bs,jo,vs,ys,jt,Ms,ws,Ts,de,Bs,Jo,$s,ks,Eo,js,Js,Es,Fe,Cs,Pe,Jt,Us,Et,Is,Co,Zs,xs,Ra,ce,We,Tn,Ct,zs,Bn,Fs,Xa,G,Ut,Ps,pe,Ws,Uo,Ns,Qs,It,Gs,qs,Vs,me,Ss,Io,As,Rs,Zo,Xs,Ls,Ds,Ne,La,fe,Qe,$n,Zt,Ys,kn,Os,Da,q,xt,Hs,V,Ks,xo,el,tl,zt,ol,nl,zo,al,rl,Fo,sl,ll,il,he,dl,Po,cl,pl,Wo,ml,fl,hl,Ge,Ya,ue,qe,jn,Ft,ul,Jn,gl,Oa,W,Pt,_l,En,bl,vl,N,No,yl,Ml,Qo,wl,Tl,Go,Bl,$l,Cn,kl,jl,qo,Jl,El,Cl,Ve,Wt,Ul,Nt,Il,Vo,Zl,xl,zl,Se,Qt,Fl,Gt,Pl,So,Wl,Nl,Ha,ge,Ae,Un,qt,Ql,In,Gl,Ka,_e,Vt,ql,te,St,Vl,be,Sl,Ao,Al,Rl,Zn,Xl,Ll,Dl,Re,er,ve,Xe,xn,At,Yl,zn,Ol,tr,D,Rt,Hl,Fn,Kl,ei,oe,Xt,ti,U,oi,Pn,ni,ai,Wn,ri,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,Fi,Hn,Pi,Wi,Kn,Ni,Qi,ea,Gi,qi,ta,Vi,Si,oa,Ai,Ri,na,Xi,Li,aa,Di,Yi,or,ye,Le,ra,Yt,Oi,sa,Hi,nr,C,Ot,Ki,la,ed,td,Ht,od,Ro,nd,ad,rd,Kt,sd,eo,ld,id,dd,S,to,cd,Me,pd,Xo,md,fd,ia,hd,ud,gd,De,_d,Ye,bd,A,oo,vd,we,yd,Lo,Md,wd,da,Td,Bd,$d,Oe,kd,He,jd,R,no,Jd,Te,Ed,Do,Cd,Ud,ca,Id,Zd,xd,Ke,zd,et,Fd,X,ao,Pd,Be,Wd,Yo,Nd,Qd,pa,Gd,qd,Vd,tt,Sd,ot,ar,$e,nt,ma,ro,Ad,fa,Rd,rr,I,so,Xd,ha,Ld,Dd,lo,Yd,ua,Od,Hd,Kd,io,ec,Oo,tc,oc,nc,co,ac,po,rc,sc,lc,x,mo,ic,ke,dc,Ho,cc,pc,ga,mc,fc,hc,at,uc,_a,gc,_c,rt,bc,st,vc,lt,fo,yc,ho,Mc,ba,wc,Tc,sr;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"}}),Fe=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}}}),Ft=new O({}),Pt=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"}}),Wt=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:": FloatTensor"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_hidden_states",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],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/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__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/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__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/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__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:[Fm]},$$scope:{ctx:j}}}),et=new Je({props:{anchor:"transformers.Blip2Model.get_image_features.example",$$slots:{default:[Pm]},$$scope:{ctx:j}}}),ao=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/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__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:[Wm]},$$scope:{ctx:j}}}),ot=new Je({props:{anchor:"transformers.Blip2Model.get_qformer_features.example",$$slots:{default:[Nm]},$$scope:{ctx:j}}}),ro=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/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__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>
`}}),at=new hn({props:{$$slots:{default:[Qm]},$$scope:{ctx:j}}}),rt=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=r("meta"),v=m(),g=r("h1"),h=r("a"),b=r("span"),y(i.$$.fragment),p=m(),E=r("span"),Fr=n("BLIP-2"),Ua=m(),se=r("h2"),Ue=r("a"),un=r("span"),y(ht.$$.fragment),Pr=m(),gn=r("span"),Wr=n("Overview"),Ia=m(),H=r("p"),Nr=n("The BLIP-2 model was proposed in "),ut=r("a"),Qr=n("BLIP-2: Bootstrapping Language-Image Pre-training with Frozen Image Encoders and Large Language Models"),Gr=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=r("a"),qr=n("Flamingo"),Vr=n(`, an 80 billion parameter model, by 8.7%
on zero-shot VQAv2 with 54x fewer trainable parameters.`),Za=m(),bo=r("p"),Sr=n("The abstract from the paper is the following:"),xa=m(),vo=r("p"),_n=r("em"),Ar=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."),za=m(),yo=r("p"),Rr=n("Tips:"),Fa=m(),Ie=r("ul"),_t=r("li"),Xr=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=r("code"),Lr=n("generate"),Dr=n(" method."),Yr=m(),bt=r("li"),Or=n("One can use "),Mo=r("a"),Hr=n("Blip2Processor"),Kr=n(" to prepare images for the model, and decode the predicted tokens ID\u2019s back to text."),Pa=m(),Ze=r("img"),Wa=m(),vt=r("small"),es=n("BLIP-2 architecture. Taken from the "),wo=r("a"),ts=n("original paper."),Na=m(),K=r("p"),os=n("This model was contributed by "),yt=r("a"),ns=n("nielsr"),as=n(`.
The original code can be found `),Mt=r("a"),rs=n("here"),ss=n("."),Qa=m(),le=r("h2"),xe=r("a"),vn=r("span"),y(wt.$$.fragment),ls=m(),yn=r("span"),is=n("Resources"),Ga=m(),To=r("p"),ds=n("A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started with BLIP-2."),qa=m(),Bo=r("ul"),Tt=r("li"),cs=n("Demo notebooks for BLIP-2 for image captioning, visual question answering (VQA) and chat-like conversations can be found "),Bt=r("a"),ps=n("here"),ms=n("."),Va=m(),$o=r("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."),Sa=m(),ie=r("h2"),ze=r("a"),Mn=r("span"),y($t.$$.fragment),hs=m(),wn=r("span"),us=n("Blip2Config"),Aa=m(),P=r("div"),y(kt.$$.fragment),gs=m(),ee=r("p"),ko=r("a"),_s=n("Blip2Config"),bs=n(" is the configuration class to store the configuration of a "),jo=r("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=r("a"),Ms=n("Salesforce/blip2-opt-2.7b"),ws=n(" architecture."),Ts=m(),de=r("p"),Bs=n("Configuration objects inherit from "),Jo=r("a"),$s=n("PretrainedConfig"),ks=n(` and can be used to control the model outputs. Read the
documentation from `),Eo=r("a"),js=n("PretrainedConfig"),Js=n(" for more information."),Es=m(),y(Fe.$$.fragment),Cs=m(),Pe=r("div"),y(Jt.$$.fragment),Us=m(),Et=r("p"),Is=n("Instantiate a "),Co=r("a"),Zs=n("Blip2Config"),xs=n(` (or a derived class) from a BLIP-2 vision model, Q-Former and language model
configurations.`),Ra=m(),ce=r("h2"),We=r("a"),Tn=r("span"),y(Ct.$$.fragment),zs=m(),Bn=r("span"),Fs=n("Blip2VisionConfig"),Xa=m(),G=r("div"),y(Ut.$$.fragment),Ps=m(),pe=r("p"),Ws=n("This is the configuration class to store the configuration of a "),Uo=r("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=r("a"),Gs=n("Salesforce/blip2-opt-2.7b"),qs=n(" architecture."),Vs=m(),me=r("p"),Ss=n("Configuration objects inherit from "),Io=r("a"),As=n("PretrainedConfig"),Rs=n(` and can be used to control the model outputs. Read the
documentation from `),Zo=r("a"),Xs=n("PretrainedConfig"),Ls=n(" for more information."),Ds=m(),y(Ne.$$.fragment),La=m(),fe=r("h2"),Qe=r("a"),$n=r("span"),y(Zt.$$.fragment),Ys=m(),kn=r("span"),Os=n("Blip2QFormerConfig"),Da=m(),q=r("div"),y(xt.$$.fragment),Hs=m(),V=r("p"),Ks=n("This is the configuration class to store the configuration of a "),xo=r("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=r("a"),ol=n("Salesforce/blip2-opt-2.7b"),nl=n(` architecture. Configuration objects
inherit from `),zo=r("a"),al=n("PretrainedConfig"),rl=n(` and can be used to control the model outputs. Read the documentation from
`),Fo=r("a"),sl=n("PretrainedConfig"),ll=n(" for more information."),il=m(),he=r("p"),dl=n("Note that "),Po=r("a"),cl=n("Blip2QFormerModel"),pl=n(" is very similar to "),Wo=r("a"),ml=n("BertLMHeadModel"),fl=n(" with interleaved cross-attention."),hl=m(),y(Ge.$$.fragment),Ya=m(),ue=r("h2"),qe=r("a"),jn=r("span"),y(Ft.$$.fragment),ul=m(),Jn=r("span"),gl=n("Blip2Processor"),Oa=m(),W=r("div"),y(Pt.$$.fragment),_l=m(),En=r("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=r("p"),No=r("a"),yl=n("BlipProcessor"),Ml=n(" offers all the functionalities of "),Qo=r("a"),wl=n("BlipImageProcessor"),Tl=n(" and "),Go=r("a"),Bl=n("AutoTokenizer"),$l=n(`. See the docstring
of `),Cn=r("code"),kl=n("__call__()"),jl=n(" and "),qo=r("a"),Jl=n("decode()"),El=n(" for more information."),Cl=m(),Ve=r("div"),y(Wt.$$.fragment),Ul=m(),Nt=r("p"),Il=n("This method forwards all its arguments to PreTrainedTokenizer\u2019s "),Vo=r("a"),Zl=n("batch_decode()"),xl=n(`. Please
refer to the docstring of this method for more information.`),zl=m(),Se=r("div"),y(Qt.$$.fragment),Fl=m(),Gt=r("p"),Pl=n("This method forwards all its arguments to PreTrainedTokenizer\u2019s "),So=r("a"),Wl=n("decode()"),Nl=n(`. Please refer
to the docstring of this method for more information.`),Ha=m(),ge=r("h2"),Ae=r("a"),Un=r("span"),y(qt.$$.fragment),Ql=m(),In=r("span"),Gl=n("Blip2VisionModel"),Ka=m(),_e=r("div"),y(Vt.$$.fragment),ql=m(),te=r("div"),y(St.$$.fragment),Vl=m(),be=r("p"),Sl=n("The "),Ao=r("a"),Al=n("Blip2VisionModel"),Rl=n(" forward method, overrides the "),Zn=r("code"),Xl=n("__call__"),Ll=n(" special method."),Dl=m(),y(Re.$$.fragment),er=m(),ve=r("h2"),Xe=r("a"),xn=r("span"),y(At.$$.fragment),Yl=m(),zn=r("span"),Ol=n("Blip2QFormerModel"),tr=m(),D=r("div"),y(Rt.$$.fragment),Hl=m(),Fn=r("p"),Kl=n("Querying Transformer (Q-Former), used in BLIP-2."),ei=m(),oe=r("div"),y(Xt.$$.fragment),ti=m(),U=r("p"),oi=n("encoder_hidden_states  ("),Pn=r("code"),ni=n("torch.FloatTensor"),ai=n(" of shape "),Wn=r("code"),ri=n("(batch_size, sequence_length, hidden_size)"),si=n(", "),Nn=r("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=r("code"),di=n("torch.FloatTensor"),ci=n(" of shape "),Gn=r("code"),pi=n("(batch_size, sequence_length)"),mi=n(", "),qn=r("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=r("code"),ui=n("[0, 1]"),gi=n(":"),_i=m(),Lt=r("ul"),Dt=r("li"),bi=n("1 for tokens that are "),Sn=r("strong"),vi=n("not masked"),yi=n(","),Mi=m(),k=r("li"),wi=n("0 for tokens that are "),An=r("strong"),Ti=n("masked"),Bi=n(`.
past_key_values (`),Rn=r("code"),$i=n("tuple(tuple(torch.FloatTensor))"),ki=n(" of length "),Xn=r("code"),ji=n("config.n_layers"),Ji=n(` with each tuple having 4 tensors of:
shape `),Ln=r("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=r("code"),Ui=n("past_key_values"),Ii=n(` are
used, the user can optionally input only the last `),Yn=r("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=r("code"),zi=n("(batch_size, 1)"),Fi=n(" instead of all "),Hn=r("code"),Pi=n("decoder_input_ids"),Wi=n(` of shape
`),Kn=r("code"),Ni=n("(batch_size, sequence_length)"),Qi=n(`.
use_cache (`),ea=r("code"),Gi=n("bool"),qi=n(", "),ta=r("code"),Vi=n("optional"),Si=n(`):
If set to `),oa=r("code"),Ai=n("True"),Ri=n(", "),na=r("code"),Xi=n("past_key_values"),Li=n(` key value states are returned and can be used to speed up decoding (see
`),aa=r("code"),Di=n("past_key_values"),Yi=n(")."),or=m(),ye=r("h2"),Le=r("a"),ra=r("span"),y(Yt.$$.fragment),Oi=m(),sa=r("span"),Hi=n("Blip2Model"),nr=m(),C=r("div"),y(Ot.$$.fragment),Ki=m(),la=r("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=r("p"),od=n("This model inherits from "),Ro=r("a"),nd=n("PreTrainedModel"),ad=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.)`),rd=m(),Kt=r("p"),sd=n("This model is also a PyTorch "),eo=r("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=r("div"),y(to.$$.fragment),cd=m(),Me=r("p"),pd=n("The "),Xo=r("a"),md=n("Blip2Model"),fd=n(" forward method, overrides the "),ia=r("code"),hd=n("__call__"),ud=n(" special method."),gd=m(),y(De.$$.fragment),_d=m(),y(Ye.$$.fragment),bd=m(),A=r("div"),y(oo.$$.fragment),vd=m(),we=r("p"),yd=n("The "),Lo=r("a"),Md=n("Blip2Model"),wd=n(" forward method, overrides the "),da=r("code"),Td=n("__call__"),Bd=n(" special method."),$d=m(),y(Oe.$$.fragment),kd=m(),y(He.$$.fragment),jd=m(),R=r("div"),y(no.$$.fragment),Jd=m(),Te=r("p"),Ed=n("The "),Do=r("a"),Cd=n("Blip2Model"),Ud=n(" forward method, overrides the "),ca=r("code"),Id=n("__call__"),Zd=n(" special method."),xd=m(),y(Ke.$$.fragment),zd=m(),y(et.$$.fragment),Fd=m(),X=r("div"),y(ao.$$.fragment),Pd=m(),Be=r("p"),Wd=n("The "),Yo=r("a"),Nd=n("Blip2Model"),Qd=n(" forward method, overrides the "),pa=r("code"),Gd=n("__call__"),qd=n(" special method."),Vd=m(),y(tt.$$.fragment),Sd=m(),y(ot.$$.fragment),ar=m(),$e=r("h2"),nt=r("a"),ma=r("span"),y(ro.$$.fragment),Ad=m(),fa=r("span"),Rd=n("Blip2ForConditionalGeneration"),rr=m(),I=r("div"),y(so.$$.fragment),Xd=m(),ha=r("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=r("p"),Yd=n("One can optionally pass "),ua=r("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=r("p"),ec=n("This model inherits from "),Oo=r("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=r("p"),ac=n("This model is also a PyTorch "),po=r("a"),rc=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=r("div"),y(mo.$$.fragment),ic=m(),ke=r("p"),dc=n("The "),Ho=r("a"),cc=n("Blip2ForConditionalGeneration"),pc=n(" forward method, overrides the "),ga=r("code"),mc=n("__call__"),fc=n(" special method."),hc=m(),y(at.$$.fragment),uc=m(),_a=r("p"),gc=n("Examples:"),_c=m(),y(rt.$$.fragment),bc=m(),y(st.$$.fragment),vc=m(),lt=r("div"),y(fo.$$.fragment),yc=m(),ho=r("p"),Mc=n("Overrides "),ba=r("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 va=l(h);b=s(va,"SPAN",{});var ya=l(b);M(i.$$.fragment,ya),ya.forEach(o),va.forEach(o),p=f(uo),E=s(uo,"SPAN",{});var Ma=l(E);Fr=a(Ma,"BLIP-2"),Ma.forEach(o),uo.forEach(o),Ua=f(t),se=s(t,"H2",{class:!0});var go=l(se);Ue=s(go,"A",{id:!0,class:!0,href:!0});var wa=l(Ue);un=s(wa,"SPAN",{});var Ta=l(un);M(ht.$$.fragment,Ta),Ta.forEach(o),wa.forEach(o),Pr=f(go),gn=s(go,"SPAN",{});var Ba=l(gn);Wr=a(Ba,"Overview"),Ba.forEach(o),go.forEach(o),Ia=f(t),H=s(t,"P",{});var je=l(H);Nr=a(je,"The BLIP-2 model was proposed in "),ut=s(je,"A",{href:!0,rel:!0});var $a=l(ut);Qr=a($a,"BLIP-2: Bootstrapping Language-Image Pre-training with Frozen Image Encoders and Large Language Models"),$a.forEach(o),Gr=a(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 ka=l(gt);qr=a(ka,"Flamingo"),ka.forEach(o),Vr=a(je,`, an 80 billion parameter model, by 8.7%
on zero-shot VQAv2 with 54x fewer trainable parameters.`),je.forEach(o),Za=f(t),bo=s(t,"P",{});var ja=l(bo);Sr=a(ja,"The abstract from the paper is the following:"),ja.forEach(o),xa=f(t),vo=s(t,"P",{});var Ja=l(vo);_n=s(Ja,"EM",{});var Ea=l(_n);Ar=a(Ea,"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."),Ea.forEach(o),Ja.forEach(o),za=f(t),yo=s(t,"P",{});var Ca=l(yo);Rr=a(Ca,"Tips:"),Ca.forEach(o),Fa=f(t),Ie=s(t,"UL",{});var lr=l(Ie);_t=s(lr,"LI",{});var ir=l(_t);Xr=a(ir,"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(ir,"CODE",{});var kc=l(bn);Lr=a(kc,"generate"),kc.forEach(o),Dr=a(ir," method."),ir.forEach(o),Yr=f(lr),bt=s(lr,"LI",{});var dr=l(bt);Or=a(dr,"One can use "),Mo=s(dr,"A",{href:!0});var jc=l(Mo);Hr=a(jc,"Blip2Processor"),jc.forEach(o),Kr=a(dr," to prepare images for the model, and decode the predicted tokens ID\u2019s back to text."),dr.forEach(o),lr.forEach(o),Pa=f(t),Ze=s(t,"IMG",{src:!0,alt:!0,width:!0}),Wa=f(t),vt=s(t,"SMALL",{});var Bc=l(vt);es=a(Bc,"BLIP-2 architecture. Taken from the "),wo=s(Bc,"A",{href:!0});var Jc=l(wo);ts=a(Jc,"original paper."),Jc.forEach(o),Bc.forEach(o),Na=f(t),K=s(t,"P",{});var Ko=l(K);os=a(Ko,"This model was contributed by "),yt=s(Ko,"A",{href:!0,rel:!0});var Ec=l(yt);ns=a(Ec,"nielsr"),Ec.forEach(o),as=a(Ko,`.
The original code can be found `),Mt=s(Ko,"A",{href:!0,rel:!0});var Cc=l(Mt);rs=a(Cc,"here"),Cc.forEach(o),ss=a(Ko,"."),Ko.forEach(o),Qa=f(t),le=s(t,"H2",{class:!0});var cr=l(le);xe=s(cr,"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(cr),yn=s(cr,"SPAN",{});var Zc=l(yn);is=a(Zc,"Resources"),Zc.forEach(o),cr.forEach(o),Ga=f(t),To=s(t,"P",{});var xc=l(To);ds=a(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),qa=f(t),Bo=s(t,"UL",{});var zc=l(Bo);Tt=s(zc,"LI",{});var pr=l(Tt);cs=a(pr,"Demo notebooks for BLIP-2 for image captioning, visual question answering (VQA) and chat-like conversations can be found "),Bt=s(pr,"A",{href:!0,rel:!0});var Fc=l(Bt);ps=a(Fc,"here"),Fc.forEach(o),ms=a(pr,"."),pr.forEach(o),zc.forEach(o),Va=f(t),$o=s(t,"P",{});var Pc=l($o);fs=a(Pc,"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."),Pc.forEach(o),Sa=f(t),ie=s(t,"H2",{class:!0});var mr=l(ie);ze=s(mr,"A",{id:!0,class:!0,href:!0});var Wc=l(ze);Mn=s(Wc,"SPAN",{});var Nc=l(Mn);M($t.$$.fragment,Nc),Nc.forEach(o),Wc.forEach(o),hs=f(mr),wn=s(mr,"SPAN",{});var Qc=l(wn);us=a(Qc,"Blip2Config"),Qc.forEach(o),mr.forEach(o),Aa=f(t),P=s(t,"DIV",{class:!0});var ne=l(P);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=a(Gc,"Blip2Config"),Gc.forEach(o),bs=a(_o," is the configuration class to store the configuration of a "),jo=s(_o,"A",{href:!0});var qc=l(jo);vs=a(qc,"Blip2ForConditionalGeneration"),qc.forEach(o),ys=a(_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=a(Vc,"Salesforce/blip2-opt-2.7b"),Vc.forEach(o),ws=a(_o," architecture."),_o.forEach(o),Ts=f(ne),de=s(ne,"P",{});var en=l(de);Bs=a(en,"Configuration objects inherit from "),Jo=s(en,"A",{href:!0});var Sc=l(Jo);$s=a(Sc,"PretrainedConfig"),Sc.forEach(o),ks=a(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=a(Ac,"PretrainedConfig"),Ac.forEach(o),Js=a(en," for more information."),en.forEach(o),Es=f(ne),M(Fe.$$.fragment,ne),Cs=f(ne),Pe=s(ne,"DIV",{class:!0});var fr=l(Pe);M(Jt.$$.fragment,fr),Us=f(fr),Et=s(fr,"P",{});var hr=l(Et);Is=a(hr,"Instantiate a "),Co=s(hr,"A",{href:!0});var Rc=l(Co);Zs=a(Rc,"Blip2Config"),Rc.forEach(o),xs=a(hr,` (or a derived class) from a BLIP-2 vision model, Q-Former and language model
configurations.`),hr.forEach(o),fr.forEach(o),ne.forEach(o),Ra=f(t),ce=s(t,"H2",{class:!0});var ur=l(ce);We=s(ur,"A",{id:!0,class:!0,href:!0});var Xc=l(We);Tn=s(Xc,"SPAN",{});var Lc=l(Tn);M(Ct.$$.fragment,Lc),Lc.forEach(o),Xc.forEach(o),zs=f(ur),Bn=s(ur,"SPAN",{});var Dc=l(Bn);Fs=a(Dc,"Blip2VisionConfig"),Dc.forEach(o),ur.forEach(o),Xa=f(t),G=s(t,"DIV",{class:!0});var it=l(G);M(Ut.$$.fragment,it),Ps=f(it),pe=s(it,"P",{});var tn=l(pe);Ws=a(tn,"This is the configuration class to store the configuration of a "),Uo=s(tn,"A",{href:!0});var Yc=l(Uo);Ns=a(Yc,"Blip2VisionModel"),Yc.forEach(o),Qs=a(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=a(Oc,"Salesforce/blip2-opt-2.7b"),Oc.forEach(o),qs=a(tn," architecture."),tn.forEach(o),Vs=f(it),me=s(it,"P",{});var on=l(me);Ss=a(on,"Configuration objects inherit from "),Io=s(on,"A",{href:!0});var Hc=l(Io);As=a(Hc,"PretrainedConfig"),Hc.forEach(o),Rs=a(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=a(Kc,"PretrainedConfig"),Kc.forEach(o),Ls=a(on," for more information."),on.forEach(o),Ds=f(it),M(Ne.$$.fragment,it),it.forEach(o),La=f(t),fe=s(t,"H2",{class:!0});var gr=l(fe);Qe=s(gr,"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(gr),kn=s(gr,"SPAN",{});var op=l(kn);Os=a(op,"Blip2QFormerConfig"),op.forEach(o),gr.forEach(o),Da=f(t),q=s(t,"DIV",{class:!0});var dt=l(q);M(xt.$$.fragment,dt),Hs=f(dt),V=s(dt,"P",{});var ae=l(V);Ks=a(ae,"This is the configuration class to store the configuration of a "),xo=s(ae,"A",{href:!0});var np=l(xo);el=a(np,"Blip2QFormerModel"),np.forEach(o),tl=a(ae,`. 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(ae,"A",{href:!0,rel:!0});var ap=l(zt);ol=a(ap,"Salesforce/blip2-opt-2.7b"),ap.forEach(o),nl=a(ae,` architecture. Configuration objects
inherit from `),zo=s(ae,"A",{href:!0});var rp=l(zo);al=a(rp,"PretrainedConfig"),rp.forEach(o),rl=a(ae,` and can be used to control the model outputs. Read the documentation from
`),Fo=s(ae,"A",{href:!0});var sp=l(Fo);sl=a(sp,"PretrainedConfig"),sp.forEach(o),ll=a(ae," for more information."),ae.forEach(o),il=f(dt),he=s(dt,"P",{});var nn=l(he);dl=a(nn,"Note that "),Po=s(nn,"A",{href:!0});var lp=l(Po);cl=a(lp,"Blip2QFormerModel"),lp.forEach(o),pl=a(nn," is very similar to "),Wo=s(nn,"A",{href:!0});var ip=l(Wo);ml=a(ip,"BertLMHeadModel"),ip.forEach(o),fl=a(nn," with interleaved cross-attention."),nn.forEach(o),hl=f(dt),M(Ge.$$.fragment,dt),dt.forEach(o),Ya=f(t),ue=s(t,"H2",{class:!0});var _r=l(ue);qe=s(_r,"A",{id:!0,class:!0,href:!0});var dp=l(qe);jn=s(dp,"SPAN",{});var cp=l(jn);M(Ft.$$.fragment,cp),cp.forEach(o),dp.forEach(o),ul=f(_r),Jn=s(_r,"SPAN",{});var pp=l(Jn);gl=a(pp,"Blip2Processor"),pp.forEach(o),_r.forEach(o),Oa=f(t),W=s(t,"DIV",{class:!0});var re=l(W);M(Pt.$$.fragment,re),_l=f(re),En=s(re,"P",{});var mp=l(En);bl=a(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(re),N=s(re,"P",{});var Y=l(N);No=s(Y,"A",{href:!0});var fp=l(No);yl=a(fp,"BlipProcessor"),fp.forEach(o),Ml=a(Y," offers all the functionalities of "),Qo=s(Y,"A",{href:!0});var hp=l(Qo);wl=a(hp,"BlipImageProcessor"),hp.forEach(o),Tl=a(Y," and "),Go=s(Y,"A",{href:!0});var up=l(Go);Bl=a(up,"AutoTokenizer"),up.forEach(o),$l=a(Y,`. See the docstring
of `),Cn=s(Y,"CODE",{});var gp=l(Cn);kl=a(gp,"__call__()"),gp.forEach(o),jl=a(Y," and "),qo=s(Y,"A",{href:!0});var _p=l(qo);Jl=a(_p,"decode()"),_p.forEach(o),El=a(Y," for more information."),Y.forEach(o),Cl=f(re),Ve=s(re,"DIV",{class:!0});var br=l(Ve);M(Wt.$$.fragment,br),Ul=f(br),Nt=s(br,"P",{});var vr=l(Nt);Il=a(vr,"This method forwards all its arguments to PreTrainedTokenizer\u2019s "),Vo=s(vr,"A",{href:!0});var bp=l(Vo);Zl=a(bp,"batch_decode()"),bp.forEach(o),xl=a(vr,`. Please
refer to the docstring of this method for more information.`),vr.forEach(o),br.forEach(o),zl=f(re),Se=s(re,"DIV",{class:!0});var yr=l(Se);M(Qt.$$.fragment,yr),Fl=f(yr),Gt=s(yr,"P",{});var Mr=l(Gt);Pl=a(Mr,"This method forwards all its arguments to PreTrainedTokenizer\u2019s "),So=s(Mr,"A",{href:!0});var vp=l(So);Wl=a(vp,"decode()"),vp.forEach(o),Nl=a(Mr,`. Please refer
to the docstring of this method for more information.`),Mr.forEach(o),yr.forEach(o),re.forEach(o),Ha=f(t),ge=s(t,"H2",{class:!0});var wr=l(ge);Ae=s(wr,"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(wr),In=s(wr,"SPAN",{});var wp=l(In);Gl=a(wp,"Blip2VisionModel"),wp.forEach(o),wr.forEach(o),Ka=f(t),_e=s(t,"DIV",{class:!0});var Tr=l(_e);M(Vt.$$.fragment,Tr),ql=f(Tr),te=s(Tr,"DIV",{class:!0});var an=l(te);M(St.$$.fragment,an),Vl=f(an),be=s(an,"P",{});var rn=l(be);Sl=a(rn,"The "),Ao=s(rn,"A",{href:!0});var Tp=l(Ao);Al=a(Tp,"Blip2VisionModel"),Tp.forEach(o),Rl=a(rn," forward method, overrides the "),Zn=s(rn,"CODE",{});var Bp=l(Zn);Xl=a(Bp,"__call__"),Bp.forEach(o),Ll=a(rn," special method."),rn.forEach(o),Dl=f(an),M(Re.$$.fragment,an),an.forEach(o),Tr.forEach(o),er=f(t),ve=s(t,"H2",{class:!0});var Br=l(ve);Xe=s(Br,"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(Br),zn=s(Br,"SPAN",{});var jp=l(zn);Ol=a(jp,"Blip2QFormerModel"),jp.forEach(o),Br.forEach(o),tr=f(t),D=s(t,"DIV",{class:!0});var sn=l(D);M(Rt.$$.fragment,sn),Hl=f(sn),Fn=s(sn,"P",{});var Jp=l(Fn);Kl=a(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=a(z,"encoder_hidden_states  ("),Pn=s(z,"CODE",{});var Ep=l(Pn);ni=a(Ep,"torch.FloatTensor"),Ep.forEach(o),ai=a(z," of shape "),Wn=s(z,"CODE",{});var Cp=l(Wn);ri=a(Cp,"(batch_size, sequence_length, hidden_size)"),Cp.forEach(o),si=a(z,", "),Nn=s(z,"CODE",{});var Up=l(Nn);li=a(Up,"optional"),Up.forEach(o),ii=a(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=a(Ip,"torch.FloatTensor"),Ip.forEach(o),ci=a(z," of shape "),Gn=s(z,"CODE",{});var Zp=l(Gn);pi=a(Zp,"(batch_size, sequence_length)"),Zp.forEach(o),mi=a(z,", "),qn=s(z,"CODE",{});var xp=l(qn);fi=a(xp,"optional"),xp.forEach(o),hi=a(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=a(zp,"[0, 1]"),zp.forEach(o),gi=a(z,":"),z.forEach(o),_i=f(ln),Lt=s(ln,"UL",{});var $r=l(Lt);Dt=s($r,"LI",{});var kr=l(Dt);bi=a(kr,"1 for tokens that are "),Sn=s(kr,"STRONG",{});var Fp=l(Sn);vi=a(Fp,"not masked"),Fp.forEach(o),yi=a(kr,","),kr.forEach(o),Mi=f($r),k=s($r,"LI",{});var J=l(k);wi=a(J,"0 for tokens that are "),An=s(J,"STRONG",{});var Pp=l(An);Ti=a(Pp,"masked"),Pp.forEach(o),Bi=a(J,`.
past_key_values (`),Rn=s(J,"CODE",{});var Wp=l(Rn);$i=a(Wp,"tuple(tuple(torch.FloatTensor))"),Wp.forEach(o),ki=a(J," of length "),Xn=s(J,"CODE",{});var Np=l(Xn);ji=a(Np,"config.n_layers"),Np.forEach(o),Ji=a(J,` with each tuple having 4 tensors of:
shape `),Ln=s(J,"CODE",{});var Qp=l(Ln);Ei=a(Qp,"(batch_size, num_heads, sequence_length - 1, embed_size_per_head)"),Qp.forEach(o),Ci=a(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=a(Gp,"past_key_values"),Gp.forEach(o),Ii=a(J,` are
used, the user can optionally input only the last `),Yn=s(J,"CODE",{});var qp=l(Yn);Zi=a(qp,"decoder_input_ids"),qp.forEach(o),xi=a(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=a(Vp,"(batch_size, 1)"),Vp.forEach(o),Fi=a(J," instead of all "),Hn=s(J,"CODE",{});var Sp=l(Hn);Pi=a(Sp,"decoder_input_ids"),Sp.forEach(o),Wi=a(J,` of shape
`),Kn=s(J,"CODE",{});var Ap=l(Kn);Ni=a(Ap,"(batch_size, sequence_length)"),Ap.forEach(o),Qi=a(J,`.
use_cache (`),ea=s(J,"CODE",{});var Rp=l(ea);Gi=a(Rp,"bool"),Rp.forEach(o),qi=a(J,", "),ta=s(J,"CODE",{});var Xp=l(ta);Vi=a(Xp,"optional"),Xp.forEach(o),Si=a(J,`):
If set to `),oa=s(J,"CODE",{});var Lp=l(oa);Ai=a(Lp,"True"),Lp.forEach(o),Ri=a(J,", "),na=s(J,"CODE",{});var Dp=l(na);Xi=a(Dp,"past_key_values"),Dp.forEach(o),Li=a(J,` key value states are returned and can be used to speed up decoding (see
`),aa=s(J,"CODE",{});var Yp=l(aa);Di=a(Yp,"past_key_values"),Yp.forEach(o),Yi=a(J,")."),J.forEach(o),$r.forEach(o),ln.forEach(o),sn.forEach(o),or=f(t),ye=s(t,"H2",{class:!0});var jr=l(ye);Le=s(jr,"A",{id:!0,class:!0,href:!0});var Op=l(Le);ra=s(Op,"SPAN",{});var Hp=l(ra);M(Yt.$$.fragment,Hp),Hp.forEach(o),Op.forEach(o),Oi=f(jr),sa=s(jr,"SPAN",{});var Kp=l(sa);Hi=a(Kp,"Blip2Model"),Kp.forEach(o),jr.forEach(o),nr=f(t),C=s(t,"DIV",{class:!0});var F=l(C);M(Ot.$$.fragment,F),Ki=f(F),la=s(F,"P",{});var em=l(la);ed=a(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(F),Ht=s(F,"P",{});var Jr=l(Ht);od=a(Jr,"This model inherits from "),Ro=s(Jr,"A",{href:!0});var tm=l(Ro);nd=a(tm,"PreTrainedModel"),tm.forEach(o),ad=a(Jr,`. 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.)`),Jr.forEach(o),rd=f(F),Kt=s(F,"P",{});var Er=l(Kt);sd=a(Er,"This model is also a PyTorch "),eo=s(Er,"A",{href:!0,rel:!0});var om=l(eo);ld=a(om,"torch.nn.Module"),om.forEach(o),id=a(Er,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Er.forEach(o),dd=f(F),S=s(F,"DIV",{class:!0});var ct=l(S);M(to.$$.fragment,ct),cd=f(ct),Me=s(ct,"P",{});var dn=l(Me);pd=a(dn,"The "),Xo=s(dn,"A",{href:!0});var nm=l(Xo);md=a(nm,"Blip2Model"),nm.forEach(o),fd=a(dn," forward method, overrides the "),ia=s(dn,"CODE",{});var am=l(ia);hd=a(am,"__call__"),am.forEach(o),ud=a(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(F),A=s(F,"DIV",{class:!0});var pt=l(A);M(oo.$$.fragment,pt),vd=f(pt),we=s(pt,"P",{});var cn=l(we);yd=a(cn,"The "),Lo=s(cn,"A",{href:!0});var rm=l(Lo);Md=a(rm,"Blip2Model"),rm.forEach(o),wd=a(cn," forward method, overrides the "),da=s(cn,"CODE",{});var sm=l(da);Td=a(sm,"__call__"),sm.forEach(o),Bd=a(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(F),R=s(F,"DIV",{class:!0});var mt=l(R);M(no.$$.fragment,mt),Jd=f(mt),Te=s(mt,"P",{});var pn=l(Te);Ed=a(pn,"The "),Do=s(pn,"A",{href:!0});var lm=l(Do);Cd=a(lm,"Blip2Model"),lm.forEach(o),Ud=a(pn," forward method, overrides the "),ca=s(pn,"CODE",{});var im=l(ca);Id=a(im,"__call__"),im.forEach(o),Zd=a(pn," special method."),pn.forEach(o),xd=f(mt),M(Ke.$$.fragment,mt),zd=f(mt),M(et.$$.fragment,mt),mt.forEach(o),Fd=f(F),X=s(F,"DIV",{class:!0});var ft=l(X);M(ao.$$.fragment,ft),Pd=f(ft),Be=s(ft,"P",{});var mn=l(Be);Wd=a(mn,"The "),Yo=s(mn,"A",{href:!0});var dm=l(Yo);Nd=a(dm,"Blip2Model"),dm.forEach(o),Qd=a(mn," forward method, overrides the "),pa=s(mn,"CODE",{});var cm=l(pa);Gd=a(cm,"__call__"),cm.forEach(o),qd=a(mn," special method."),mn.forEach(o),Vd=f(ft),M(tt.$$.fragment,ft),Sd=f(ft),M(ot.$$.fragment,ft),ft.forEach(o),F.forEach(o),ar=f(t),$e=s(t,"H2",{class:!0});var Cr=l($e);nt=s(Cr,"A",{id:!0,class:!0,href:!0});var pm=l(nt);ma=s(pm,"SPAN",{});var mm=l(ma);M(ro.$$.fragment,mm),mm.forEach(o),pm.forEach(o),Ad=f(Cr),fa=s(Cr,"SPAN",{});var fm=l(fa);Rd=a(fm,"Blip2ForConditionalGeneration"),fm.forEach(o),Cr.forEach(o),rr=f(t),I=s(t,"DIV",{class:!0});var Q=l(I);M(so.$$.fragment,Q),Xd=f(Q),ha=s(Q,"P",{});var hm=l(ha);Ld=a(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 Ur=l(lo);Yd=a(Ur,"One can optionally pass "),ua=s(Ur,"CODE",{});var um=l(ua);Od=a(um,"input_ids"),um.forEach(o),Hd=a(Ur,` 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.`),Ur.forEach(o),Kd=f(Q),io=s(Q,"P",{});var Ir=l(io);ec=a(Ir,"This model inherits from "),Oo=s(Ir,"A",{href:!0});var gm=l(Oo);tc=a(gm,"PreTrainedModel"),gm.forEach(o),oc=a(Ir,`. 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.)`),Ir.forEach(o),nc=f(Q),co=s(Q,"P",{});var Zr=l(co);ac=a(Zr,"This model is also a PyTorch "),po=s(Zr,"A",{href:!0,rel:!0});var _m=l(po);rc=a(_m,"torch.nn.Module"),_m.forEach(o),sc=a(Zr,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Zr.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=a(fn,"The "),Ho=s(fn,"A",{href:!0});var bm=l(Ho);cc=a(bm,"Blip2ForConditionalGeneration"),bm.forEach(o),pc=a(fn," forward method, overrides the "),ga=s(fn,"CODE",{});var vm=l(ga);mc=a(vm,"__call__"),vm.forEach(o),fc=a(fn," special method."),fn.forEach(o),hc=f(L),M(at.$$.fragment,L),uc=f(L),_a=s(L,"P",{});var ym=l(_a);gc=a(ym,"Examples:"),ym.forEach(o),_c=f(L),M(rt.$$.fragment,L),bc=f(L),M(st.$$.fragment,L),L.forEach(o),vc=f(Q),lt=s(Q,"DIV",{class:!0});var xr=l(lt);M(fo.$$.fragment,xr),yc=f(xr),ho=s(xr,"P",{});var zr=l(ho);Mc=a(zr,"Overrides "),ba=s(zr,"CODE",{});var Mm=l(ba);wc=a(Mm,"generate"),Mm.forEach(o),Tc=a(zr," function to be able to use the model as a conditional generator."),zr.forEach(o),xr.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(Pe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(We,"id","transformers.Blip2VisionConfig"),c(We,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(We,"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(Fo,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),c(Po,"href","/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2QFormerModel"),c(Wo,"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/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.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/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.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(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(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,Fr),_(t,Ua,u),_(t,se,u),e(se,Ue),e(Ue,un),w(ht,un,null),e(se,Pr),e(se,gn),e(gn,Wr),_(t,Ia,u),_(t,H,u),e(H,Nr),e(H,ut),e(ut,Qr),e(H,Gr),e(H,gt),e(gt,qr),e(H,Vr),_(t,Za,u),_(t,bo,u),e(bo,Sr),_(t,xa,u),_(t,vo,u),e(vo,_n),e(_n,Ar),_(t,za,u),_(t,yo,u),e(yo,Rr),_(t,Fa,u),_(t,Ie,u),e(Ie,_t),e(_t,Xr),e(_t,bn),e(bn,Lr),e(_t,Dr),e(Ie,Yr),e(Ie,bt),e(bt,Or),e(bt,Mo),e(Mo,Hr),e(bt,Kr),_(t,Pa,u),_(t,Ze,u),_(t,Wa,u),_(t,vt,u),e(vt,es),e(vt,wo),e(wo,ts),_(t,Na,u),_(t,K,u),e(K,os),e(K,yt),e(yt,ns),e(K,as),e(K,Mt),e(Mt,rs),e(K,ss),_(t,Qa,u),_(t,le,u),e(le,xe),e(xe,vn),w(wt,vn,null),e(le,ls),e(le,yn),e(yn,is),_(t,Ga,u),_(t,To,u),e(To,ds),_(t,qa,u),_(t,Bo,u),e(Bo,Tt),e(Tt,cs),e(Tt,Bt),e(Bt,ps),e(Tt,ms),_(t,Va,u),_(t,$o,u),e($o,fs),_(t,Sa,u),_(t,ie,u),e(ie,ze),e(ze,Mn),w($t,Mn,null),e(ie,hs),e(ie,wn),e(wn,us),_(t,Aa,u),_(t,P,u),w(kt,P,null),e(P,gs),e(P,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(P,Ts),e(P,de),e(de,Bs),e(de,Jo),e(Jo,$s),e(de,ks),e(de,Eo),e(Eo,js),e(de,Js),e(P,Es),w(Fe,P,null),e(P,Cs),e(P,Pe),w(Jt,Pe,null),e(Pe,Us),e(Pe,Et),e(Et,Is),e(Et,Co),e(Co,Zs),e(Et,xs),_(t,Ra,u),_(t,ce,u),e(ce,We),e(We,Tn),w(Ct,Tn,null),e(ce,zs),e(ce,Bn),e(Bn,Fs),_(t,Xa,u),_(t,G,u),w(Ut,G,null),e(G,Ps),e(G,pe),e(pe,Ws),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,La,u),_(t,fe,u),e(fe,Qe),e(Qe,$n),w(Zt,$n,null),e(fe,Ys),e(fe,kn),e(kn,Os),_(t,Da,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,al),e(V,rl),e(V,Fo),e(Fo,sl),e(V,ll),e(q,il),e(q,he),e(he,dl),e(he,Po),e(Po,cl),e(he,pl),e(he,Wo),e(Wo,ml),e(he,fl),e(q,hl),w(Ge,q,null),_(t,Ya,u),_(t,ue,u),e(ue,qe),e(qe,jn),w(Ft,jn,null),e(ue,ul),e(ue,Jn),e(Jn,gl),_(t,Oa,u),_(t,W,u),w(Pt,W,null),e(W,_l),e(W,En),e(En,bl),e(W,vl),e(W,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(W,Cl),e(W,Ve),w(Wt,Ve,null),e(Ve,Ul),e(Ve,Nt),e(Nt,Il),e(Nt,Vo),e(Vo,Zl),e(Nt,xl),e(W,zl),e(W,Se),w(Qt,Se,null),e(Se,Fl),e(Se,Gt),e(Gt,Pl),e(Gt,So),e(So,Wl),e(Gt,Nl),_(t,Ha,u),_(t,ge,u),e(ge,Ae),e(Ae,Un),w(qt,Un,null),e(ge,Ql),e(ge,In),e(In,Gl),_(t,Ka,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,er,u),_(t,ve,u),e(ve,Xe),e(Xe,xn),w(At,xn,null),e(ve,Yl),e(ve,zn),e(zn,Ol),_(t,tr,u),_(t,D,u),w(Rt,D,null),e(D,Hl),e(D,Fn),e(Fn,Kl),e(D,ei),e(D,oe),w(Xt,oe,null),e(oe,ti),e(oe,U),e(U,oi),e(U,Pn),e(Pn,ni),e(U,ai),e(U,Wn),e(Wn,ri),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,Fi),e(k,Hn),e(Hn,Pi),e(k,Wi),e(k,Kn),e(Kn,Ni),e(k,Qi),e(k,ea),e(ea,Gi),e(k,qi),e(k,ta),e(ta,Vi),e(k,Si),e(k,oa),e(oa,Ai),e(k,Ri),e(k,na),e(na,Xi),e(k,Li),e(k,aa),e(aa,Di),e(k,Yi),_(t,or,u),_(t,ye,u),e(ye,Le),e(Le,ra),w(Yt,ra,null),e(ye,Oi),e(ye,sa),e(sa,Hi),_(t,nr,u),_(t,C,u),w(Ot,C,null),e(C,Ki),e(C,la),e(la,ed),e(C,td),e(C,Ht),e(Ht,od),e(Ht,Ro),e(Ro,nd),e(Ht,ad),e(C,rd),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,ia),e(ia,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,da),e(da,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,ca),e(ca,Id),e(Te,Zd),e(R,xd),w(Ke,R,null),e(R,zd),w(et,R,null),e(C,Fd),e(C,X),w(ao,X,null),e(X,Pd),e(X,Be),e(Be,Wd),e(Be,Yo),e(Yo,Nd),e(Be,Qd),e(Be,pa),e(pa,Gd),e(Be,qd),e(X,Vd),w(tt,X,null),e(X,Sd),w(ot,X,null),_(t,ar,u),_(t,$e,u),e($e,nt),e(nt,ma),w(ro,ma,null),e($e,Ad),e($e,fa),e(fa,Rd),_(t,rr,u),_(t,I,u),w(so,I,null),e(I,Xd),e(I,ha),e(ha,Ld),e(I,Dd),e(I,lo),e(lo,Yd),e(lo,ua),e(ua,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,ac),e(co,po),e(po,rc),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,ga),e(ga,mc),e(ke,fc),e(x,hc),w(at,x,null),e(x,uc),e(x,_a),e(_a,gc),e(x,_c),w(rt,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,ba),e(ba,wc),e(ho,Tc),sr=!0},p(t,[u]){const uo={};u&2&&(uo.$$scope={dirty:u,ctx:t}),Fe.$set(uo);const va={};u&2&&(va.$$scope={dirty:u,ctx:t}),Ne.$set(va);const ya={};u&2&&(ya.$$scope={dirty:u,ctx:t}),Ge.$set(ya);const Ma={};u&2&&(Ma.$$scope={dirty:u,ctx:t}),Re.$set(Ma);const go={};u&2&&(go.$$scope={dirty:u,ctx:t}),De.$set(go);const wa={};u&2&&(wa.$$scope={dirty:u,ctx:t}),Ye.$set(wa);const Ta={};u&2&&(Ta.$$scope={dirty:u,ctx:t}),Oe.$set(Ta);const Ba={};u&2&&(Ba.$$scope={dirty:u,ctx:t}),He.$set(Ba);const je={};u&2&&(je.$$scope={dirty:u,ctx:t}),Ke.$set(je);const $a={};u&2&&($a.$$scope={dirty:u,ctx:t}),et.$set($a);const ka={};u&2&&(ka.$$scope={dirty:u,ctx:t}),tt.$set(ka);const ja={};u&2&&(ja.$$scope={dirty:u,ctx:t}),ot.$set(ja);const Ja={};u&2&&(Ja.$$scope={dirty:u,ctx:t}),at.$set(Ja);const Ea={};u&2&&(Ea.$$scope={dirty:u,ctx:t}),rt.$set(Ea);const Ca={};u&2&&(Ca.$$scope={dirty:u,ctx:t}),st.$set(Ca)},i(t){sr||(T(i.$$.fragment,t),T(ht.$$.fragment,t),T(wt.$$.fragment,t),T($t.$$.fragment,t),T(kt.$$.fragment,t),T(Fe.$$.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(Ft.$$.fragment,t),T(Pt.$$.fragment,t),T(Wt.$$.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(ao.$$.fragment,t),T(tt.$$.fragment,t),T(ot.$$.fragment,t),T(ro.$$.fragment,t),T(so.$$.fragment,t),T(mo.$$.fragment,t),T(at.$$.fragment,t),T(rt.$$.fragment,t),T(st.$$.fragment,t),T(fo.$$.fragment,t),sr=!0)},o(t){B(i.$$.fragment,t),B(ht.$$.fragment,t),B(wt.$$.fragment,t),B($t.$$.fragment,t),B(kt.$$.fragment,t),B(Fe.$$.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(Ft.$$.fragment,t),B(Pt.$$.fragment,t),B(Wt.$$.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(ao.$$.fragment,t),B(tt.$$.fragment,t),B(ot.$$.fragment,t),B(ro.$$.fragment,t),B(so.$$.fragment,t),B(mo.$$.fragment,t),B(at.$$.fragment,t),B(rt.$$.fragment,t),B(st.$$.fragment,t),B(fo.$$.fragment,t),sr=!1},d(t){o(d),t&&o(v),t&&o(g),$(i),t&&o(Ua),t&&o(se),$(ht),t&&o(Ia),t&&o(H),t&&o(Za),t&&o(bo),t&&o(xa),t&&o(vo),t&&o(za),t&&o(yo),t&&o(Fa),t&&o(Ie),t&&o(Pa),t&&o(Ze),t&&o(Wa),t&&o(vt),t&&o(Na),t&&o(K),t&&o(Qa),t&&o(le),$(wt),t&&o(Ga),t&&o(To),t&&o(qa),t&&o(Bo),t&&o(Va),t&&o($o),t&&o(Sa),t&&o(ie),$($t),t&&o(Aa),t&&o(P),$(kt),$(Fe),$(Jt),t&&o(Ra),t&&o(ce),$(Ct),t&&o(Xa),t&&o(G),$(Ut),$(Ne),t&&o(La),t&&o(fe),$(Zt),t&&o(Da),t&&o(q),$(xt),$(Ge),t&&o(Ya),t&&o(ue),$(Ft),t&&o(Oa),t&&o(W),$(Pt),$(Wt),$(Qt),t&&o(Ha),t&&o(ge),$(qt),t&&o(Ka),t&&o(_e),$(Vt),$(St),$(Re),t&&o(er),t&&o(ve),$(At),t&&o(tr),t&&o(D),$(Rt),$(Xt),t&&o(or),t&&o(ye),$(Yt),t&&o(nr),t&&o(C),$(Ot),$(to),$(De),$(Ye),$(oo),$(Oe),$(He),$(no),$(Ke),$(et),$(ao),$(tt),$(ot),t&&o(ar),t&&o($e),$(ro),t&&o(rr),t&&o(I),$(so),$(mo),$(at),$(rt),$(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};
