import{S as yf,i as kf,s as Tf,e as s,k as f,w as $,t as n,M as Pf,c as a,d as o,m,a as i,x as w,h as r,b as c,N as xf,G as e,g as _,y as B,q as y,o as k,B as T,v as Cf,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 je}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as X}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Ce}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Ef(x){let d,b,u,h,v;return h=new je({props:{code:`from transformers import (
    Blip2VisionConfig,
    Blip2QFormerConfig,
    OPTConfig,
    Blip2Config,
    Blip2ForConditionalGeneration,
)

# Initializing a Blip2Config with Salesforce/blip2-opt-2.7b style configuration
configuration = Blip2Config()

# Initializing a Blip2ForConditionalGeneration (with random weights) from the Salesforce/blip2-opt-2.7b style configuration
model = Blip2ForConditionalGeneration(configuration)

# Accessing the model configuration
configuration = model.config

# We can also initialize a Blip2Config from a Blip2VisionConfig, Blip2QFormerConfig and any PretrainedConfig

# Initializing BLIP-2 vision, BLIP-2 Q-Former and language model configurations
vision_config = Blip2VisionConfig()
qformer_config = Blip2QFormerConfig()
text_config = OPTConfig()

config = Blip2Config.from_text_vision_configs(vision_config, qformer_config, text_config)`,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=s("p"),b=n("Example:"),u=f(),$(h.$$.fragment)},l(l){d=a(l,"P",{});var p=i(d);b=r(p,"Example:"),p.forEach(o),u=m(l),w(h.$$.fragment,l)},m(l,p){_(l,d,p),e(d,b),_(l,u,p),B(h,l,p),v=!0},p:Ee,i(l){v||(y(h.$$.fragment,l),v=!0)},o(l){k(h.$$.fragment,l),v=!1},d(l){l&&o(d),l&&o(u),T(h,l)}}}function jf(x){let d,b,u,h,v;return h=new je({props:{code:`from transformers import Blip2VisionConfig, Blip2VisionModel

# Initializing a Blip2VisionConfig with Salesforce/blip2-opt-2.7b style configuration
configuration = Blip2VisionConfig()

# Initializing a Blip2VisionModel (with random weights) from the Salesforce/blip2-opt-2.7b style configuration
model = Blip2VisionModel(configuration)

# Accessing the model configuration
configuration = model.config`,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=s("p"),b=n("Example:"),u=f(),$(h.$$.fragment)},l(l){d=a(l,"P",{});var p=i(d);b=r(p,"Example:"),p.forEach(o),u=m(l),w(h.$$.fragment,l)},m(l,p){_(l,d,p),e(d,b),_(l,u,p),B(h,l,p),v=!0},p:Ee,i(l){v||(y(h.$$.fragment,l),v=!0)},o(l){k(h.$$.fragment,l),v=!1},d(l){l&&o(d),l&&o(u),T(h,l)}}}function qf(x){let d,b,u,h,v;return h=new je({props:{code:`from transformers import Blip2QFormerConfig, Blip2QFormerModel

# Initializing a BLIP-2 Salesforce/blip2-opt-2.7b style configuration
configuration = Blip2QFormerConfig()

# Initializing a model (with random weights) from the Salesforce/blip2-opt-2.7b style configuration
model = Blip2QFormerModel(configuration)
# Accessing the model configuration
configuration = model.config`,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=s("p"),b=n("Examples:"),u=f(),$(h.$$.fragment)},l(l){d=a(l,"P",{});var p=i(d);b=r(p,"Examples:"),p.forEach(o),u=m(l),w(h.$$.fragment,l)},m(l,p){_(l,d,p),e(d,b),_(l,u,p),B(h,l,p),v=!0},p:Ee,i(l){v||(y(h.$$.fragment,l),v=!0)},o(l){k(h.$$.fragment,l),v=!1},d(l){l&&o(d),l&&o(u),T(h,l)}}}function Mf(x){let d,b,u,h,v;return{c(){d=s("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=s("code"),h=n("Module"),v=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=a(l,"P",{});var p=i(d);b=r(p,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=a(p,"CODE",{});var E=i(u);h=r(E,"Module"),E.forEach(o),v=r(p,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),p.forEach(o)},m(l,p){_(l,d,p),e(d,b),e(d,u),e(u,h),e(d,v)},d(l){l&&o(d)}}}function zf(x){let d,b,u,h,v;return{c(){d=s("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=s("code"),h=n("Module"),v=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=a(l,"P",{});var p=i(d);b=r(p,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=a(p,"CODE",{});var E=i(u);h=r(E,"Module"),E.forEach(o),v=r(p,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),p.forEach(o)},m(l,p){_(l,d,p),e(d,b),e(d,u),e(u,h),e(d,v)},d(l){l&&o(d)}}}function If(x){let d,b,u,h,v;return h=new je({props:{code:`from PIL import Image
import requests
from transformers import Blip2Processor, Blip2Model
import torch

device = "cuda" if torch.cuda.is_available() else "cpu"

processor = Blip2Processor.from_pretrained("Salesforce/blip2-opt-2.7b")
model = Blip2Model.from_pretrained("Salesforce/blip2-opt-2.7b", torch_dtype=torch.float16)
model.to(device)
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)

prompt = "Question: how many cats are there? Answer:"
inputs = processor(images=image, text=prompt, return_tensors="pt").to(device, torch.float16)

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

device = "cuda" if torch.cuda.is_available() else "cpu"

model = Blip2Model.from_pretrained("Salesforce/blip2-opt-2.7b", torch_dtype=torch.float16)

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

device = "cuda" if torch.cuda.is_available() else "cpu"

model = Blip2Model.from_pretrained("Salesforce/blip2-opt-2.7b", torch_dtype=torch.float16)

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

device = "cuda" if torch.cuda.is_available() else "cpu"

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

device = "cuda" if torch.cuda.is_available() else "cpu"

processor = Blip2Processor.from_pretrained("Salesforce/blip2-opt-2.7b")
model = Blip2ForConditionalGeneration.from_pretrained(
    "Salesforce/blip2-opt-2.7b", torch_dtype=torch.float16
)
model.to(device)
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)

inputs = processor(images=image, return_tensors="pt").to(device, torch.float16)

generated_ids = model.generate(**inputs)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()
print(generated_text)`,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=s("p"),b=n("Image captioning (without providing a text prompt):"),u=f(),$(h.$$.fragment)},l(l){d=a(l,"P",{});var p=i(d);b=r(p,"Image captioning (without providing a text prompt):"),p.forEach(o),u=m(l),w(h.$$.fragment,l)},m(l,p){_(l,d,p),e(d,b),_(l,u,p),B(h,l,p),v=!0},p:Ee,i(l){v||(y(h.$$.fragment,l),v=!0)},o(l){k(h.$$.fragment,l),v=!1},d(l){l&&o(d),l&&o(u),T(h,l)}}}function Nf(x){let d,b,u,h,v;return h=new je({props:{code:`from PIL import Image
import requests
from transformers import Blip2Processor, Blip2ForConditionalGeneration
import torch

device = "cuda" if torch.cuda.is_available() else "cpu"

processor = Blip2Processor.from_pretrained("Salesforce/blip2-opt-2.7b")
model = Blip2ForConditionalGeneration.from_pretrained(
    "Salesforce/blip2-opt-2.7b", torch_dtype=torch.float16
)
model.to(device)
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)

prompt = "Question: how many cats are there? Answer:"
inputs = processor(images=image, text=prompt, return_tensors="pt").to(device, torch.float16)

generated_ids = model.generate(**inputs)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()
print(generated_text)`,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=s("p"),b=n("Visual question answering (prompt = question):"),u=f(),$(h.$$.fragment)},l(l){d=a(l,"P",{});var p=i(d);b=r(p,"Visual question answering (prompt = question):"),p.forEach(o),u=m(l),w(h.$$.fragment,l)},m(l,p){_(l,d,p),e(d,b),_(l,u,p),B(h,l,p),v=!0},p:Ee,i(l){v||(y(h.$$.fragment,l),v=!0)},o(l){k(h.$$.fragment,l),v=!1},d(l){l&&o(d),l&&o(u),T(h,l)}}}function Gf(x){let d,b,u,h,v,l,p,E,Ls,qr,ae,qe,gn,ht,As,un,Os,Mr,Y,Ss,gt,Ds,Qs,ut,Vs,Ns,zr,vo,Gs,Ir,bo,_n,Ws,Fr,$o,Hs,Lr,Me,_t,Rs,vn,Us,Js,Ks,vt,Xs,wo,Ys,Zs,Ar,ze,Tc,Or,bt,ea,Bo,ta,Sr,Z,oa,$t,na,ra,wt,sa,aa,Dr,ie,Ie,bn,Bt,ia,$n,la,Qr,yo,da,Vr,ko,yt,ca,kt,pa,fa,Nr,To,ma,Gr,le,Fe,wn,Tt,ha,Bn,ga,Wr,A,Pt,ua,ee,Po,_a,va,xo,ba,$a,xt,wa,Ba,ya,de,ka,Co,Ta,Pa,Eo,xa,Ca,Ea,Le,ja,Ae,Ct,qa,Et,Ma,jo,za,Ia,Hr,ce,Oe,yn,jt,Fa,kn,La,Rr,Q,qt,Aa,pe,Oa,qo,Sa,Da,Mt,Qa,Va,Na,fe,Ga,Mo,Wa,Ha,zo,Ra,Ua,Ja,Se,Ur,me,De,Tn,zt,Ka,Pn,Xa,Jr,V,It,Ya,N,Za,Io,ei,ti,Ft,oi,ni,Fo,ri,si,Lo,ai,ii,li,he,di,Ao,ci,pi,Oo,fi,mi,hi,Qe,Kr,ge,Ve,xn,Lt,gi,Cn,ui,Xr,O,At,_i,En,vi,bi,S,So,$i,wi,Do,Bi,yi,Qo,ki,Ti,jn,Pi,xi,Vo,Ci,Ei,ji,Ne,Ot,qi,St,Mi,No,zi,Ii,Fi,Ge,Dt,Li,Qt,Ai,Go,Oi,Si,Yr,ue,We,qn,Vt,Di,Mn,Qi,Zr,_e,Nt,Vi,te,Gt,Ni,ve,Gi,Wo,Wi,Hi,zn,Ri,Ui,Ji,He,es,be,Re,In,Wt,Ki,Fn,Xi,ts,J,Ht,Yi,Ln,Zi,el,oe,Rt,tl,q,ol,An,nl,rl,On,sl,al,Sn,il,ll,Dn,dl,cl,Qn,pl,fl,Vn,ml,hl,Nn,gl,ul,_l,Ut,Jt,vl,Gn,bl,$l,wl,P,Bl,Wn,yl,kl,Hn,Tl,Pl,Rn,xl,Cl,Un,El,jl,Jn,ql,Ml,Kn,zl,Il,Xn,Fl,Ll,Yn,Al,Ol,Zn,Sl,Dl,er,Ql,Vl,tr,Nl,Gl,or,Wl,Hl,nr,Rl,Ul,rr,Jl,Kl,os,$e,Ue,sr,Kt,Xl,ar,Yl,ns,j,Xt,Zl,ir,ed,td,Yt,od,Ho,nd,rd,sd,Zt,ad,eo,id,ld,dd,G,to,cd,we,pd,Ro,fd,md,lr,hd,gd,ud,Je,_d,Ke,vd,W,oo,bd,Be,$d,Uo,wd,Bd,dr,yd,kd,Td,Xe,Pd,Ye,xd,H,no,Cd,ye,Ed,Jo,jd,qd,cr,Md,zd,Id,Ze,Fd,et,Ld,R,ro,Ad,ke,Od,Ko,Sd,Dd,pr,Qd,Vd,Nd,tt,Gd,ot,rs,Te,nt,fr,so,Wd,mr,Hd,ss,M,ao,Rd,hr,Ud,Jd,io,Kd,gr,Xd,Yd,Zd,lo,ec,Xo,tc,oc,nc,co,rc,po,sc,ac,ic,I,fo,lc,Pe,dc,Yo,cc,pc,ur,fc,mc,hc,rt,gc,_r,uc,_c,st,vc,at,bc,it,mo,$c,ho,wc,vr,Bc,yc,as;return l=new X({}),ht=new X({}),Bt=new X({}),Tt=new X({}),Pt=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/v4.27.1/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/v4.27.1/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/v4.27.1/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/v4.27.1/src/transformers/models/blip_2/configuration_blip_2.py#L264"}}),Le=new Ce({props:{anchor:"transformers.Blip2Config.example",$$slots:{default:[Ef]},$$scope:{ctx:x}}}),Ct=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/v4.27.1/src/transformers/models/blip_2/configuration_blip_2.py#L349",returnDescription:`
<p>An instance of a configuration object</p>
`,returnType:`
<p><a
  href="/docs/transformers/v4.27.1/en/model_doc/blip-2#transformers.Blip2Config"
>Blip2Config</a></p>
`}}),jt=new X({}),qt=new z({props:{name:"class transformers.Blip2VisionConfig",anchor:"transformers.Blip2VisionConfig",parameters:[{name:"hidden_size",val:" = 1408"},{name:"intermediate_size",val:" = 6144"},{name:"projection_dim",val:" = 512"},{name:"num_hidden_layers",val:" = 39"},{name:"num_attention_heads",val:" = 16"},{name:"num_channels",val:" = 3"},{name:"image_size",val:" = 224"},{name:"patch_size",val:" = 14"},{name:"hidden_act",val:" = 'gelu'"},{name:"layer_norm_eps",val:" = 1e-05"},{name:"dropout",val:" = 0.0"},{name:"attention_dropout",val:" = 0.0"},{name:"initializer_range",val:" = 1e-10"},{name:"initializer_factor",val:" = 1.0"},{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.dropout",description:`<strong>dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout probabilitiy for all fully connected layers in the embeddings, encoder, and pooler.`,name:"dropout"},{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.initializer_factor",description:`<strong>initializer_factor</strong> (\`float&#x201C;, <em>optional</em>, defaults to 1) &#x2014;
A factor for initializing all weight matrices (should be kept to 1, used internally for initialization
testing).`,name:"initializer_factor"},{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/v4.27.1/src/transformers/models/blip_2/configuration_blip_2.py#L34"}}),Se=new Ce({props:{anchor:"transformers.Blip2VisionConfig.example",$$slots:{default:[jf]},$$scope:{ctx:x}}}),zt=new X({}),It=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:"classifier_dropout",val:" = None"},{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.classifier_dropout",description:`<strong>classifier_dropout</strong> (<code>float</code>, <em>optional</em>) &#x2014;
The dropout ratio for the classification head.`,name:"classifier_dropout"},{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/v4.27.1/src/transformers/models/blip_2/configuration_blip_2.py#L144"}}),Qe=new Ce({props:{anchor:"transformers.Blip2QFormerConfig.example",$$slots:{default:[qf]},$$scope:{ctx:x}}}),Lt=new X({}),At=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/v4.27.1/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/v4.27.1/src/transformers/models/blip_2/processing_blip_2.py#L26"}}),Ot=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/v4.27.1/src/transformers/models/blip_2/processing_blip_2.py#L133"}}),Dt=new z({props:{name:"decode",anchor:"transformers.Blip2Processor.decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/blip_2/processing_blip_2.py#L141"}}),Vt=new X({}),Nt=new z({props:{name:"class transformers.Blip2VisionModel",anchor:"transformers.Blip2VisionModel",parameters:[{name:"config",val:": Blip2VisionConfig"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/blip_2/modeling_blip_2.py#L524"}}),Gt=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/v4.27.1/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/v4.27.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/blip_2/modeling_blip_2.py#L539",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.27.1/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/v4.27.1/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling"
>transformers.modeling_outputs.BaseModelOutputWithPooling</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),He=new hn({props:{$$slots:{default:[Mf]},$$scope:{ctx:x}}}),Wt=new X({}),Ht=new z({props:{name:"class transformers.Blip2QFormerModel",anchor:"transformers.Blip2QFormerModel",parameters:[{name:"config",val:": Blip2QFormerConfig"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/blip_2/modeling_blip_2.py#L1019"}}),Rt=new z({props:{name:"forward",anchor:"transformers.Blip2QFormerModel.forward",parameters:[{name:"query_embeds",val:""},{name:"attention_mask",val:" = None"},{name:"head_mask",val:" = None"},{name:"encoder_hidden_states",val:" = None"},{name:"encoder_attention_mask",val:" = None"},{name:"past_key_values",val:" = None"},{name:"use_cache",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/blip_2/modeling_blip_2.py#L1094"}}),Kt=new X({}),Xt=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/v4.27.1/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/v4.27.1/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/v4.27.1/src/transformers/models/blip_2/modeling_blip_2.py#L1219"}}),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/v4.27.1/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/v4.27.1/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/v4.27.1/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.27.1/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/v4.27.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/blip_2/modeling_blip_2.py#L1417",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>
`}}),Je=new hn({props:{$$slots:{default:[zf]},$$scope:{ctx:x}}}),Ke=new Ce({props:{anchor:"transformers.Blip2Model.forward.example",$$slots:{default:[If]},$$scope:{ctx:x}}}),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/v4.27.1/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.27.1/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/v4.27.1/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.27.1/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/v4.27.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/blip_2/modeling_blip_2.py#L1244",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>
`}}),Xe=new hn({props:{$$slots:{default:[Ff]},$$scope:{ctx:x}}}),Ye=new Ce({props:{anchor:"transformers.Blip2Model.get_text_features.example",$$slots:{default:[Lf]},$$scope:{ctx:x}}}),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/v4.27.1/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/v4.27.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/blip_2/modeling_blip_2.py#L1307",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>
`}}),Ze=new hn({props:{$$slots:{default:[Af]},$$scope:{ctx:x}}}),et=new Ce({props:{anchor:"transformers.Blip2Model.get_image_features.example",$$slots:{default:[Of]},$$scope:{ctx:x}}}),ro=new z({props:{name:"get_qformer_features",anchor:"transformers.Blip2Model.get_qformer_features",parameters:[{name:"pixel_values",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.Blip2Model.get_qformer_features.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/v4.27.1/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/v4.27.1/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/v4.27.1/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.27.1/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/v4.27.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/blip_2/modeling_blip_2.py#L1355",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:[Sf]},$$scope:{ctx:x}}}),ot=new Ce({props:{anchor:"transformers.Blip2Model.get_qformer_features.example",$$slots:{default:[Df]},$$scope:{ctx:x}}}),so=new X({}),ao=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/v4.27.1/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/v4.27.1/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/v4.27.1/src/transformers/models/blip_2/modeling_blip_2.py#L1553"}}),fo=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/v4.27.1/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/v4.27.1/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/v4.27.1/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.27.1/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/v4.27.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/blip_2/modeling_blip_2.py#L1618",returnDescription:`
<p>A <code>transformers.models.blip_2.modeling_blip_2.Blip2ForConditionalGenerationModelOutput</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<code>&lt;class 'transformers.models.blip_2.configuration_blip_2.Blip2VisionConfig'&gt;</code>) and inputs.</p>
<ul>
<li><strong>loss</strong> (<code>torch.FloatTensor</code>, <em>optional</em>, returned when <code>labels</code> is provided, <code>torch.FloatTensor</code> of shape <code>(1,)</code>) \u2014 Language modeling loss from the language model.</li>
<li><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head of the language model.</li>
<li><strong>vision_outputs</strong> (<code>BaseModelOutputWithPooling</code>) \u2014 Outputs of the vision encoder.</li>
<li><strong>qformer_outputs</strong> (<code>BaseModelOutputWithPoolingAndCrossAttentions</code>) \u2014 Outputs of the Q-Former (Querying Transformer).</li>
<li><strong>language_model_outputs</strong> (<code>CausalLMOutputWithPast</code> or <code>Seq2SeqLMOutput</code>) \u2014 Outputs of the language model.</li>
</ul>
`,returnType:`
<p><code>transformers.models.blip_2.modeling_blip_2.Blip2ForConditionalGenerationModelOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),rt=new hn({props:{$$slots:{default:[Qf]},$$scope:{ctx:x}}}),st=new Ce({props:{anchor:"transformers.Blip2ForConditionalGeneration.forward.example",$$slots:{default:[Vf]},$$scope:{ctx:x}}}),at=new Ce({props:{anchor:"transformers.Blip2ForConditionalGeneration.forward.example-2",$$slots:{default:[Nf]},$$scope:{ctx:x}}}),mo=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/v4.27.1/src/transformers/models/blip_2/modeling_blip_2.py#L1777",returnDescription:`
<p>A list of strings of length batch_size * num_captions.</p>
`,returnType:`
<p>captions (list)</p>
`}}),{c(){d=s("meta"),b=f(),u=s("h1"),h=s("a"),v=s("span"),$(l.$$.fragment),p=f(),E=s("span"),Ls=n("BLIP-2"),qr=f(),ae=s("h2"),qe=s("a"),gn=s("span"),$(ht.$$.fragment),As=f(),un=s("span"),Os=n("Overview"),Mr=f(),Y=s("p"),Ss=n("The BLIP-2 model was proposed in "),gt=s("a"),Ds=n("BLIP-2: Bootstrapping Language-Image Pre-training with Frozen Image Encoders and Large Language Models"),Qs=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 `),ut=s("a"),Vs=n("Flamingo"),Ns=n(`, an 80 billion parameter model, by 8.7%
on zero-shot VQAv2 with 54x fewer trainable parameters.`),zr=f(),vo=s("p"),Gs=n("The abstract from the paper is the following:"),Ir=f(),bo=s("p"),_n=s("em"),Ws=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."),Fr=f(),$o=s("p"),Hs=n("Tips:"),Lr=f(),Me=s("ul"),_t=s("li"),Rs=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 "),vn=s("code"),Us=n("generate"),Js=n(" method."),Ks=f(),vt=s("li"),Xs=n("One can use "),wo=s("a"),Ys=n("Blip2Processor"),Zs=n(" to prepare images for the model, and decode the predicted tokens ID\u2019s back to text."),Ar=f(),ze=s("img"),Or=f(),bt=s("small"),ea=n("BLIP-2 architecture. Taken from the "),Bo=s("a"),ta=n("original paper."),Sr=f(),Z=s("p"),oa=n("This model was contributed by "),$t=s("a"),na=n("nielsr"),ra=n(`.
The original code can be found `),wt=s("a"),sa=n("here"),aa=n("."),Dr=f(),ie=s("h2"),Ie=s("a"),bn=s("span"),$(Bt.$$.fragment),ia=f(),$n=s("span"),la=n("Resources"),Qr=f(),yo=s("p"),da=n("A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started with BLIP-2."),Vr=f(),ko=s("ul"),yt=s("li"),ca=n("Demo notebooks for BLIP-2 for image captioning, visual question answering (VQA) and chat-like conversations can be found "),kt=s("a"),pa=n("here"),fa=n("."),Nr=f(),To=s("p"),ma=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."),Gr=f(),le=s("h2"),Fe=s("a"),wn=s("span"),$(Tt.$$.fragment),ha=f(),Bn=s("span"),ga=n("Blip2Config"),Wr=f(),A=s("div"),$(Pt.$$.fragment),ua=f(),ee=s("p"),Po=s("a"),_a=n("Blip2Config"),va=n(" is the configuration class to store the configuration of a "),xo=s("a"),ba=n("Blip2ForConditionalGeneration"),$a=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 `),xt=s("a"),wa=n("Salesforce/blip2-opt-2.7b"),Ba=n(" architecture."),ya=f(),de=s("p"),ka=n("Configuration objects inherit from "),Co=s("a"),Ta=n("PretrainedConfig"),Pa=n(` and can be used to control the model outputs. Read the
documentation from `),Eo=s("a"),xa=n("PretrainedConfig"),Ca=n(" for more information."),Ea=f(),$(Le.$$.fragment),ja=f(),Ae=s("div"),$(Ct.$$.fragment),qa=f(),Et=s("p"),Ma=n("Instantiate a "),jo=s("a"),za=n("Blip2Config"),Ia=n(` (or a derived class) from a BLIP-2 vision model, Q-Former and language model
configurations.`),Hr=f(),ce=s("h2"),Oe=s("a"),yn=s("span"),$(jt.$$.fragment),Fa=f(),kn=s("span"),La=n("Blip2VisionConfig"),Rr=f(),Q=s("div"),$(qt.$$.fragment),Aa=f(),pe=s("p"),Oa=n("This is the configuration class to store the configuration of a "),qo=s("a"),Sa=n("Blip2VisionModel"),Da=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
`),Mt=s("a"),Qa=n("Salesforce/blip2-opt-2.7b"),Va=n(" architecture."),Na=f(),fe=s("p"),Ga=n("Configuration objects inherit from "),Mo=s("a"),Wa=n("PretrainedConfig"),Ha=n(` and can be used to control the model outputs. Read the
documentation from `),zo=s("a"),Ra=n("PretrainedConfig"),Ua=n(" for more information."),Ja=f(),$(Se.$$.fragment),Ur=f(),me=s("h2"),De=s("a"),Tn=s("span"),$(zt.$$.fragment),Ka=f(),Pn=s("span"),Xa=n("Blip2QFormerConfig"),Jr=f(),V=s("div"),$(It.$$.fragment),Ya=f(),N=s("p"),Za=n("This is the configuration class to store the configuration of a "),Io=s("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
`),Ft=s("a"),oi=n("Salesforce/blip2-opt-2.7b"),ni=n(` architecture. Configuration objects
inherit from `),Fo=s("a"),ri=n("PretrainedConfig"),si=n(` and can be used to control the model outputs. Read the documentation from
`),Lo=s("a"),ai=n("PretrainedConfig"),ii=n(" for more information."),li=f(),he=s("p"),di=n("Note that "),Ao=s("a"),ci=n("Blip2QFormerModel"),pi=n(" is very similar to "),Oo=s("a"),fi=n("BertLMHeadModel"),mi=n(" with interleaved cross-attention."),hi=f(),$(Qe.$$.fragment),Kr=f(),ge=s("h2"),Ve=s("a"),xn=s("span"),$(Lt.$$.fragment),gi=f(),Cn=s("span"),ui=n("Blip2Processor"),Xr=f(),O=s("div"),$(At.$$.fragment),_i=f(),En=s("p"),vi=n("Constructs a BLIP-2 processor which wraps a BLIP image processor and an OPT/T5 tokenizer into a single processor."),bi=f(),S=s("p"),So=s("a"),$i=n("BlipProcessor"),wi=n(" offers all the functionalities of "),Do=s("a"),Bi=n("BlipImageProcessor"),yi=n(" and "),Qo=s("a"),ki=n("AutoTokenizer"),Ti=n(`. See the docstring
of `),jn=s("code"),Pi=n("__call__()"),xi=n(" and "),Vo=s("a"),Ci=n("decode()"),Ei=n(" for more information."),ji=f(),Ne=s("div"),$(Ot.$$.fragment),qi=f(),St=s("p"),Mi=n("This method forwards all its arguments to PreTrainedTokenizer\u2019s "),No=s("a"),zi=n("batch_decode()"),Ii=n(`. Please
refer to the docstring of this method for more information.`),Fi=f(),Ge=s("div"),$(Dt.$$.fragment),Li=f(),Qt=s("p"),Ai=n("This method forwards all its arguments to PreTrainedTokenizer\u2019s "),Go=s("a"),Oi=n("decode()"),Si=n(`. Please refer
to the docstring of this method for more information.`),Yr=f(),ue=s("h2"),We=s("a"),qn=s("span"),$(Vt.$$.fragment),Di=f(),Mn=s("span"),Qi=n("Blip2VisionModel"),Zr=f(),_e=s("div"),$(Nt.$$.fragment),Vi=f(),te=s("div"),$(Gt.$$.fragment),Ni=f(),ve=s("p"),Gi=n("The "),Wo=s("a"),Wi=n("Blip2VisionModel"),Hi=n(" forward method, overrides the "),zn=s("code"),Ri=n("__call__"),Ui=n(" special method."),Ji=f(),$(He.$$.fragment),es=f(),be=s("h2"),Re=s("a"),In=s("span"),$(Wt.$$.fragment),Ki=f(),Fn=s("span"),Xi=n("Blip2QFormerModel"),ts=f(),J=s("div"),$(Ht.$$.fragment),Yi=f(),Ln=s("p"),Zi=n("Querying Transformer (Q-Former), used in BLIP-2."),el=f(),oe=s("div"),$(Rt.$$.fragment),tl=f(),q=s("p"),ol=n("encoder_hidden_states  ("),An=s("code"),nl=n("torch.FloatTensor"),rl=n(" of shape "),On=s("code"),sl=n("(batch_size, sequence_length, hidden_size)"),al=n(", "),Sn=s("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 (`),Dn=s("code"),dl=n("torch.FloatTensor"),cl=n(" of shape "),Qn=s("code"),pl=n("(batch_size, sequence_length)"),fl=n(", "),Vn=s("code"),ml=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 `),Nn=s("code"),gl=n("[0, 1]"),ul=n(":"),_l=f(),Ut=s("ul"),Jt=s("li"),vl=n("1 for tokens that are "),Gn=s("strong"),bl=n("not masked"),$l=n(","),wl=f(),P=s("li"),Bl=n("0 for tokens that are "),Wn=s("strong"),yl=n("masked"),kl=n(`.
past_key_values (`),Hn=s("code"),Tl=n("tuple(tuple(torch.FloatTensor))"),Pl=n(" of length "),Rn=s("code"),xl=n("config.n_layers"),Cl=n(` with each tuple having 4 tensors of:
shape `),Un=s("code"),El=n("(batch_size, num_heads, sequence_length - 1, embed_size_per_head)"),jl=n(`): Contains precomputed key and
value hidden states of the attention blocks. Can be used to speed up decoding. If `),Jn=s("code"),ql=n("past_key_values"),Ml=n(` are
used, the user can optionally input only the last `),Kn=s("code"),zl=n("decoder_input_ids"),Il=n(` (those that don\u2019t have their past key
value states given to this model) of shape `),Xn=s("code"),Fl=n("(batch_size, 1)"),Ll=n(" instead of all "),Yn=s("code"),Al=n("decoder_input_ids"),Ol=n(` of shape
`),Zn=s("code"),Sl=n("(batch_size, sequence_length)"),Dl=n(`.
use_cache (`),er=s("code"),Ql=n("bool"),Vl=n(", "),tr=s("code"),Nl=n("optional"),Gl=n(`):
If set to `),or=s("code"),Wl=n("True"),Hl=n(", "),nr=s("code"),Rl=n("past_key_values"),Ul=n(` key value states are returned and can be used to speed up decoding (see
`),rr=s("code"),Jl=n("past_key_values"),Kl=n(")."),os=f(),$e=s("h2"),Ue=s("a"),sr=s("span"),$(Kt.$$.fragment),Xl=f(),ar=s("span"),Yl=n("Blip2Model"),ns=f(),j=s("div"),$(Xt.$$.fragment),Zl=f(),ir=s("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=f(),Yt=s("p"),od=n("This model inherits from "),Ho=s("a"),nd=n("PreTrainedModel"),rd=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),sd=f(),Zt=s("p"),ad=n("This model is also a PyTorch "),eo=s("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=f(),G=s("div"),$(to.$$.fragment),cd=f(),we=s("p"),pd=n("The "),Ro=s("a"),fd=n("Blip2Model"),md=n(" forward method, overrides the "),lr=s("code"),hd=n("__call__"),gd=n(" special method."),ud=f(),$(Je.$$.fragment),_d=f(),$(Ke.$$.fragment),vd=f(),W=s("div"),$(oo.$$.fragment),bd=f(),Be=s("p"),$d=n("The "),Uo=s("a"),wd=n("Blip2Model"),Bd=n(" forward method, overrides the "),dr=s("code"),yd=n("__call__"),kd=n(" special method."),Td=f(),$(Xe.$$.fragment),Pd=f(),$(Ye.$$.fragment),xd=f(),H=s("div"),$(no.$$.fragment),Cd=f(),ye=s("p"),Ed=n("The "),Jo=s("a"),jd=n("Blip2Model"),qd=n(" forward method, overrides the "),cr=s("code"),Md=n("__call__"),zd=n(" special method."),Id=f(),$(Ze.$$.fragment),Fd=f(),$(et.$$.fragment),Ld=f(),R=s("div"),$(ro.$$.fragment),Ad=f(),ke=s("p"),Od=n("The "),Ko=s("a"),Sd=n("Blip2Model"),Dd=n(" forward method, overrides the "),pr=s("code"),Qd=n("__call__"),Vd=n(" special method."),Nd=f(),$(tt.$$.fragment),Gd=f(),$(ot.$$.fragment),rs=f(),Te=s("h2"),nt=s("a"),fr=s("span"),$(so.$$.fragment),Wd=f(),mr=s("span"),Hd=n("Blip2ForConditionalGeneration"),ss=f(),M=s("div"),$(ao.$$.fragment),Rd=f(),hr=s("p"),Ud=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.`),Jd=f(),io=s("p"),Kd=n("One can optionally pass "),gr=s("code"),Xd=n("input_ids"),Yd=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.`),Zd=f(),lo=s("p"),ec=n("This model inherits from "),Xo=s("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=f(),co=s("p"),rc=n("This model is also a PyTorch "),po=s("a"),sc=n("torch.nn.Module"),ac=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=f(),I=s("div"),$(fo.$$.fragment),lc=f(),Pe=s("p"),dc=n("The "),Yo=s("a"),cc=n("Blip2ForConditionalGeneration"),pc=n(" forward method, overrides the "),ur=s("code"),fc=n("__call__"),mc=n(" special method."),hc=f(),$(rt.$$.fragment),gc=f(),_r=s("p"),uc=n("Examples:"),_c=f(),$(st.$$.fragment),vc=f(),$(at.$$.fragment),bc=f(),it=s("div"),$(mo.$$.fragment),$c=f(),ho=s("p"),wc=n("Overrides "),vr=s("code"),Bc=n("generate"),yc=n(" function to be able to use the model as a conditional generator."),this.h()},l(t){const g=Pf('[data-svelte="svelte-1phssyn"]',document.head);d=a(g,"META",{name:!0,content:!0}),g.forEach(o),b=m(t),u=a(t,"H1",{class:!0});var go=i(u);h=a(go,"A",{id:!0,class:!0,href:!0});var br=i(h);v=a(br,"SPAN",{});var $r=i(v);w(l.$$.fragment,$r),$r.forEach(o),br.forEach(o),p=m(go),E=a(go,"SPAN",{});var wr=i(E);Ls=r(wr,"BLIP-2"),wr.forEach(o),go.forEach(o),qr=m(t),ae=a(t,"H2",{class:!0});var uo=i(ae);qe=a(uo,"A",{id:!0,class:!0,href:!0});var Br=i(qe);gn=a(Br,"SPAN",{});var yr=i(gn);w(ht.$$.fragment,yr),yr.forEach(o),Br.forEach(o),As=m(uo),un=a(uo,"SPAN",{});var kr=i(un);Os=r(kr,"Overview"),kr.forEach(o),uo.forEach(o),Mr=m(t),Y=a(t,"P",{});var xe=i(Y);Ss=r(xe,"The BLIP-2 model was proposed in "),gt=a(xe,"A",{href:!0,rel:!0});var Tr=i(gt);Ds=r(Tr,"BLIP-2: Bootstrapping Language-Image Pre-training with Frozen Image Encoders and Large Language Models"),Tr.forEach(o),Qs=r(xe,` 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 `),ut=a(xe,"A",{href:!0,rel:!0});var Pr=i(ut);Vs=r(Pr,"Flamingo"),Pr.forEach(o),Ns=r(xe,`, an 80 billion parameter model, by 8.7%
on zero-shot VQAv2 with 54x fewer trainable parameters.`),xe.forEach(o),zr=m(t),vo=a(t,"P",{});var xr=i(vo);Gs=r(xr,"The abstract from the paper is the following:"),xr.forEach(o),Ir=m(t),bo=a(t,"P",{});var Cr=i(bo);_n=a(Cr,"EM",{});var Er=i(_n);Ws=r(Er,"The cost of vision-and-language pre-training has become increasingly prohibitive due to end-to-end training of large-scale models. This paper proposes BLIP-2, a generic and efficient pre-training strategy that bootstraps vision-language pre-training from off-the-shelf frozen pre-trained image encoders and frozen large language models. BLIP-2 bridges the modality gap with a lightweight Querying Transformer, which is pre-trained in two stages. The first stage bootstraps vision-language representation learning from a frozen image encoder. The second stage bootstraps vision-to-language generative learning from a frozen language model. BLIP-2 achieves state-of-the-art performance on various vision-language tasks, despite having significantly fewer trainable parameters than existing methods. For example, our model outperforms Flamingo80B by 8.7% on zero-shot VQAv2 with 54x fewer trainable parameters. We also demonstrate the model\u2019s emerging capabilities of zero-shot image-to-text generation that can follow natural language instructions."),Er.forEach(o),Cr.forEach(o),Fr=m(t),$o=a(t,"P",{});var jr=i($o);Hs=r(jr,"Tips:"),jr.forEach(o),Lr=m(t),Me=a(t,"UL",{});var is=i(Me);_t=a(is,"LI",{});var ls=i(_t);Rs=r(ls,"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 "),vn=a(ls,"CODE",{});var Pc=i(vn);Us=r(Pc,"generate"),Pc.forEach(o),Js=r(ls," method."),ls.forEach(o),Ks=m(is),vt=a(is,"LI",{});var ds=i(vt);Xs=r(ds,"One can use "),wo=a(ds,"A",{href:!0});var xc=i(wo);Ys=r(xc,"Blip2Processor"),xc.forEach(o),Zs=r(ds," to prepare images for the model, and decode the predicted tokens ID\u2019s back to text."),ds.forEach(o),is.forEach(o),Ar=m(t),ze=a(t,"IMG",{src:!0,alt:!0,width:!0}),Or=m(t),bt=a(t,"SMALL",{});var kc=i(bt);ea=r(kc,"BLIP-2 architecture. Taken from the "),Bo=a(kc,"A",{href:!0});var Cc=i(Bo);ta=r(Cc,"original paper."),Cc.forEach(o),kc.forEach(o),Sr=m(t),Z=a(t,"P",{});var Zo=i(Z);oa=r(Zo,"This model was contributed by "),$t=a(Zo,"A",{href:!0,rel:!0});var Ec=i($t);na=r(Ec,"nielsr"),Ec.forEach(o),ra=r(Zo,`.
The original code can be found `),wt=a(Zo,"A",{href:!0,rel:!0});var jc=i(wt);sa=r(jc,"here"),jc.forEach(o),aa=r(Zo,"."),Zo.forEach(o),Dr=m(t),ie=a(t,"H2",{class:!0});var cs=i(ie);Ie=a(cs,"A",{id:!0,class:!0,href:!0});var qc=i(Ie);bn=a(qc,"SPAN",{});var Mc=i(bn);w(Bt.$$.fragment,Mc),Mc.forEach(o),qc.forEach(o),ia=m(cs),$n=a(cs,"SPAN",{});var zc=i($n);la=r(zc,"Resources"),zc.forEach(o),cs.forEach(o),Qr=m(t),yo=a(t,"P",{});var Ic=i(yo);da=r(Ic,"A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started with BLIP-2."),Ic.forEach(o),Vr=m(t),ko=a(t,"UL",{});var Fc=i(ko);yt=a(Fc,"LI",{});var ps=i(yt);ca=r(ps,"Demo notebooks for BLIP-2 for image captioning, visual question answering (VQA) and chat-like conversations can be found "),kt=a(ps,"A",{href:!0,rel:!0});var Lc=i(kt);pa=r(Lc,"here"),Lc.forEach(o),fa=r(ps,"."),ps.forEach(o),Fc.forEach(o),Nr=m(t),To=a(t,"P",{});var Ac=i(To);ma=r(Ac,"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."),Ac.forEach(o),Gr=m(t),le=a(t,"H2",{class:!0});var fs=i(le);Fe=a(fs,"A",{id:!0,class:!0,href:!0});var Oc=i(Fe);wn=a(Oc,"SPAN",{});var Sc=i(wn);w(Tt.$$.fragment,Sc),Sc.forEach(o),Oc.forEach(o),ha=m(fs),Bn=a(fs,"SPAN",{});var Dc=i(Bn);ga=r(Dc,"Blip2Config"),Dc.forEach(o),fs.forEach(o),Wr=m(t),A=a(t,"DIV",{class:!0});var ne=i(A);w(Pt.$$.fragment,ne),ua=m(ne),ee=a(ne,"P",{});var _o=i(ee);Po=a(_o,"A",{href:!0});var Qc=i(Po);_a=r(Qc,"Blip2Config"),Qc.forEach(o),va=r(_o," is the configuration class to store the configuration of a "),xo=a(_o,"A",{href:!0});var Vc=i(xo);ba=r(Vc,"Blip2ForConditionalGeneration"),Vc.forEach(o),$a=r(_o,`. It is
used to instantiate a BLIP-2 model according to the specified arguments, defining the vision model, Q-Former model
and language model configs. Instantiating a configuration with the defaults will yield a similar configuration to
that of the BLIP-2 `),xt=a(_o,"A",{href:!0,rel:!0});var Nc=i(xt);wa=r(Nc,"Salesforce/blip2-opt-2.7b"),Nc.forEach(o),Ba=r(_o," architecture."),_o.forEach(o),ya=m(ne),de=a(ne,"P",{});var en=i(de);ka=r(en,"Configuration objects inherit from "),Co=a(en,"A",{href:!0});var Gc=i(Co);Ta=r(Gc,"PretrainedConfig"),Gc.forEach(o),Pa=r(en,` and can be used to control the model outputs. Read the
documentation from `),Eo=a(en,"A",{href:!0});var Wc=i(Eo);xa=r(Wc,"PretrainedConfig"),Wc.forEach(o),Ca=r(en," for more information."),en.forEach(o),Ea=m(ne),w(Le.$$.fragment,ne),ja=m(ne),Ae=a(ne,"DIV",{class:!0});var ms=i(Ae);w(Ct.$$.fragment,ms),qa=m(ms),Et=a(ms,"P",{});var hs=i(Et);Ma=r(hs,"Instantiate a "),jo=a(hs,"A",{href:!0});var Hc=i(jo);za=r(Hc,"Blip2Config"),Hc.forEach(o),Ia=r(hs,` (or a derived class) from a BLIP-2 vision model, Q-Former and language model
configurations.`),hs.forEach(o),ms.forEach(o),ne.forEach(o),Hr=m(t),ce=a(t,"H2",{class:!0});var gs=i(ce);Oe=a(gs,"A",{id:!0,class:!0,href:!0});var Rc=i(Oe);yn=a(Rc,"SPAN",{});var Uc=i(yn);w(jt.$$.fragment,Uc),Uc.forEach(o),Rc.forEach(o),Fa=m(gs),kn=a(gs,"SPAN",{});var Jc=i(kn);La=r(Jc,"Blip2VisionConfig"),Jc.forEach(o),gs.forEach(o),Rr=m(t),Q=a(t,"DIV",{class:!0});var lt=i(Q);w(qt.$$.fragment,lt),Aa=m(lt),pe=a(lt,"P",{});var tn=i(pe);Oa=r(tn,"This is the configuration class to store the configuration of a "),qo=a(tn,"A",{href:!0});var Kc=i(qo);Sa=r(Kc,"Blip2VisionModel"),Kc.forEach(o),Da=r(tn,`. It is used to instantiate a
BLIP-2 vision encoder according to the specified arguments, defining the model architecture. Instantiating a
configuration defaults will yield a similar configuration to that of the BLIP-2
`),Mt=a(tn,"A",{href:!0,rel:!0});var Xc=i(Mt);Qa=r(Xc,"Salesforce/blip2-opt-2.7b"),Xc.forEach(o),Va=r(tn," architecture."),tn.forEach(o),Na=m(lt),fe=a(lt,"P",{});var on=i(fe);Ga=r(on,"Configuration objects inherit from "),Mo=a(on,"A",{href:!0});var Yc=i(Mo);Wa=r(Yc,"PretrainedConfig"),Yc.forEach(o),Ha=r(on,` and can be used to control the model outputs. Read the
documentation from `),zo=a(on,"A",{href:!0});var Zc=i(zo);Ra=r(Zc,"PretrainedConfig"),Zc.forEach(o),Ua=r(on," for more information."),on.forEach(o),Ja=m(lt),w(Se.$$.fragment,lt),lt.forEach(o),Ur=m(t),me=a(t,"H2",{class:!0});var us=i(me);De=a(us,"A",{id:!0,class:!0,href:!0});var ep=i(De);Tn=a(ep,"SPAN",{});var tp=i(Tn);w(zt.$$.fragment,tp),tp.forEach(o),ep.forEach(o),Ka=m(us),Pn=a(us,"SPAN",{});var op=i(Pn);Xa=r(op,"Blip2QFormerConfig"),op.forEach(o),us.forEach(o),Jr=m(t),V=a(t,"DIV",{class:!0});var dt=i(V);w(It.$$.fragment,dt),Ya=m(dt),N=a(dt,"P",{});var re=i(N);Za=r(re,"This is the configuration class to store the configuration of a "),Io=a(re,"A",{href:!0});var np=i(Io);ei=r(np,"Blip2QFormerModel"),np.forEach(o),ti=r(re,`. It is used to instantiate a
BLIP-2 Querying Transformer (Q-Former) model according to the specified arguments, defining the model architecture.
Instantiating a configuration with the defaults will yield a similar configuration to that of the BLIP-2
`),Ft=a(re,"A",{href:!0,rel:!0});var rp=i(Ft);oi=r(rp,"Salesforce/blip2-opt-2.7b"),rp.forEach(o),ni=r(re,` architecture. Configuration objects
inherit from `),Fo=a(re,"A",{href:!0});var sp=i(Fo);ri=r(sp,"PretrainedConfig"),sp.forEach(o),si=r(re,` and can be used to control the model outputs. Read the documentation from
`),Lo=a(re,"A",{href:!0});var ap=i(Lo);ai=r(ap,"PretrainedConfig"),ap.forEach(o),ii=r(re," for more information."),re.forEach(o),li=m(dt),he=a(dt,"P",{});var nn=i(he);di=r(nn,"Note that "),Ao=a(nn,"A",{href:!0});var ip=i(Ao);ci=r(ip,"Blip2QFormerModel"),ip.forEach(o),pi=r(nn," is very similar to "),Oo=a(nn,"A",{href:!0});var lp=i(Oo);fi=r(lp,"BertLMHeadModel"),lp.forEach(o),mi=r(nn," with interleaved cross-attention."),nn.forEach(o),hi=m(dt),w(Qe.$$.fragment,dt),dt.forEach(o),Kr=m(t),ge=a(t,"H2",{class:!0});var _s=i(ge);Ve=a(_s,"A",{id:!0,class:!0,href:!0});var dp=i(Ve);xn=a(dp,"SPAN",{});var cp=i(xn);w(Lt.$$.fragment,cp),cp.forEach(o),dp.forEach(o),gi=m(_s),Cn=a(_s,"SPAN",{});var pp=i(Cn);ui=r(pp,"Blip2Processor"),pp.forEach(o),_s.forEach(o),Xr=m(t),O=a(t,"DIV",{class:!0});var se=i(O);w(At.$$.fragment,se),_i=m(se),En=a(se,"P",{});var fp=i(En);vi=r(fp,"Constructs a BLIP-2 processor which wraps a BLIP image processor and an OPT/T5 tokenizer into a single processor."),fp.forEach(o),bi=m(se),S=a(se,"P",{});var K=i(S);So=a(K,"A",{href:!0});var mp=i(So);$i=r(mp,"BlipProcessor"),mp.forEach(o),wi=r(K," offers all the functionalities of "),Do=a(K,"A",{href:!0});var hp=i(Do);Bi=r(hp,"BlipImageProcessor"),hp.forEach(o),yi=r(K," and "),Qo=a(K,"A",{href:!0});var gp=i(Qo);ki=r(gp,"AutoTokenizer"),gp.forEach(o),Ti=r(K,`. See the docstring
of `),jn=a(K,"CODE",{});var up=i(jn);Pi=r(up,"__call__()"),up.forEach(o),xi=r(K," and "),Vo=a(K,"A",{href:!0});var _p=i(Vo);Ci=r(_p,"decode()"),_p.forEach(o),Ei=r(K," for more information."),K.forEach(o),ji=m(se),Ne=a(se,"DIV",{class:!0});var vs=i(Ne);w(Ot.$$.fragment,vs),qi=m(vs),St=a(vs,"P",{});var bs=i(St);Mi=r(bs,"This method forwards all its arguments to PreTrainedTokenizer\u2019s "),No=a(bs,"A",{href:!0});var vp=i(No);zi=r(vp,"batch_decode()"),vp.forEach(o),Ii=r(bs,`. Please
refer to the docstring of this method for more information.`),bs.forEach(o),vs.forEach(o),Fi=m(se),Ge=a(se,"DIV",{class:!0});var $s=i(Ge);w(Dt.$$.fragment,$s),Li=m($s),Qt=a($s,"P",{});var ws=i(Qt);Ai=r(ws,"This method forwards all its arguments to PreTrainedTokenizer\u2019s "),Go=a(ws,"A",{href:!0});var bp=i(Go);Oi=r(bp,"decode()"),bp.forEach(o),Si=r(ws,`. Please refer
to the docstring of this method for more information.`),ws.forEach(o),$s.forEach(o),se.forEach(o),Yr=m(t),ue=a(t,"H2",{class:!0});var Bs=i(ue);We=a(Bs,"A",{id:!0,class:!0,href:!0});var $p=i(We);qn=a($p,"SPAN",{});var wp=i(qn);w(Vt.$$.fragment,wp),wp.forEach(o),$p.forEach(o),Di=m(Bs),Mn=a(Bs,"SPAN",{});var Bp=i(Mn);Qi=r(Bp,"Blip2VisionModel"),Bp.forEach(o),Bs.forEach(o),Zr=m(t),_e=a(t,"DIV",{class:!0});var ys=i(_e);w(Nt.$$.fragment,ys),Vi=m(ys),te=a(ys,"DIV",{class:!0});var rn=i(te);w(Gt.$$.fragment,rn),Ni=m(rn),ve=a(rn,"P",{});var sn=i(ve);Gi=r(sn,"The "),Wo=a(sn,"A",{href:!0});var yp=i(Wo);Wi=r(yp,"Blip2VisionModel"),yp.forEach(o),Hi=r(sn," forward method, overrides the "),zn=a(sn,"CODE",{});var kp=i(zn);Ri=r(kp,"__call__"),kp.forEach(o),Ui=r(sn," special method."),sn.forEach(o),Ji=m(rn),w(He.$$.fragment,rn),rn.forEach(o),ys.forEach(o),es=m(t),be=a(t,"H2",{class:!0});var ks=i(be);Re=a(ks,"A",{id:!0,class:!0,href:!0});var Tp=i(Re);In=a(Tp,"SPAN",{});var Pp=i(In);w(Wt.$$.fragment,Pp),Pp.forEach(o),Tp.forEach(o),Ki=m(ks),Fn=a(ks,"SPAN",{});var xp=i(Fn);Xi=r(xp,"Blip2QFormerModel"),xp.forEach(o),ks.forEach(o),ts=m(t),J=a(t,"DIV",{class:!0});var an=i(J);w(Ht.$$.fragment,an),Yi=m(an),Ln=a(an,"P",{});var Cp=i(Ln);Zi=r(Cp,"Querying Transformer (Q-Former), used in BLIP-2."),Cp.forEach(o),el=m(an),oe=a(an,"DIV",{class:!0});var ln=i(oe);w(Rt.$$.fragment,ln),tl=m(ln),q=a(ln,"P",{});var F=i(q);ol=r(F,"encoder_hidden_states  ("),An=a(F,"CODE",{});var Ep=i(An);nl=r(Ep,"torch.FloatTensor"),Ep.forEach(o),rl=r(F," of shape "),On=a(F,"CODE",{});var jp=i(On);sl=r(jp,"(batch_size, sequence_length, hidden_size)"),jp.forEach(o),al=r(F,", "),Sn=a(F,"CODE",{});var qp=i(Sn);il=r(qp,"optional"),qp.forEach(o),ll=r(F,`):
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 (`),Dn=a(F,"CODE",{});var Mp=i(Dn);dl=r(Mp,"torch.FloatTensor"),Mp.forEach(o),cl=r(F," of shape "),Qn=a(F,"CODE",{});var zp=i(Qn);pl=r(zp,"(batch_size, sequence_length)"),zp.forEach(o),fl=r(F,", "),Vn=a(F,"CODE",{});var Ip=i(Vn);ml=r(Ip,"optional"),Ip.forEach(o),hl=r(F,`):
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 `),Nn=a(F,"CODE",{});var Fp=i(Nn);gl=r(Fp,"[0, 1]"),Fp.forEach(o),ul=r(F,":"),F.forEach(o),_l=m(ln),Ut=a(ln,"UL",{});var Ts=i(Ut);Jt=a(Ts,"LI",{});var Ps=i(Jt);vl=r(Ps,"1 for tokens that are "),Gn=a(Ps,"STRONG",{});var Lp=i(Gn);bl=r(Lp,"not masked"),Lp.forEach(o),$l=r(Ps,","),Ps.forEach(o),wl=m(Ts),P=a(Ts,"LI",{});var C=i(P);Bl=r(C,"0 for tokens that are "),Wn=a(C,"STRONG",{});var Ap=i(Wn);yl=r(Ap,"masked"),Ap.forEach(o),kl=r(C,`.
past_key_values (`),Hn=a(C,"CODE",{});var Op=i(Hn);Tl=r(Op,"tuple(tuple(torch.FloatTensor))"),Op.forEach(o),Pl=r(C," of length "),Rn=a(C,"CODE",{});var Sp=i(Rn);xl=r(Sp,"config.n_layers"),Sp.forEach(o),Cl=r(C,` with each tuple having 4 tensors of:
shape `),Un=a(C,"CODE",{});var Dp=i(Un);El=r(Dp,"(batch_size, num_heads, sequence_length - 1, embed_size_per_head)"),Dp.forEach(o),jl=r(C,`): Contains precomputed key and
value hidden states of the attention blocks. Can be used to speed up decoding. If `),Jn=a(C,"CODE",{});var Qp=i(Jn);ql=r(Qp,"past_key_values"),Qp.forEach(o),Ml=r(C,` are
used, the user can optionally input only the last `),Kn=a(C,"CODE",{});var Vp=i(Kn);zl=r(Vp,"decoder_input_ids"),Vp.forEach(o),Il=r(C,` (those that don\u2019t have their past key
value states given to this model) of shape `),Xn=a(C,"CODE",{});var Np=i(Xn);Fl=r(Np,"(batch_size, 1)"),Np.forEach(o),Ll=r(C," instead of all "),Yn=a(C,"CODE",{});var Gp=i(Yn);Al=r(Gp,"decoder_input_ids"),Gp.forEach(o),Ol=r(C,` of shape
`),Zn=a(C,"CODE",{});var Wp=i(Zn);Sl=r(Wp,"(batch_size, sequence_length)"),Wp.forEach(o),Dl=r(C,`.
use_cache (`),er=a(C,"CODE",{});var Hp=i(er);Ql=r(Hp,"bool"),Hp.forEach(o),Vl=r(C,", "),tr=a(C,"CODE",{});var Rp=i(tr);Nl=r(Rp,"optional"),Rp.forEach(o),Gl=r(C,`):
If set to `),or=a(C,"CODE",{});var Up=i(or);Wl=r(Up,"True"),Up.forEach(o),Hl=r(C,", "),nr=a(C,"CODE",{});var Jp=i(nr);Rl=r(Jp,"past_key_values"),Jp.forEach(o),Ul=r(C,` key value states are returned and can be used to speed up decoding (see
`),rr=a(C,"CODE",{});var Kp=i(rr);Jl=r(Kp,"past_key_values"),Kp.forEach(o),Kl=r(C,")."),C.forEach(o),Ts.forEach(o),ln.forEach(o),an.forEach(o),os=m(t),$e=a(t,"H2",{class:!0});var xs=i($e);Ue=a(xs,"A",{id:!0,class:!0,href:!0});var Xp=i(Ue);sr=a(Xp,"SPAN",{});var Yp=i(sr);w(Kt.$$.fragment,Yp),Yp.forEach(o),Xp.forEach(o),Xl=m(xs),ar=a(xs,"SPAN",{});var Zp=i(ar);Yl=r(Zp,"Blip2Model"),Zp.forEach(o),xs.forEach(o),ns=m(t),j=a(t,"DIV",{class:!0});var L=i(j);w(Xt.$$.fragment,L),Zl=m(L),ir=a(L,"P",{});var ef=i(ir);ed=r(ef,`BLIP-2 Model for generating text and image features. The model consists of a vision encoder, Querying Transformer
(Q-Former) and a language model.`),ef.forEach(o),td=m(L),Yt=a(L,"P",{});var Cs=i(Yt);od=r(Cs,"This model inherits from "),Ho=a(Cs,"A",{href:!0});var tf=i(Ho);nd=r(tf,"PreTrainedModel"),tf.forEach(o),rd=r(Cs,`. 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.)`),Cs.forEach(o),sd=m(L),Zt=a(L,"P",{});var Es=i(Zt);ad=r(Es,"This model is also a PyTorch "),eo=a(Es,"A",{href:!0,rel:!0});var of=i(eo);id=r(of,"torch.nn.Module"),of.forEach(o),ld=r(Es,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Es.forEach(o),dd=m(L),G=a(L,"DIV",{class:!0});var ct=i(G);w(to.$$.fragment,ct),cd=m(ct),we=a(ct,"P",{});var dn=i(we);pd=r(dn,"The "),Ro=a(dn,"A",{href:!0});var nf=i(Ro);fd=r(nf,"Blip2Model"),nf.forEach(o),md=r(dn," forward method, overrides the "),lr=a(dn,"CODE",{});var rf=i(lr);hd=r(rf,"__call__"),rf.forEach(o),gd=r(dn," special method."),dn.forEach(o),ud=m(ct),w(Je.$$.fragment,ct),_d=m(ct),w(Ke.$$.fragment,ct),ct.forEach(o),vd=m(L),W=a(L,"DIV",{class:!0});var pt=i(W);w(oo.$$.fragment,pt),bd=m(pt),Be=a(pt,"P",{});var cn=i(Be);$d=r(cn,"The "),Uo=a(cn,"A",{href:!0});var sf=i(Uo);wd=r(sf,"Blip2Model"),sf.forEach(o),Bd=r(cn," forward method, overrides the "),dr=a(cn,"CODE",{});var af=i(dr);yd=r(af,"__call__"),af.forEach(o),kd=r(cn," special method."),cn.forEach(o),Td=m(pt),w(Xe.$$.fragment,pt),Pd=m(pt),w(Ye.$$.fragment,pt),pt.forEach(o),xd=m(L),H=a(L,"DIV",{class:!0});var ft=i(H);w(no.$$.fragment,ft),Cd=m(ft),ye=a(ft,"P",{});var pn=i(ye);Ed=r(pn,"The "),Jo=a(pn,"A",{href:!0});var lf=i(Jo);jd=r(lf,"Blip2Model"),lf.forEach(o),qd=r(pn," forward method, overrides the "),cr=a(pn,"CODE",{});var df=i(cr);Md=r(df,"__call__"),df.forEach(o),zd=r(pn," special method."),pn.forEach(o),Id=m(ft),w(Ze.$$.fragment,ft),Fd=m(ft),w(et.$$.fragment,ft),ft.forEach(o),Ld=m(L),R=a(L,"DIV",{class:!0});var mt=i(R);w(ro.$$.fragment,mt),Ad=m(mt),ke=a(mt,"P",{});var fn=i(ke);Od=r(fn,"The "),Ko=a(fn,"A",{href:!0});var cf=i(Ko);Sd=r(cf,"Blip2Model"),cf.forEach(o),Dd=r(fn," forward method, overrides the "),pr=a(fn,"CODE",{});var pf=i(pr);Qd=r(pf,"__call__"),pf.forEach(o),Vd=r(fn," special method."),fn.forEach(o),Nd=m(mt),w(tt.$$.fragment,mt),Gd=m(mt),w(ot.$$.fragment,mt),mt.forEach(o),L.forEach(o),rs=m(t),Te=a(t,"H2",{class:!0});var js=i(Te);nt=a(js,"A",{id:!0,class:!0,href:!0});var ff=i(nt);fr=a(ff,"SPAN",{});var mf=i(fr);w(so.$$.fragment,mf),mf.forEach(o),ff.forEach(o),Wd=m(js),mr=a(js,"SPAN",{});var hf=i(mr);Hd=r(hf,"Blip2ForConditionalGeneration"),hf.forEach(o),js.forEach(o),ss=m(t),M=a(t,"DIV",{class:!0});var D=i(M);w(ao.$$.fragment,D),Rd=m(D),hr=a(D,"P",{});var gf=i(hr);Ud=r(gf,`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.`),gf.forEach(o),Jd=m(D),io=a(D,"P",{});var qs=i(io);Kd=r(qs,"One can optionally pass "),gr=a(qs,"CODE",{});var uf=i(gr);Xd=r(uf,"input_ids"),uf.forEach(o),Yd=r(qs,` 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.`),qs.forEach(o),Zd=m(D),lo=a(D,"P",{});var Ms=i(lo);ec=r(Ms,"This model inherits from "),Xo=a(Ms,"A",{href:!0});var _f=i(Xo);tc=r(_f,"PreTrainedModel"),_f.forEach(o),oc=r(Ms,`. 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.)`),Ms.forEach(o),nc=m(D),co=a(D,"P",{});var zs=i(co);rc=r(zs,"This model is also a PyTorch "),po=a(zs,"A",{href:!0,rel:!0});var vf=i(po);sc=r(vf,"torch.nn.Module"),vf.forEach(o),ac=r(zs,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),zs.forEach(o),ic=m(D),I=a(D,"DIV",{class:!0});var U=i(I);w(fo.$$.fragment,U),lc=m(U),Pe=a(U,"P",{});var mn=i(Pe);dc=r(mn,"The "),Yo=a(mn,"A",{href:!0});var bf=i(Yo);cc=r(bf,"Blip2ForConditionalGeneration"),bf.forEach(o),pc=r(mn," forward method, overrides the "),ur=a(mn,"CODE",{});var $f=i(ur);fc=r($f,"__call__"),$f.forEach(o),mc=r(mn," special method."),mn.forEach(o),hc=m(U),w(rt.$$.fragment,U),gc=m(U),_r=a(U,"P",{});var wf=i(_r);uc=r(wf,"Examples:"),wf.forEach(o),_c=m(U),w(st.$$.fragment,U),vc=m(U),w(at.$$.fragment,U),U.forEach(o),bc=m(D),it=a(D,"DIV",{class:!0});var Is=i(it);w(mo.$$.fragment,Is),$c=m(Is),ho=a(Is,"P",{});var Fs=i(ho);wc=r(Fs,"Overrides "),vr=a(Fs,"CODE",{});var Bf=i(vr);Bc=r(Bf,"generate"),Bf.forEach(o),yc=r(Fs," function to be able to use the model as a conditional generator."),Fs.forEach(o),Is.forEach(o),D.forEach(o),this.h()},h(){c(d,"name","hf:doc:metadata"),c(d,"content",JSON.stringify(Wf)),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(u,"class","relative group"),c(qe,"id","overview"),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","#overview"),c(ae,"class","relative group"),c(gt,"href","https://arxiv.org/abs/2301.12597"),c(gt,"rel","nofollow"),c(ut,"href","https://arxiv.org/abs/2204.14198"),c(ut,"rel","nofollow"),c(wo,"href","/docs/transformers/v4.27.1/en/model_doc/blip-2#transformers.Blip2Processor"),xf(ze.src,Tc="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/blip2_architecture.jpg")||c(ze,"src",Tc),c(ze,"alt","drawing"),c(ze,"width","600"),c(Bo,"href","https://arxiv.org/abs/2301.12597"),c($t,"href","https://huggingface.co/nielsr"),c($t,"rel","nofollow"),c(wt,"href","https://github.com/salesforce/LAVIS/tree/5ee63d688ba4cebff63acee04adaef2dee9af207"),c(wt,"rel","nofollow"),c(Ie,"id","resources"),c(Ie,"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(Ie,"href","#resources"),c(ie,"class","relative group"),c(kt,"href","https://github.com/NielsRogge/Transformers-Tutorials/tree/master/BLIP-2"),c(kt,"rel","nofollow"),c(Fe,"id","transformers.Blip2Config"),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.Blip2Config"),c(le,"class","relative group"),c(Po,"href","/docs/transformers/v4.27.1/en/model_doc/blip-2#transformers.Blip2Config"),c(xo,"href","/docs/transformers/v4.27.1/en/model_doc/blip-2#transformers.Blip2ForConditionalGeneration"),c(xt,"href","https://huggingface.co/Salesforce/blip2-opt-2.7b"),c(xt,"rel","nofollow"),c(Co,"href","/docs/transformers/v4.27.1/en/main_classes/configuration#transformers.PretrainedConfig"),c(Eo,"href","/docs/transformers/v4.27.1/en/main_classes/configuration#transformers.PretrainedConfig"),c(jo,"href","/docs/transformers/v4.27.1/en/model_doc/blip-2#transformers.Blip2Config"),c(Ae,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),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(Oe,"id","transformers.Blip2VisionConfig"),c(Oe,"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(Oe,"href","#transformers.Blip2VisionConfig"),c(ce,"class","relative group"),c(qo,"href","/docs/transformers/v4.27.1/en/model_doc/blip-2#transformers.Blip2VisionModel"),c(Mt,"href","https://huggingface.co/Salesforce/blip2-opt-2.7b"),c(Mt,"rel","nofollow"),c(Mo,"href","/docs/transformers/v4.27.1/en/main_classes/configuration#transformers.PretrainedConfig"),c(zo,"href","/docs/transformers/v4.27.1/en/main_classes/configuration#transformers.PretrainedConfig"),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(De,"id","transformers.Blip2QFormerConfig"),c(De,"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(De,"href","#transformers.Blip2QFormerConfig"),c(me,"class","relative group"),c(Io,"href","/docs/transformers/v4.27.1/en/model_doc/blip-2#transformers.Blip2QFormerModel"),c(Ft,"href","https://huggingface.co/Salesforce/blip2-opt-2.7b"),c(Ft,"rel","nofollow"),c(Fo,"href","/docs/transformers/v4.27.1/en/main_classes/configuration#transformers.PretrainedConfig"),c(Lo,"href","/docs/transformers/v4.27.1/en/main_classes/configuration#transformers.PretrainedConfig"),c(Ao,"href","/docs/transformers/v4.27.1/en/model_doc/blip-2#transformers.Blip2QFormerModel"),c(Oo,"href","/docs/transformers/v4.27.1/en/model_doc/bert#transformers.BertLMHeadModel"),c(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Ve,"id","transformers.Blip2Processor"),c(Ve,"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(Ve,"href","#transformers.Blip2Processor"),c(ge,"class","relative group"),c(So,"href","/docs/transformers/v4.27.1/en/model_doc/blip#transformers.BlipProcessor"),c(Do,"href","/docs/transformers/v4.27.1/en/model_doc/blip#transformers.BlipImageProcessor"),c(Qo,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.AutoTokenizer"),c(Vo,"href","/docs/transformers/v4.27.1/en/model_doc/blip#transformers.BlipProcessor.decode"),c(No,"href","/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.batch_decode"),c(Ne,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Go,"href","/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.decode"),c(Ge,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(We,"id","transformers.Blip2VisionModel"),c(We,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(We,"href","#transformers.Blip2VisionModel"),c(ue,"class","relative group"),c(Wo,"href","/docs/transformers/v4.27.1/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(Re,"id","transformers.Blip2QFormerModel"),c(Re,"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(Re,"href","#transformers.Blip2QFormerModel"),c(be,"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(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Ue,"id","transformers.Blip2Model"),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","#transformers.Blip2Model"),c($e,"class","relative group"),c(Ho,"href","/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel"),c(eo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(eo,"rel","nofollow"),c(Ro,"href","/docs/transformers/v4.27.1/en/model_doc/blip-2#transformers.Blip2Model"),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(Uo,"href","/docs/transformers/v4.27.1/en/model_doc/blip-2#transformers.Blip2Model"),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(Jo,"href","/docs/transformers/v4.27.1/en/model_doc/blip-2#transformers.Blip2Model"),c(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Ko,"href","/docs/transformers/v4.27.1/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(j,"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(Te,"class","relative group"),c(Xo,"href","/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel"),c(po,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(po,"rel","nofollow"),c(Yo,"href","/docs/transformers/v4.27.1/en/model_doc/blip-2#transformers.Blip2ForConditionalGeneration"),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"),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(M,"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,g){e(document.head,d),_(t,b,g),_(t,u,g),e(u,h),e(h,v),B(l,v,null),e(u,p),e(u,E),e(E,Ls),_(t,qr,g),_(t,ae,g),e(ae,qe),e(qe,gn),B(ht,gn,null),e(ae,As),e(ae,un),e(un,Os),_(t,Mr,g),_(t,Y,g),e(Y,Ss),e(Y,gt),e(gt,Ds),e(Y,Qs),e(Y,ut),e(ut,Vs),e(Y,Ns),_(t,zr,g),_(t,vo,g),e(vo,Gs),_(t,Ir,g),_(t,bo,g),e(bo,_n),e(_n,Ws),_(t,Fr,g),_(t,$o,g),e($o,Hs),_(t,Lr,g),_(t,Me,g),e(Me,_t),e(_t,Rs),e(_t,vn),e(vn,Us),e(_t,Js),e(Me,Ks),e(Me,vt),e(vt,Xs),e(vt,wo),e(wo,Ys),e(vt,Zs),_(t,Ar,g),_(t,ze,g),_(t,Or,g),_(t,bt,g),e(bt,ea),e(bt,Bo),e(Bo,ta),_(t,Sr,g),_(t,Z,g),e(Z,oa),e(Z,$t),e($t,na),e(Z,ra),e(Z,wt),e(wt,sa),e(Z,aa),_(t,Dr,g),_(t,ie,g),e(ie,Ie),e(Ie,bn),B(Bt,bn,null),e(ie,ia),e(ie,$n),e($n,la),_(t,Qr,g),_(t,yo,g),e(yo,da),_(t,Vr,g),_(t,ko,g),e(ko,yt),e(yt,ca),e(yt,kt),e(kt,pa),e(yt,fa),_(t,Nr,g),_(t,To,g),e(To,ma),_(t,Gr,g),_(t,le,g),e(le,Fe),e(Fe,wn),B(Tt,wn,null),e(le,ha),e(le,Bn),e(Bn,ga),_(t,Wr,g),_(t,A,g),B(Pt,A,null),e(A,ua),e(A,ee),e(ee,Po),e(Po,_a),e(ee,va),e(ee,xo),e(xo,ba),e(ee,$a),e(ee,xt),e(xt,wa),e(ee,Ba),e(A,ya),e(A,de),e(de,ka),e(de,Co),e(Co,Ta),e(de,Pa),e(de,Eo),e(Eo,xa),e(de,Ca),e(A,Ea),B(Le,A,null),e(A,ja),e(A,Ae),B(Ct,Ae,null),e(Ae,qa),e(Ae,Et),e(Et,Ma),e(Et,jo),e(jo,za),e(Et,Ia),_(t,Hr,g),_(t,ce,g),e(ce,Oe),e(Oe,yn),B(jt,yn,null),e(ce,Fa),e(ce,kn),e(kn,La),_(t,Rr,g),_(t,Q,g),B(qt,Q,null),e(Q,Aa),e(Q,pe),e(pe,Oa),e(pe,qo),e(qo,Sa),e(pe,Da),e(pe,Mt),e(Mt,Qa),e(pe,Va),e(Q,Na),e(Q,fe),e(fe,Ga),e(fe,Mo),e(Mo,Wa),e(fe,Ha),e(fe,zo),e(zo,Ra),e(fe,Ua),e(Q,Ja),B(Se,Q,null),_(t,Ur,g),_(t,me,g),e(me,De),e(De,Tn),B(zt,Tn,null),e(me,Ka),e(me,Pn),e(Pn,Xa),_(t,Jr,g),_(t,V,g),B(It,V,null),e(V,Ya),e(V,N),e(N,Za),e(N,Io),e(Io,ei),e(N,ti),e(N,Ft),e(Ft,oi),e(N,ni),e(N,Fo),e(Fo,ri),e(N,si),e(N,Lo),e(Lo,ai),e(N,ii),e(V,li),e(V,he),e(he,di),e(he,Ao),e(Ao,ci),e(he,pi),e(he,Oo),e(Oo,fi),e(he,mi),e(V,hi),B(Qe,V,null),_(t,Kr,g),_(t,ge,g),e(ge,Ve),e(Ve,xn),B(Lt,xn,null),e(ge,gi),e(ge,Cn),e(Cn,ui),_(t,Xr,g),_(t,O,g),B(At,O,null),e(O,_i),e(O,En),e(En,vi),e(O,bi),e(O,S),e(S,So),e(So,$i),e(S,wi),e(S,Do),e(Do,Bi),e(S,yi),e(S,Qo),e(Qo,ki),e(S,Ti),e(S,jn),e(jn,Pi),e(S,xi),e(S,Vo),e(Vo,Ci),e(S,Ei),e(O,ji),e(O,Ne),B(Ot,Ne,null),e(Ne,qi),e(Ne,St),e(St,Mi),e(St,No),e(No,zi),e(St,Ii),e(O,Fi),e(O,Ge),B(Dt,Ge,null),e(Ge,Li),e(Ge,Qt),e(Qt,Ai),e(Qt,Go),e(Go,Oi),e(Qt,Si),_(t,Yr,g),_(t,ue,g),e(ue,We),e(We,qn),B(Vt,qn,null),e(ue,Di),e(ue,Mn),e(Mn,Qi),_(t,Zr,g),_(t,_e,g),B(Nt,_e,null),e(_e,Vi),e(_e,te),B(Gt,te,null),e(te,Ni),e(te,ve),e(ve,Gi),e(ve,Wo),e(Wo,Wi),e(ve,Hi),e(ve,zn),e(zn,Ri),e(ve,Ui),e(te,Ji),B(He,te,null),_(t,es,g),_(t,be,g),e(be,Re),e(Re,In),B(Wt,In,null),e(be,Ki),e(be,Fn),e(Fn,Xi),_(t,ts,g),_(t,J,g),B(Ht,J,null),e(J,Yi),e(J,Ln),e(Ln,Zi),e(J,el),e(J,oe),B(Rt,oe,null),e(oe,tl),e(oe,q),e(q,ol),e(q,An),e(An,nl),e(q,rl),e(q,On),e(On,sl),e(q,al),e(q,Sn),e(Sn,il),e(q,ll),e(q,Dn),e(Dn,dl),e(q,cl),e(q,Qn),e(Qn,pl),e(q,fl),e(q,Vn),e(Vn,ml),e(q,hl),e(q,Nn),e(Nn,gl),e(q,ul),e(oe,_l),e(oe,Ut),e(Ut,Jt),e(Jt,vl),e(Jt,Gn),e(Gn,bl),e(Jt,$l),e(Ut,wl),e(Ut,P),e(P,Bl),e(P,Wn),e(Wn,yl),e(P,kl),e(P,Hn),e(Hn,Tl),e(P,Pl),e(P,Rn),e(Rn,xl),e(P,Cl),e(P,Un),e(Un,El),e(P,jl),e(P,Jn),e(Jn,ql),e(P,Ml),e(P,Kn),e(Kn,zl),e(P,Il),e(P,Xn),e(Xn,Fl),e(P,Ll),e(P,Yn),e(Yn,Al),e(P,Ol),e(P,Zn),e(Zn,Sl),e(P,Dl),e(P,er),e(er,Ql),e(P,Vl),e(P,tr),e(tr,Nl),e(P,Gl),e(P,or),e(or,Wl),e(P,Hl),e(P,nr),e(nr,Rl),e(P,Ul),e(P,rr),e(rr,Jl),e(P,Kl),_(t,os,g),_(t,$e,g),e($e,Ue),e(Ue,sr),B(Kt,sr,null),e($e,Xl),e($e,ar),e(ar,Yl),_(t,ns,g),_(t,j,g),B(Xt,j,null),e(j,Zl),e(j,ir),e(ir,ed),e(j,td),e(j,Yt),e(Yt,od),e(Yt,Ho),e(Ho,nd),e(Yt,rd),e(j,sd),e(j,Zt),e(Zt,ad),e(Zt,eo),e(eo,id),e(Zt,ld),e(j,dd),e(j,G),B(to,G,null),e(G,cd),e(G,we),e(we,pd),e(we,Ro),e(Ro,fd),e(we,md),e(we,lr),e(lr,hd),e(we,gd),e(G,ud),B(Je,G,null),e(G,_d),B(Ke,G,null),e(j,vd),e(j,W),B(oo,W,null),e(W,bd),e(W,Be),e(Be,$d),e(Be,Uo),e(Uo,wd),e(Be,Bd),e(Be,dr),e(dr,yd),e(Be,kd),e(W,Td),B(Xe,W,null),e(W,Pd),B(Ye,W,null),e(j,xd),e(j,H),B(no,H,null),e(H,Cd),e(H,ye),e(ye,Ed),e(ye,Jo),e(Jo,jd),e(ye,qd),e(ye,cr),e(cr,Md),e(ye,zd),e(H,Id),B(Ze,H,null),e(H,Fd),B(et,H,null),e(j,Ld),e(j,R),B(ro,R,null),e(R,Ad),e(R,ke),e(ke,Od),e(ke,Ko),e(Ko,Sd),e(ke,Dd),e(ke,pr),e(pr,Qd),e(ke,Vd),e(R,Nd),B(tt,R,null),e(R,Gd),B(ot,R,null),_(t,rs,g),_(t,Te,g),e(Te,nt),e(nt,fr),B(so,fr,null),e(Te,Wd),e(Te,mr),e(mr,Hd),_(t,ss,g),_(t,M,g),B(ao,M,null),e(M,Rd),e(M,hr),e(hr,Ud),e(M,Jd),e(M,io),e(io,Kd),e(io,gr),e(gr,Xd),e(io,Yd),e(M,Zd),e(M,lo),e(lo,ec),e(lo,Xo),e(Xo,tc),e(lo,oc),e(M,nc),e(M,co),e(co,rc),e(co,po),e(po,sc),e(co,ac),e(M,ic),e(M,I),B(fo,I,null),e(I,lc),e(I,Pe),e(Pe,dc),e(Pe,Yo),e(Yo,cc),e(Pe,pc),e(Pe,ur),e(ur,fc),e(Pe,mc),e(I,hc),B(rt,I,null),e(I,gc),e(I,_r),e(_r,uc),e(I,_c),B(st,I,null),e(I,vc),B(at,I,null),e(M,bc),e(M,it),B(mo,it,null),e(it,$c),e(it,ho),e(ho,wc),e(ho,vr),e(vr,Bc),e(ho,yc),as=!0},p(t,[g]){const go={};g&2&&(go.$$scope={dirty:g,ctx:t}),Le.$set(go);const br={};g&2&&(br.$$scope={dirty:g,ctx:t}),Se.$set(br);const $r={};g&2&&($r.$$scope={dirty:g,ctx:t}),Qe.$set($r);const wr={};g&2&&(wr.$$scope={dirty:g,ctx:t}),He.$set(wr);const uo={};g&2&&(uo.$$scope={dirty:g,ctx:t}),Je.$set(uo);const Br={};g&2&&(Br.$$scope={dirty:g,ctx:t}),Ke.$set(Br);const yr={};g&2&&(yr.$$scope={dirty:g,ctx:t}),Xe.$set(yr);const kr={};g&2&&(kr.$$scope={dirty:g,ctx:t}),Ye.$set(kr);const xe={};g&2&&(xe.$$scope={dirty:g,ctx:t}),Ze.$set(xe);const Tr={};g&2&&(Tr.$$scope={dirty:g,ctx:t}),et.$set(Tr);const Pr={};g&2&&(Pr.$$scope={dirty:g,ctx:t}),tt.$set(Pr);const xr={};g&2&&(xr.$$scope={dirty:g,ctx:t}),ot.$set(xr);const Cr={};g&2&&(Cr.$$scope={dirty:g,ctx:t}),rt.$set(Cr);const Er={};g&2&&(Er.$$scope={dirty:g,ctx:t}),st.$set(Er);const jr={};g&2&&(jr.$$scope={dirty:g,ctx:t}),at.$set(jr)},i(t){as||(y(l.$$.fragment,t),y(ht.$$.fragment,t),y(Bt.$$.fragment,t),y(Tt.$$.fragment,t),y(Pt.$$.fragment,t),y(Le.$$.fragment,t),y(Ct.$$.fragment,t),y(jt.$$.fragment,t),y(qt.$$.fragment,t),y(Se.$$.fragment,t),y(zt.$$.fragment,t),y(It.$$.fragment,t),y(Qe.$$.fragment,t),y(Lt.$$.fragment,t),y(At.$$.fragment,t),y(Ot.$$.fragment,t),y(Dt.$$.fragment,t),y(Vt.$$.fragment,t),y(Nt.$$.fragment,t),y(Gt.$$.fragment,t),y(He.$$.fragment,t),y(Wt.$$.fragment,t),y(Ht.$$.fragment,t),y(Rt.$$.fragment,t),y(Kt.$$.fragment,t),y(Xt.$$.fragment,t),y(to.$$.fragment,t),y(Je.$$.fragment,t),y(Ke.$$.fragment,t),y(oo.$$.fragment,t),y(Xe.$$.fragment,t),y(Ye.$$.fragment,t),y(no.$$.fragment,t),y(Ze.$$.fragment,t),y(et.$$.fragment,t),y(ro.$$.fragment,t),y(tt.$$.fragment,t),y(ot.$$.fragment,t),y(so.$$.fragment,t),y(ao.$$.fragment,t),y(fo.$$.fragment,t),y(rt.$$.fragment,t),y(st.$$.fragment,t),y(at.$$.fragment,t),y(mo.$$.fragment,t),as=!0)},o(t){k(l.$$.fragment,t),k(ht.$$.fragment,t),k(Bt.$$.fragment,t),k(Tt.$$.fragment,t),k(Pt.$$.fragment,t),k(Le.$$.fragment,t),k(Ct.$$.fragment,t),k(jt.$$.fragment,t),k(qt.$$.fragment,t),k(Se.$$.fragment,t),k(zt.$$.fragment,t),k(It.$$.fragment,t),k(Qe.$$.fragment,t),k(Lt.$$.fragment,t),k(At.$$.fragment,t),k(Ot.$$.fragment,t),k(Dt.$$.fragment,t),k(Vt.$$.fragment,t),k(Nt.$$.fragment,t),k(Gt.$$.fragment,t),k(He.$$.fragment,t),k(Wt.$$.fragment,t),k(Ht.$$.fragment,t),k(Rt.$$.fragment,t),k(Kt.$$.fragment,t),k(Xt.$$.fragment,t),k(to.$$.fragment,t),k(Je.$$.fragment,t),k(Ke.$$.fragment,t),k(oo.$$.fragment,t),k(Xe.$$.fragment,t),k(Ye.$$.fragment,t),k(no.$$.fragment,t),k(Ze.$$.fragment,t),k(et.$$.fragment,t),k(ro.$$.fragment,t),k(tt.$$.fragment,t),k(ot.$$.fragment,t),k(so.$$.fragment,t),k(ao.$$.fragment,t),k(fo.$$.fragment,t),k(rt.$$.fragment,t),k(st.$$.fragment,t),k(at.$$.fragment,t),k(mo.$$.fragment,t),as=!1},d(t){o(d),t&&o(b),t&&o(u),T(l),t&&o(qr),t&&o(ae),T(ht),t&&o(Mr),t&&o(Y),t&&o(zr),t&&o(vo),t&&o(Ir),t&&o(bo),t&&o(Fr),t&&o($o),t&&o(Lr),t&&o(Me),t&&o(Ar),t&&o(ze),t&&o(Or),t&&o(bt),t&&o(Sr),t&&o(Z),t&&o(Dr),t&&o(ie),T(Bt),t&&o(Qr),t&&o(yo),t&&o(Vr),t&&o(ko),t&&o(Nr),t&&o(To),t&&o(Gr),t&&o(le),T(Tt),t&&o(Wr),t&&o(A),T(Pt),T(Le),T(Ct),t&&o(Hr),t&&o(ce),T(jt),t&&o(Rr),t&&o(Q),T(qt),T(Se),t&&o(Ur),t&&o(me),T(zt),t&&o(Jr),t&&o(V),T(It),T(Qe),t&&o(Kr),t&&o(ge),T(Lt),t&&o(Xr),t&&o(O),T(At),T(Ot),T(Dt),t&&o(Yr),t&&o(ue),T(Vt),t&&o(Zr),t&&o(_e),T(Nt),T(Gt),T(He),t&&o(es),t&&o(be),T(Wt),t&&o(ts),t&&o(J),T(Ht),T(Rt),t&&o(os),t&&o($e),T(Kt),t&&o(ns),t&&o(j),T(Xt),T(to),T(Je),T(Ke),T(oo),T(Xe),T(Ye),T(no),T(Ze),T(et),T(ro),T(tt),T(ot),t&&o(rs),t&&o(Te),T(so),t&&o(ss),t&&o(M),T(ao),T(fo),T(rt),T(st),T(at),T(mo)}}}const Wf={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 Hf(x){return Cf(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Zf extends yf{constructor(d){super();kf(this,d,Hf,Gf,Tf,{})}}export{Zf as default,Wf as metadata};
