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 i,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(l){d=s(l,"P",{});var p=i(d);v=a(p,"Example:"),p.forEach(o),g=f(l),M(h.$$.fragment,l)},m(l,p){_(l,d,p),e(d,v),_(l,g,p),w(h,l,p),b=!0},p:Ee,i(l){b||(T(h.$$.fragment,l),b=!0)},o(l){B(h.$$.fragment,l),b=!1},d(l){l&&o(d),l&&o(g),$(h,l)}}}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(l){d=s(l,"P",{});var p=i(d);v=a(p,"Example:"),p.forEach(o),g=f(l),M(h.$$.fragment,l)},m(l,p){_(l,d,p),e(d,v),_(l,g,p),w(h,l,p),b=!0},p:Ee,i(l){b||(T(h.$$.fragment,l),b=!0)},o(l){B(h.$$.fragment,l),b=!1},d(l){l&&o(d),l&&o(g),$(h,l)}}}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(l){d=s(l,"P",{});var p=i(d);v=a(p,"Examples:"),p.forEach(o),g=f(l),M(h.$$.fragment,l)},m(l,p){_(l,d,p),e(d,v),_(l,g,p),w(h,l,p),b=!0},p:Ee,i(l){b||(T(h.$$.fragment,l),b=!0)},o(l){B(h.$$.fragment,l),b=!1},d(l){l&&o(d),l&&o(g),$(h,l)}}}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(l){d=s(l,"P",{});var p=i(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=i(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(l,p){_(l,d,p),e(d,v),e(d,g),e(g,h),e(d,b)},d(l){l&&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(l){d=s(l,"P",{});var p=i(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=i(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(l,p){_(l,d,p),e(d,v),e(d,g),e(g,h),e(d,b)},d(l){l&&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(l){d=s(l,"P",{});var p=i(d);v=a(p,"Examples:"),p.forEach(o),g=f(l),M(h.$$.fragment,l)},m(l,p){_(l,d,p),e(d,v),_(l,g,p),w(h,l,p),b=!0},p:Ee,i(l){b||(T(h.$$.fragment,l),b=!0)},o(l){B(h.$$.fragment,l),b=!1},d(l){l&&o(d),l&&o(g),$(h,l)}}}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(l){d=s(l,"P",{});var p=i(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=i(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(l,p){_(l,d,p),e(d,v),e(d,g),e(g,h),e(d,b)},d(l){l&&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(l){d=s(l,"P",{});var p=i(d);v=a(p,"Examples:"),p.forEach(o),g=f(l),M(h.$$.fragment,l)},m(l,p){_(l,d,p),e(d,v),_(l,g,p),w(h,l,p),b=!0},p:Ee,i(l){b||(T(h.$$.fragment,l),b=!0)},o(l){B(h.$$.fragment,l),b=!1},d(l){l&&o(d),l&&o(g),$(h,l)}}}function Pm(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(l){d=s(l,"P",{});var p=i(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=i(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(l,p){_(l,d,p),e(d,v),e(d,g),e(g,h),e(d,b)},d(l){l&&o(d)}}}function Wm(j){let d,v,g,h,b;return h=new Ce({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFpbXBvcnQlMjByZXF1ZXN0cyUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBBdXRvUHJvY2Vzc29yJTJDJTIwQmxpcDJNb2RlbCUwQSUwQWRldmljZSUyMCUzRCUyMCUyMmN1ZGElMjIlMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwJTIyY3B1JTIyJTBBJTBBbW9kZWwlMjAlM0QlMjBCbGlwMk1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJTYWxlc2ZvcmNlJTJGYmxpcDItb3B0LTIuN2IlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBJTBBbW9kZWwudG8oZGV2aWNlKSUwQXByb2Nlc3NvciUyMCUzRCUyMEF1dG9Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMlNhbGVzZm9yY2UlMkZibGlwMi1vcHQtMi43YiUyMiklMEF1cmwlMjAlM0QlMjAlMjJodHRwJTNBJTJGJTJGaW1hZ2VzLmNvY29kYXRhc2V0Lm9yZyUyRnZhbDIwMTclMkYwMDAwMDAwMzk3NjkuanBnJTIyJTBBaW1hZ2UlMjAlM0QlMjBJbWFnZS5vcGVuKHJlcXVlc3RzLmdldCh1cmwlMkMlMjBzdHJlYW0lM0RUcnVlKS5yYXcpJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKGltYWdlcyUzRGltYWdlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikudG8oZGV2aWNlJTJDJTIwdG9yY2guZmxvYXQxNiklMEFpbWFnZV9vdXRwdXRzJTIwJTNEJTIwbW9kZWwuZ2V0X2ltYWdlX2ZlYXR1cmVzKCoqaW5wdXRzKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, Blip2Model

<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&quot;cuda&quot;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cpu&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>model = Blip2Model.from_pretrained(<span class="hljs-string">&quot;Salesforce/blip2-opt-2.7b&quot;</span>, torch_dtype=torch.float16)

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