import{S as sl,i as il,s as ml,e as r,k as d,w as f,t as s,M as dl,c as n,d as t,m as l,a,x as g,h as i,b as m,N as ll,G as e,g as p,y as u,q as _,o as b,B as v,v as cl,L as pl}from"../../chunks/vendor-hf-doc-builder.js";import{T as nl}from"../../chunks/Tip-hf-doc-builder.js";import{D as x}from"../../chunks/Docstring-hf-doc-builder.js";import{C as al}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as G}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as hl}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function fl(pe){let y,$,w,T,z;return T=new al({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMCglMEElMjAlMjAlMjAlMjBTYW1WaXNpb25Db25maWclMkMlMEElMjAlMjAlMjAlMjBTYW1Qcm9tcHRFbmNvZGVyQ29uZmlnJTJDJTBBJTIwJTIwJTIwJTIwU2FtTWFza0RlY29kZXJDb25maWclMkMlMEElMjAlMjAlMjAlMjBTYW1Nb2RlbCUyQyUwQSklMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwU2FtQ29uZmlnJTIwd2l0aCUyMCU2MCUyMmZhY2Vib29rJTJGc2FtLXZpdC1odWdlJTIyJTYwJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMFNhbUNvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMFNhbU1vZGVsJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUyMGZyb20lMjB0aGUlMjAlNjAlMjJmYWNlYm9vayUyRnNhbS12aXQtaHVnZSUyMiU2MCUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsJTIwJTNEJTIwU2FtTW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmlnJTBBJTBBJTIzJTIwV2UlMjBjYW4lMjBhbHNvJTIwaW5pdGlhbGl6ZSUyMGElMjBTYW1Db25maWclMjBmcm9tJTIwYSUyMFNhbVZpc2lvbkNvbmZpZyUyQyUyMFNhbVByb21wdEVuY29kZXJDb25maWclMkMlMjBhbmQlMjBTYW1NYXNrRGVjb2RlckNvbmZpZyUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMFNBTSUyMHZpc2lvbiUyQyUyMFNBTSUyMFEtRm9ybWVyJTIwYW5kJTIwbGFuZ3VhZ2UlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb25zJTBBdmlzaW9uX2NvbmZpZyUyMCUzRCUyMFNhbVZpc2lvbkNvbmZpZygpJTBBcHJvbXB0X2VuY29kZXJfY29uZmlnJTIwJTNEJTIwU2FtUHJvbXB0RW5jb2RlckNvbmZpZygpJTBBbWFza19kZWNvZGVyX2NvbmZpZyUyMCUzRCUyMFNhbU1hc2tEZWNvZGVyQ29uZmlnKCklMEElMEFjb25maWclMjAlM0QlMjBTYW1Db25maWcodmlzaW9uX2NvbmZpZyUyQyUyMHByb21wdF9lbmNvZGVyX2NvbmZpZyUyQyUyMG1hc2tfZGVjb2Rlcl9jb25maWcp",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>    SamVisionConfig,
<span class="hljs-meta">... </span>    SamPromptEncoderConfig,
<span class="hljs-meta">... </span>    SamMaskDecoderConfig,
<span class="hljs-meta">... </span>    SamModel,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a SamConfig with \`&quot;facebook/sam-vit-huge&quot;\` style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = SamConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a SamModel (with random weights) from the \`&quot;facebook/sam-vit-huge&quot;\` style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = SamModel(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 SamConfig from a SamVisionConfig, SamPromptEncoderConfig, and SamMaskDecoderConfig</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing SAM vision, SAM Q-Former and language model configurations</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>vision_config = SamVisionConfig()
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt_encoder_config = SamPromptEncoderConfig()
<span class="hljs-meta">&gt;&gt;&gt; </span>mask_decoder_config = SamMaskDecoderConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span>config = SamConfig(vision_config, prompt_encoder_config, mask_decoder_config)`}}),{c(){y=r("p"),$=s("Example:"),w=d(),f(T.$$.fragment)},l(h){y=n(h,"P",{});var M=a(y);$=i(M,"Example:"),M.forEach(t),w=l(h),g(T.$$.fragment,h)},m(h,M){p(h,y,M),e(y,$),p(h,w,M),u(T,h,M),z=!0},p:pl,i(h){z||(_(T.$$.fragment,h),z=!0)},o(h){b(T.$$.fragment,h),z=!1},d(h){h&&t(y),h&&t(w),v(T,h)}}}function gl(pe){let y,$,w,T,z;return{c(){y=r("p"),$=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),w=r("code"),T=s("Module"),z=s(`
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(h){y=n(h,"P",{});var M=a(y);$=i(M,"Although the recipe for forward pass needs to be defined within this function, one should call the "),w=n(M,"CODE",{});var D=a(w);T=i(D,"Module"),D.forEach(t),z=i(M,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),M.forEach(t)},m(h,M){p(h,y,M),e(y,$),e(y,w),e(w,T),e(y,z)},d(h){h&&t(y)}}}function ul(pe){let y,$,w,T,z;return{c(){y=r("p"),$=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),w=r("code"),T=s("Module"),z=s(`
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(h){y=n(h,"P",{});var M=a(y);$=i(M,"Although the recipe for forward pass needs to be defined within this function, one should call the "),w=n(M,"CODE",{});var D=a(w);T=i(D,"Module"),D.forEach(t),z=i(M,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),M.forEach(t)},m(h,M){p(h,y,M),e(y,$),e(y,w),e(w,T),e(y,z)},d(h){h&&t(y)}}}function _l(pe){let y,$,w,T,z,h,M,D,An,zr,X,he,Jt,Re,Dn,Wt,jn,$r,fe,Un,Ve,Jn,Wn,Ir,Xo,Fn,Er,Yo,Ho,ym,Pr,Oo,Rn,Cr,Qo,Le,Vn,Ze,Ln,Zn,Nr,Ko,Bn,Ar,E,Ft,qn,Gn,Rt,Xn,Yn,Vt,Hn,On,Lt,Qn,Kn,Be,ea,qe,oa,ta,Dr,N,ra,Ge,na,aa,Xe,sa,ia,Ye,ma,da,jr,et,la,Ur,He,Jr,ot,ca,Wr,A,tt,Oe,pa,ha,fa,rt,Qe,ga,ua,_a,nt,Ke,ba,va,ya,at,eo,Sa,wa,Fr,Y,ge,Zt,oo,Ta,Bt,Ma,Rr,I,to,ka,R,st,xa,za,it,$a,Ia,ro,Ea,Pa,Ca,H,Na,mt,Aa,Da,dt,ja,Ua,Ja,ue,Wa,_e,no,Fa,ao,Ra,lt,Va,La,Vr,O,be,qt,so,Za,Gt,Ba,Lr,j,io,qa,Q,Ga,Xt,Xa,Ya,mo,Ha,Oa,Qa,K,Ka,ct,es,os,pt,ts,rs,Zr,ee,ve,Yt,lo,ns,Ht,as,Br,U,co,ss,oe,is,Ot,ms,ds,po,ls,cs,ps,te,hs,ht,fs,gs,ft,us,_s,qr,re,ye,Qt,ho,bs,Kt,vs,Gr,J,fo,ys,W,Ss,er,ws,Ts,or,Ms,ks,go,xs,zs,$s,ne,Is,gt,Es,Ps,ut,Cs,Ns,Xr,ae,Se,tr,uo,As,rr,Ds,Yr,F,_o,js,nr,Us,Js,V,_t,Ws,Fs,bt,Rs,Vs,bo,ar,Ls,Zs,Bs,Hr,se,we,sr,vo,qs,ir,Gs,Or,S,yo,Xs,mr,Ys,Hs,Te,So,Os,ie,Qs,dr,Ks,ei,lr,oi,ti,ri,Me,wo,ni,To,ai,cr,si,ii,mi,ke,Mo,di,pr,li,ci,xe,ko,pi,xo,hi,hr,fi,gi,ui,ze,zo,_i,fr,bi,vi,$e,$o,yi,gr,Si,wi,Ie,Io,Ti,ur,Mi,ki,Ee,Eo,xi,_r,zi,$i,Pe,Po,Ii,Co,Ei,br,Pi,Ci,Qr,me,Ce,vr,No,Ni,yr,Ai,Kr,P,Ao,Di,Do,ji,vt,Ui,Ji,Wi,jo,Fi,Uo,Ri,Vi,Li,L,Jo,Zi,de,Bi,yt,qi,Gi,Sr,Xi,Yi,Hi,Ne,en,le,Ae,wr,Wo,Oi,Tr,Qi,on,C,Fo,Ki,Ro,em,St,om,tm,rm,Vo,nm,Lo,am,sm,im,Z,Zo,mm,ce,dm,wt,lm,cm,Mr,pm,hm,fm,De,tn;return h=new G({}),Re=new G({}),He=new al({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFpbXBvcnQlMjByZXF1ZXN0cyUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBTYW1Nb2RlbCUyQyUyMFNhbVByb2Nlc3NvciUwQSUwQWRldmljZSUyMCUzRCUyMCUyMmN1ZGElMjIlMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwJTIyY3B1JTIyJTBBbW9kZWwlMjAlM0QlMjBTYW1Nb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZzYW0tdml0LWh1Z2UlMjIpLnRvKGRldmljZSklMEFwcm9jZXNzb3IlMjAlM0QlMjBTYW1Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGc2FtLXZpdC1odWdlJTIyKSUwQSUwQWltZ191cmwlMjAlM0QlMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGeWJlbGthZGElMkZzZWdtZW50LWFueXRoaW5nJTJGcmVzb2x2ZSUyRm1haW4lMkZhc3NldHMlMkZjYXIucG5nJTIyJTBBcmF3X2ltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQoaW1nX3VybCUyQyUyMHN0cmVhbSUzRFRydWUpLnJhdykuY29udmVydCglMjJSR0IlMjIpJTBBaW5wdXRfcG9pbnRzJTIwJTNEJTIwJTVCJTVCJTVCNDUwJTJDJTIwNjAwJTVEJTVEJTVEJTIwJTIwJTIzJTIwMkQlMjBsb2NhdGlvbiUyMG9mJTIwYSUyMHdpbmRvdyUyMGluJTIwdGhlJTIwaW1hZ2UlMEElMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IocmF3X2ltYWdlJTJDJTIwaW5wdXRfcG9pbnRzJTNEaW5wdXRfcG9pbnRzJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikudG8oZGV2aWNlKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyklMEElMEFtYXNrcyUyMCUzRCUyMHByb2Nlc3Nvci5pbWFnZV9wcm9jZXNzb3IucG9zdF9wcm9jZXNzX21hc2tzKCUwQSUyMCUyMCUyMCUyMG91dHB1dHMucHJlZF9tYXNrcy5jcHUoKSUyQyUyMGlucHV0cyU1QiUyMm9yaWdpbmFsX3NpemVzJTIyJTVELmNwdSgpJTJDJTIwaW5wdXRzJTVCJTIycmVzaGFwZWRfaW5wdXRfc2l6ZXMlMjIlNUQuY3B1KCklMEEpJTBBc2NvcmVzJTIwJTNEJTIwb3V0cHV0cy5pb3Vfc2NvcmVz",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> SamModel, SamProcessor

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>
model = SamModel.from_pretrained(<span class="hljs-string">&quot;facebook/sam-vit-huge&quot;</span>).to(device)
processor = SamProcessor.from_pretrained(<span class="hljs-string">&quot;facebook/sam-vit-huge&quot;</span>)

img_url = <span class="hljs-string">&quot;https://huggingface.co/ybelkada/segment-anything/resolve/main/assets/car.png&quot;</span>
raw_image = Image.<span class="hljs-built_in">open</span>(requests.get(img_url, stream=<span class="hljs-literal">True</span>).raw).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
input_points = [[[<span class="hljs-number">450</span>, <span class="hljs-number">600</span>]]]  <span class="hljs-comment"># 2D location of a window in the image</span>

inputs = processor(raw_image, input_points=input_points, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).to(device)
outputs = model(**inputs)

masks = processor.image_processor.post_process_masks(
    outputs.pred_masks.cpu(), inputs[<span class="hljs-string">&quot;original_sizes&quot;</span>].cpu(), inputs[<span class="hljs-string">&quot;reshaped_input_sizes&quot;</span>].cpu()
)
scores = outputs.iou_scores`}}),oo=new G({}),to=new x({props:{name:"class transformers.SamConfig",anchor:"transformers.SamConfig",parameters:[{name:"vision_config",val:" = None"},{name:"prompt_encoder_config",val:" = None"},{name:"mask_decoder_config",val:" = None"},{name:"initializer_range",val:" = 0.02"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamConfig.vision_config",description:`<strong>vision_config</strong> (Union[<code>dict</code>, <code>SamVisionConfig</code>], <em>optional</em>) &#x2014;
Dictionary of configuration options used to initialize <a href="/docs/transformers/v4.30.0/en/model_doc/sam#transformers.SamVisionConfig">SamVisionConfig</a>.`,name:"vision_config"},{anchor:"transformers.SamConfig.prompt_encoder_config",description:`<strong>prompt_encoder_config</strong> (Union[<code>dict</code>, <code>SamPromptEncoderConfig</code>], <em>optional</em>) &#x2014;
Dictionary of configuration options used to initialize <a href="/docs/transformers/v4.30.0/en/model_doc/sam#transformers.SamPromptEncoderConfig">SamPromptEncoderConfig</a>.`,name:"prompt_encoder_config"},{anchor:"transformers.SamConfig.mask_decoder_config",description:`<strong>mask_decoder_config</strong> (Union[<code>dict</code>, <code>SamMaskDecoderConfig</code>], <em>optional</em>) &#x2014;
Dictionary of configuration options used to initialize <a href="/docs/transformers/v4.30.0/en/model_doc/sam#transformers.SamMaskDecoderConfig">SamMaskDecoderConfig</a>.`,name:"mask_decoder_config"},{anchor:"transformers.SamConfig.kwargs",description:`<strong>kwargs</strong> (<em>optional</em>) &#x2014;
Dictionary of keyword arguments.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/sam/configuration_sam.py#L254"}}),ue=new hl({props:{anchor:"transformers.SamConfig.example",$$slots:{default:[fl]},$$scope:{ctx:pe}}}),no=new x({props:{name:"to_dict",anchor:"transformers.SamConfig.to_dict",parameters:[],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/sam/configuration_sam.py#L332",returnDescription:`
<p>Dictionary of all the attributes that make up this configuration instance,</p>
`,returnType:`
<p><code>Dict[str, any]</code></p>
`}}),so=new G({}),io=new x({props:{name:"class transformers.SamVisionConfig",anchor:"transformers.SamVisionConfig",parameters:[{name:"hidden_size",val:" = 768"},{name:"intermediate_size",val:" = 6144"},{name:"projection_dim",val:" = 512"},{name:"output_channels",val:" = 256"},{name:"num_hidden_layers",val:" = 12"},{name:"num_attention_heads",val:" = 12"},{name:"num_channels",val:" = 3"},{name:"image_size",val:" = 1024"},{name:"patch_size",val:" = 16"},{name:"hidden_act",val:" = 'gelu'"},{name:"layer_norm_eps",val:" = 1e-06"},{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:"mlp_ratio",val:" = 4.0"},{name:"use_abs_pos",val:" = True"},{name:"use_rel_pos",val:" = True"},{name:"window_size",val:" = 14"},{name:"global_attn_indexes",val:" = [2, 5, 8, 11]"},{name:"num_pos_feats",val:" = 128"},{name:"mlp_dim",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamVisionConfig.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.SamVisionConfig.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.SamVisionConfig.projection_dim",description:`<strong>projection_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 512) &#x2014;
Dimensionality of the projection layer in the Transformer encoder.`,name:"projection_dim"},{anchor:"transformers.SamVisionConfig.output_channels",description:`<strong>output_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 256) &#x2014;
Dimensionality of the output channels in the Patch Encoder.`,name:"output_channels"},{anchor:"transformers.SamVisionConfig.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.SamVisionConfig.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.SamVisionConfig.num_channels",description:`<strong>num_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 3) &#x2014;
Number of channels in the input image.`,name:"num_channels"},{anchor:"transformers.SamVisionConfig.image_size",description:`<strong>image_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
Expected resolution. Target size of the resized input image.`,name:"image_size"},{anchor:"transformers.SamVisionConfig.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
Size of the patches to be extracted from the input image.`,name:"patch_size"},{anchor:"transformers.SamVisionConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string)`,name:"hidden_act"},{anchor:"transformers.SamVisionConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-6) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.SamVisionConfig.dropout",description:`<strong>dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout probability.`,name:"dropout"},{anchor:"transformers.SamVisionConfig.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.SamVisionConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-10) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.SamVisionConfig.initializer_factor",description:`<strong>initializer_factor</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
A factor for multiplying the initializer range.`,name:"initializer_factor"},{anchor:"transformers.SamVisionConfig.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 query, key, value projections.`,name:"qkv_bias"},{anchor:"transformers.SamVisionConfig.mlp_ratio",description:`<strong>mlp_ratio</strong> (<code>float</code>, <em>optional</em>, defaults to 4.0) &#x2014;
Ratio of mlp hidden dim to embedding dim.`,name:"mlp_ratio"},{anchor:"transformers.SamVisionConfig.use_abs_pos",description:`<strong>use_abs_pos</strong> (<code>bool</code>, <em>optional</em>, defaults to True) &#x2014;
Whether to use absolute position embedding.`,name:"use_abs_pos"},{anchor:"transformers.SamVisionConfig.use_rel_pos",description:`<strong>use_rel_pos</strong> (<code>bool</code>, <em>optional</em>, defaults to True) &#x2014;
Whether to use relative position embedding.`,name:"use_rel_pos"},{anchor:"transformers.SamVisionConfig.window_size",description:`<strong>window_size</strong> (<code>int</code>, <em>optional</em>, defaults to 14) &#x2014;
Window size for relative position.`,name:"window_size"},{anchor:"transformers.SamVisionConfig.global_attn_indexes",description:`<strong>global_attn_indexes</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[2, 5, 8, 11]</code>) &#x2014;
The indexes of the global attention layers.`,name:"global_attn_indexes"},{anchor:"transformers.SamVisionConfig.num_pos_feats",description:`<strong>num_pos_feats</strong> (<code>int</code>, <em>optional</em>, defaults to 128) &#x2014;
The dimensionality of the position embedding.`,name:"num_pos_feats"},{anchor:"transformers.SamVisionConfig.mlp_dim",description:`<strong>mlp_dim</strong> (<code>int</code>, <em>optional</em>, defaults to None) &#x2014;
The dimensionality of the MLP layer in the Transformer encoder. If <code>None</code>, defaults to <code>mlp_ratio * hidden_size</code>.`,name:"mlp_dim"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/sam/configuration_sam.py#L140"}}),lo=new G({}),co=new x({props:{name:"class transformers.SamMaskDecoderConfig",anchor:"transformers.SamMaskDecoderConfig",parameters:[{name:"hidden_size",val:" = 256"},{name:"hidden_act",val:" = 'relu'"},{name:"mlp_dim",val:" = 2048"},{name:"num_hidden_layers",val:" = 2"},{name:"num_attention_heads",val:" = 8"},{name:"attention_downsample_rate",val:" = 2"},{name:"num_multimask_outputs",val:" = 3"},{name:"iou_head_depth",val:" = 3"},{name:"iou_head_hidden_dim",val:" = 256"},{name:"layer_norm_eps",val:" = 1e-06"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamMaskDecoderConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 256) &#x2014;
Dimensionality of the hidden states.`,name:"hidden_size"},{anchor:"transformers.SamMaskDecoderConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;relu&quot;</code>) &#x2014;
The non-linear activation function used inside the <code>SamMaskDecoder</code> module.`,name:"hidden_act"},{anchor:"transformers.SamMaskDecoderConfig.mlp_dim",description:`<strong>mlp_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 2048) &#x2014;
Dimensionality of the &#x201C;intermediate&#x201D; (i.e., feed-forward) layer in the Transformer encoder.`,name:"mlp_dim"},{anchor:"transformers.SamMaskDecoderConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"num_hidden_layers"},{anchor:"transformers.SamMaskDecoderConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 8) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_attention_heads"},{anchor:"transformers.SamMaskDecoderConfig.attention_downsample_rate",description:`<strong>attention_downsample_rate</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
The downsampling rate of the attention layer.`,name:"attention_downsample_rate"},{anchor:"transformers.SamMaskDecoderConfig.num_multimask_outputs",description:`<strong>num_multimask_outputs</strong> (<code>int</code>, <em>optional</em>, defaults to 3) &#x2014;
The number of outputs from the <code>SamMaskDecoder</code> module. In the Segment Anything paper, this is set to 3.`,name:"num_multimask_outputs"},{anchor:"transformers.SamMaskDecoderConfig.iou_head_depth",description:`<strong>iou_head_depth</strong> (<code>int</code>, <em>optional</em>, defaults to 3) &#x2014;
The number of layers in the IoU head module.`,name:"iou_head_depth"},{anchor:"transformers.SamMaskDecoderConfig.iou_head_hidden_dim",description:`<strong>iou_head_hidden_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 256) &#x2014;
The dimensionality of the hidden states in the IoU head module.`,name:"iou_head_hidden_dim"},{anchor:"transformers.SamMaskDecoderConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-6) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/sam/configuration_sam.py#L79"}}),ho=new G({}),fo=new x({props:{name:"class transformers.SamPromptEncoderConfig",anchor:"transformers.SamPromptEncoderConfig",parameters:[{name:"hidden_size",val:" = 256"},{name:"image_size",val:" = 1024"},{name:"patch_size",val:" = 16"},{name:"mask_input_channels",val:" = 16"},{name:"num_point_embeddings",val:" = 4"},{name:"hidden_act",val:" = 'gelu'"},{name:"layer_norm_eps",val:" = 1e-06"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamPromptEncoderConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 256) &#x2014;
Dimensionality of the hidden states.`,name:"hidden_size"},{anchor:"transformers.SamPromptEncoderConfig.image_size",description:`<strong>image_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
The expected output resolution of the image.`,name:"image_size"},{anchor:"transformers.SamPromptEncoderConfig.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
The size (resolution) of each patch.`,name:"patch_size"},{anchor:"transformers.SamPromptEncoderConfig.mask_input_channels",description:`<strong>mask_input_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
The number of channels to be fed to the <code>MaskDecoder</code> module.`,name:"mask_input_channels"},{anchor:"transformers.SamPromptEncoderConfig.num_point_embeddings",description:`<strong>num_point_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014;
The number of point embeddings to be used.`,name:"num_point_embeddings"},{anchor:"transformers.SamPromptEncoderConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function in the encoder and pooler.`,name:"hidden_act"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/sam/configuration_sam.py#L32"}}),uo=new G({}),_o=new x({props:{name:"class transformers.SamProcessor",anchor:"transformers.SamProcessor",parameters:[{name:"image_processor",val:""}],parametersDescription:[{anchor:"transformers.SamProcessor.image_processor",description:`<strong>image_processor</strong> (<code>SamImageProcessor</code>) &#x2014;
An instance of <a href="/docs/transformers/v4.30.0/en/model_doc/sam#transformers.SamImageProcessor">SamImageProcessor</a>. The image processor is a required input.`,name:"image_processor"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/sam/processing_sam.py#L35"}}),vo=new G({}),yo=new x({props:{name:"class transformers.SamImageProcessor",anchor:"transformers.SamImageProcessor",parameters:[{name:"do_resize",val:": bool = True"},{name:"size",val:": typing.Dict[str, int] = None"},{name:"resample",val:": Resampling = <Resampling.BILINEAR: 2>"},{name:"do_rescale",val:": bool = True"},{name:"rescale_factor",val:": typing.Union[int, float] = 0.00392156862745098"},{name:"do_normalize",val:": bool = True"},{name:"image_mean",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"image_std",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"do_pad",val:": bool = True"},{name:"pad_size",val:": int = None"},{name:"do_convert_rgb",val:": bool = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamImageProcessor.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to resize the image&#x2019;s (height, width) dimensions to the specified <code>size</code>. Can be overridden by the
<code>do_resize</code> parameter in the <code>preprocess</code> method.`,name:"do_resize"},{anchor:"transformers.SamImageProcessor.size",description:`<strong>size</strong> (<code>dict</code>, <em>optional</em>, defaults to <code>{&quot;longest_edge&quot; -- 1024}</code>):
Size of the output image after resizing. Resizes the longest edge of the image to match
<code>size[&quot;longest_edge&quot;]</code> while maintaining the aspect ratio. Can be overridden by the <code>size</code> parameter in the
<code>preprocess</code> method.`,name:"size"},{anchor:"transformers.SamImageProcessor.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code>, <em>optional</em>, defaults to <code>PILImageResampling.BICUBIC</code>) &#x2014;
Resampling filter to use if resizing the image. Can be overridden by the <code>resample</code> parameter in the
<code>preprocess</code> method.`,name:"resample"},{anchor:"transformers.SamImageProcessor.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Wwhether to rescale the image by the specified scale <code>rescale_factor</code>. Can be overridden by the
<code>do_rescale</code> parameter in the <code>preprocess</code> method.`,name:"do_rescale"},{anchor:"transformers.SamImageProcessor.rescale_factor",description:`<strong>rescale_factor</strong> (<code>int</code> or <code>float</code>, <em>optional</em>, defaults to <code>1/255</code>) &#x2014;
Scale factor to use if rescaling the image. Only has an effect if <code>do_rescale</code> is set to <code>True</code>. Can be
overridden by the <code>rescale_factor</code> parameter in the <code>preprocess</code> method.`,name:"rescale_factor"},{anchor:"transformers.SamImageProcessor.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to normalize the image. Can be overridden by the <code>do_normalize</code> parameter in the <code>preprocess</code>
method. Can be overridden by the <code>do_normalize</code> parameter in the <code>preprocess</code> method.`,name:"do_normalize"},{anchor:"transformers.SamImageProcessor.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IMAGENET_DEFAULT_MEAN</code>) &#x2014;
Mean to use if normalizing the image. This is a float or list of floats the length of the number of
channels in the image. Can be overridden by the <code>image_mean</code> parameter in the <code>preprocess</code> method. Can be
overridden by the <code>image_mean</code> parameter in the <code>preprocess</code> method.`,name:"image_mean"},{anchor:"transformers.SamImageProcessor.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IMAGENET_DEFAULT_STD</code>) &#x2014;
Standard deviation to use if normalizing the image. This is a float or list of floats the length of the
number of channels in the image. Can be overridden by the <code>image_std</code> parameter in the <code>preprocess</code> method.
Can be overridden by the <code>image_std</code> parameter in the <code>preprocess</code> method.`,name:"image_std"},{anchor:"transformers.SamImageProcessor.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to pad the image to the specified <code>pad_size</code>. Can be overridden by the <code>do_pad</code> parameter in the
<code>preprocess</code> method.`,name:"do_pad"},{anchor:"transformers.SamImageProcessor.pad_size",description:`<strong>pad_size</strong> (<code>dict</code>, <em>optional</em>, defaults to <code>{&quot;height&quot; -- 1024, &quot;width&quot;: 1024}</code>):
Size of the output image after padding. Can be overridden by the <code>pad_size</code> parameter in the <code>preprocess</code>
method.`,name:"pad_size"},{anchor:"transformers.SamImageProcessor.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to convert the image to RGB.`,name:"do_convert_rgb"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/sam/image_processing_sam.py#L63"}}),So=new x({props:{name:"filter_masks",anchor:"transformers.SamImageProcessor.filter_masks",parameters:[{name:"masks",val:""},{name:"iou_scores",val:""},{name:"original_size",val:""},{name:"cropped_box_image",val:""},{name:"pred_iou_thresh",val:" = 0.88"},{name:"stability_score_thresh",val:" = 0.95"},{name:"mask_threshold",val:" = 0"},{name:"stability_score_offset",val:" = 1"},{name:"return_tensors",val:" = 'pt'"}],parametersDescription:[{anchor:"transformers.SamImageProcessor.filter_masks.masks",description:`<strong>masks</strong> (<code>Union[torch.Tensor, tf.Tensor]</code>) &#x2014;
Input masks.`,name:"masks"},{anchor:"transformers.SamImageProcessor.filter_masks.iou_scores",description:`<strong>iou_scores</strong> (<code>Union[torch.Tensor, tf.Tensor]</code>) &#x2014;
List of IoU scores.`,name:"iou_scores"},{anchor:"transformers.SamImageProcessor.filter_masks.original_size",description:`<strong>original_size</strong> (<code>Tuple[int,int]</code>) &#x2014;
Size of the orginal image.`,name:"original_size"},{anchor:"transformers.SamImageProcessor.filter_masks.cropped_box_image",description:`<strong>cropped_box_image</strong> (<code>np.array</code>) &#x2014;
The cropped image.`,name:"cropped_box_image"},{anchor:"transformers.SamImageProcessor.filter_masks.pred_iou_thresh",description:`<strong>pred_iou_thresh</strong> (<code>float</code>, <em>optional</em>, defaults to 0.88) &#x2014;
The threshold for the iou scores.`,name:"pred_iou_thresh"},{anchor:"transformers.SamImageProcessor.filter_masks.stability_score_thresh",description:`<strong>stability_score_thresh</strong> (<code>float</code>, <em>optional</em>, defaults to 0.95) &#x2014;
The threshold for the stability score.`,name:"stability_score_thresh"},{anchor:"transformers.SamImageProcessor.filter_masks.mask_threshold",description:`<strong>mask_threshold</strong> (<code>float</code>, <em>optional</em>, defaults to 0) &#x2014;
The threshold for the predicted masks.`,name:"mask_threshold"},{anchor:"transformers.SamImageProcessor.filter_masks.stability_score_offset",description:`<strong>stability_score_offset</strong> (<code>float</code>, <em>optional</em>, defaults to 1) &#x2014;
The offset for the stability score used in the <code>_compute_stability_score</code> method.`,name:"stability_score_offset"},{anchor:"transformers.SamImageProcessor.filter_masks.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code>, <em>optional</em>, defaults to <code>pt</code>) &#x2014;
If <code>pt</code>, returns <code>torch.Tensor</code>. If <code>tf</code>, returns <code>tf.Tensor</code>.`,name:"return_tensors"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/sam/image_processing_sam.py#L615"}}),wo=new x({props:{name:"generate_crop_boxes",anchor:"transformers.SamImageProcessor.generate_crop_boxes",parameters:[{name:"image",val:""},{name:"target_size",val:""},{name:"crop_n_layers",val:": int = 0"},{name:"overlap_ratio",val:": float = 0.3413333333333333"},{name:"points_per_crop",val:": typing.Optional[int] = 32"},{name:"crop_n_points_downscale_factor",val:": typing.Optional[typing.List[int]] = 1"},{name:"device",val:": typing.Optional[ForwardRef('torch.device')] = None"},{name:"return_tensors",val:": str = 'pt'"}],parametersDescription:[{anchor:"transformers.SamImageProcessor.generate_crop_boxes.image",description:`<strong>image</strong> (<code>np.array</code>) &#x2014;
Input original image`,name:"image"},{anchor:"transformers.SamImageProcessor.generate_crop_boxes.target_size",description:`<strong>target_size</strong> (<code>int</code>) &#x2014;
Target size of the resized image`,name:"target_size"},{anchor:"transformers.SamImageProcessor.generate_crop_boxes.crop_n_layers",description:`<strong>crop_n_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
If &gt;0, mask prediction will be run again on crops of the image. Sets the number of layers to run, where
each layer has 2**i_layer number of image crops.`,name:"crop_n_layers"},{anchor:"transformers.SamImageProcessor.generate_crop_boxes.overlap_ratio",description:`<strong>overlap_ratio</strong> (<code>float</code>, <em>optional</em>, defaults to 512/1500) &#x2014;
Sets the degree to which crops overlap. In the first crop layer, crops will overlap by this fraction of
the image length. Later layers with more crops scale down this overlap.`,name:"overlap_ratio"},{anchor:"transformers.SamImageProcessor.generate_crop_boxes.points_per_crop",description:`<strong>points_per_crop</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
Number of points to sample from each crop.`,name:"points_per_crop"},{anchor:"transformers.SamImageProcessor.generate_crop_boxes.crop_n_points_downscale_factor",description:`<strong>crop_n_points_downscale_factor</strong> (<code>List[int]</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of points-per-side sampled in layer n is scaled down by crop_n_points_downscale_factor**n.`,name:"crop_n_points_downscale_factor"},{anchor:"transformers.SamImageProcessor.generate_crop_boxes.device",description:`<strong>device</strong> (<code>torch.device</code>, <em>optional</em>, defaults to None) &#x2014;
Device to use for the computation. If None, cpu will be used.`,name:"device"},{anchor:"transformers.SamImageProcessor.generate_crop_boxes.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code>, <em>optional</em>, defaults to <code>pt</code>) &#x2014;
If <code>pt</code>, returns <code>torch.Tensor</code>. If <code>tf</code>, returns <code>tf.Tensor</code>.`,name:"return_tensors"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/sam/image_processing_sam.py#L554"}}),Mo=new x({props:{name:"normalize",anchor:"transformers.SamImageProcessor.normalize",parameters:[{name:"image",val:": ndarray"},{name:"mean",val:": typing.Union[float, typing.List[float]]"},{name:"std",val:": typing.Union[float, typing.List[float]]"},{name:"data_format",val:": typing.Union[str, transformers.image_utils.ChannelDimension, NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamImageProcessor.normalize.image",description:`<strong>image</strong> (<code>np.ndarray</code>) &#x2014;
Image to normalize.`,name:"image"},{anchor:"transformers.SamImageProcessor.normalize.mean",description:`<strong>mean</strong> (<code>float</code> or <code>List[float]</code>) &#x2014;
Image mean.`,name:"mean"},{anchor:"transformers.SamImageProcessor.normalize.std",description:`<strong>std</strong> (<code>float</code> or <code>List[float]</code>) &#x2014;
Image standard deviation.`,name:"std"},{anchor:"transformers.SamImageProcessor.normalize.data_format",description:`<strong>data_format</strong> (<code>str</code> or <code>ChannelDimension</code>, <em>optional</em>) &#x2014;
The channel dimension format of the image. If not provided, it will be the same as the input image.`,name:"data_format"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/sam/image_processing_sam.py#L235"}}),ko=new x({props:{name:"pad_image",anchor:"transformers.SamImageProcessor.pad_image",parameters:[{name:"image",val:": ndarray"},{name:"pad_size",val:": typing.Dict[str, int]"},{name:"data_format",val:": typing.Union[str, transformers.image_utils.ChannelDimension, NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamImageProcessor.pad_image.image",description:`<strong>image</strong> (<code>np.ndarray</code>) &#x2014;
Image to pad.`,name:"image"},{anchor:"transformers.SamImageProcessor.pad_image.pad_size",description:`<strong>pad_size</strong> (<code>Dict[str, int]</code>) &#x2014;
Size of the output image after padding.`,name:"pad_size"},{anchor:"transformers.SamImageProcessor.pad_image.data_format",description:`<strong>data_format</strong> (<code>str</code> or <code>ChannelDimension</code>, <em>optional</em>) &#x2014;
The data format of the image. Can be either &#x201C;channels_first&#x201D; or &#x201C;channels_last&#x201D;. If <code>None</code>, the
<code>data_format</code> of the <code>image</code> will be used.`,name:"data_format"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/sam/image_processing_sam.py#L141"}}),zo=new x({props:{name:"post_process_for_mask_generation",anchor:"transformers.SamImageProcessor.post_process_for_mask_generation",parameters:[{name:"all_masks",val:""},{name:"all_scores",val:""},{name:"all_boxes",val:""},{name:"crops_nms_thresh",val:""},{name:"return_tensors",val:" = 'pt'"}],parametersDescription:[{anchor:"transformers.SamImageProcessor.post_process_for_mask_generation.all_masks",description:`<strong>all_masks</strong> (<code>Union[List[torch.Tensor], List[tf.Tensor]]</code>) &#x2014;
List of all predicted segmentation masks`,name:"all_masks"},{anchor:"transformers.SamImageProcessor.post_process_for_mask_generation.all_scores",description:`<strong>all_scores</strong> (<code>Union[List[torch.Tensor], List[tf.Tensor]]</code>) &#x2014;
List of all predicted iou scores`,name:"all_scores"},{anchor:"transformers.SamImageProcessor.post_process_for_mask_generation.all_boxes",description:`<strong>all_boxes</strong> (<code>Union[List[torch.Tensor], List[tf.Tensor]]</code>) &#x2014;
List of all bounding boxes of the predicted masks`,name:"all_boxes"},{anchor:"transformers.SamImageProcessor.post_process_for_mask_generation.crops_nms_thresh",description:`<strong>crops_nms_thresh</strong> (<code>float</code>) &#x2014;
Threshold for NMS (Non Maximum Suppression) algorithm.`,name:"crops_nms_thresh"},{anchor:"transformers.SamImageProcessor.post_process_for_mask_generation.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code>, <em>optional</em>, defaults to <code>pt</code>) &#x2014;
If <code>pt</code>, returns <code>torch.Tensor</code>. If <code>tf</code>, returns <code>tf.Tensor</code>.`,name:"return_tensors"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/sam/image_processing_sam.py#L531"}}),$o=new x({props:{name:"post_process_masks",anchor:"transformers.SamImageProcessor.post_process_masks",parameters:[{name:"masks",val:""},{name:"original_sizes",val:""},{name:"reshaped_input_sizes",val:""},{name:"mask_threshold",val:" = 0.0"},{name:"binarize",val:" = True"},{name:"pad_size",val:" = None"},{name:"return_tensors",val:" = 'pt'"}],parametersDescription:[{anchor:"transformers.SamImageProcessor.post_process_masks.masks",description:`<strong>masks</strong> (<code>Union[List[torch.Tensor], List[np.ndarray], List[tf.Tensor]]</code>) &#x2014;
Batched masks from the mask_decoder in (batch_size, num_channels, height, width) format.`,name:"masks"},{anchor:"transformers.SamImageProcessor.post_process_masks.original_sizes",description:`<strong>original_sizes</strong> (<code>Union[torch.Tensor, tf.Tensor, List[Tuple[int,int]]]</code>) &#x2014;
The original sizes of each image before it was resized to the model&#x2019;s expected input shape, in (height,
width) format.`,name:"original_sizes"},{anchor:"transformers.SamImageProcessor.post_process_masks.reshaped_input_sizes",description:`<strong>reshaped_input_sizes</strong> (<code>Union[torch.Tensor, tf.Tensor, List[Tuple[int,int]]]</code>) &#x2014;
The size of each image as it is fed to the model, in (height, width) format. Used to remove padding.`,name:"reshaped_input_sizes"},{anchor:"transformers.SamImageProcessor.post_process_masks.mask_threshold",description:`<strong>mask_threshold</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The threshold to use for binarizing the masks.`,name:"mask_threshold"},{anchor:"transformers.SamImageProcessor.post_process_masks.binarize",description:`<strong>binarize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to binarize the masks.`,name:"binarize"},{anchor:"transformers.SamImageProcessor.post_process_masks.pad_size",description:`<strong>pad_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.pad_size</code>) &#x2014;
The target size the images were padded to before being passed to the model. If None, the target size is
assumed to be the processor&#x2019;s <code>pad_size</code>.`,name:"pad_size"},{anchor:"transformers.SamImageProcessor.post_process_masks.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pt&quot;</code>) &#x2014;
If <code>&quot;pt&quot;</code>, return PyTorch tensors. If <code>&quot;tf&quot;</code>, return TensorFlow tensors.`,name:"return_tensors"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/sam/image_processing_sam.py#L387",returnDescription:`
<p>Batched masks in batch_size, num_channels, height, width) format, where
(height, width) is given by original_size.</p>
`,returnType:`
<p>(<code>Union[torch.Tensor, tf.Tensor]</code>)</p>
`}}),Io=new x({props:{name:"preprocess",anchor:"transformers.SamImageProcessor.preprocess",parameters:[{name:"images",val:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), typing.List[ForwardRef('PIL.Image.Image')], typing.List[numpy.ndarray], typing.List[ForwardRef('torch.Tensor')]]"},{name:"do_resize",val:": typing.Optional[bool] = None"},{name:"size",val:": typing.Union[typing.Dict[str, int], NoneType] = None"},{name:"resample",val:": typing.Optional[ForwardRef('PILImageResampling')] = None"},{name:"do_rescale",val:": typing.Optional[bool] = None"},{name:"rescale_factor",val:": typing.Union[int, float, NoneType] = None"},{name:"do_normalize",val:": typing.Optional[bool] = None"},{name:"image_mean",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"image_std",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"do_pad",val:": typing.Optional[bool] = None"},{name:"pad_size",val:": typing.Union[typing.Dict[str, int], NoneType] = None"},{name:"do_convert_rgb",val:": bool = None"},{name:"return_tensors",val:": typing.Union[str, transformers.utils.generic.TensorType, NoneType] = None"},{name:"data_format",val:": ChannelDimension = <ChannelDimension.FIRST: 'channels_first'>"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamImageProcessor.preprocess.images",description:`<strong>images</strong> (<code>ImageInput</code>) &#x2014;
Image to preprocess.`,name:"images"},{anchor:"transformers.SamImageProcessor.preprocess.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_resize</code>) &#x2014;
Whether to resize the image.`,name:"do_resize"},{anchor:"transformers.SamImageProcessor.preprocess.size",description:`<strong>size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>self.size</code>) &#x2014;
Controls the size of the image after <code>resize</code>. The longest edge of the image is resized to
<code>size[&quot;longest_edge&quot;]</code> whilst preserving the aspect ratio.`,name:"size"},{anchor:"transformers.SamImageProcessor.preprocess.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code>, <em>optional</em>, defaults to <code>self.resample</code>) &#x2014;
<code>PILImageResampling</code> filter to use when resizing the image e.g. <code>PILImageResampling.BILINEAR</code>.`,name:"resample"},{anchor:"transformers.SamImageProcessor.preprocess.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_rescale</code>) &#x2014;
Whether to rescale the image pixel values by rescaling factor.`,name:"do_rescale"},{anchor:"transformers.SamImageProcessor.preprocess.rescale_factor",description:`<strong>rescale_factor</strong> (<code>int</code> or <code>float</code>, <em>optional</em>, defaults to <code>self.rescale_factor</code>) &#x2014;
Rescale factor to apply to the image pixel values.`,name:"rescale_factor"},{anchor:"transformers.SamImageProcessor.preprocess.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_normalize</code>) &#x2014;
Whether to normalize the image.`,name:"do_normalize"},{anchor:"transformers.SamImageProcessor.preprocess.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_mean</code>) &#x2014;
Image mean to normalize the image by if <code>do_normalize</code> is set to <code>True</code>.`,name:"image_mean"},{anchor:"transformers.SamImageProcessor.preprocess.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_std</code>) &#x2014;
Image standard deviation to normalize the image by if <code>do_normalize</code> is set to <code>True</code>.`,name:"image_std"},{anchor:"transformers.SamImageProcessor.preprocess.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_pad</code>) &#x2014;
Whether to pad the image.`,name:"do_pad"},{anchor:"transformers.SamImageProcessor.preprocess.pad_size",description:`<strong>pad_size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>self.pad_size</code>) &#x2014;
Controls the size of the padding applied to the image. The image is padded to <code>pad_size[&quot;height&quot;]</code> and
<code>pad_size[&quot;width&quot;]</code> if <code>do_pad</code> is set to <code>True</code>.`,name:"pad_size"},{anchor:"transformers.SamImageProcessor.preprocess.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_convert_rgb</code>) &#x2014;
Whether to convert the image to RGB.`,name:"do_convert_rgb"},{anchor:"transformers.SamImageProcessor.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <code>TensorType</code>, <em>optional</em>) &#x2014;
The type of tensors to return. Can be one of:<ul>
<li>Unset: Return a list of <code>np.ndarray</code>.</li>
<li><code>TensorType.TENSORFLOW</code> or <code>&apos;tf&apos;</code>: Return a batch of type <code>tf.Tensor</code>.</li>
<li><code>TensorType.PYTORCH</code> or <code>&apos;pt&apos;</code>: Return a batch of type <code>torch.Tensor</code>.</li>
<li><code>TensorType.NUMPY</code> or <code>&apos;np&apos;</code>: Return a batch of type <code>np.ndarray</code>.</li>
<li><code>TensorType.JAX</code> or <code>&apos;jax&apos;</code>: Return a batch of type <code>jax.numpy.ndarray</code>.</li>
</ul>`,name:"return_tensors"},{anchor:"transformers.SamImageProcessor.preprocess.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>, defaults to <code>ChannelDimension.FIRST</code>) &#x2014;
The channel dimension format for the output image. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
<li>Unset: Use the channel dimension format of the input image.</li>
</ul>`,name:"data_format"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/sam/image_processing_sam.py#L258"}}),Eo=new x({props:{name:"rescale",anchor:"transformers.SamImageProcessor.rescale",parameters:[{name:"image",val:": ndarray"},{name:"scale",val:": typing.Union[int, float]"},{name:"data_format",val:": typing.Union[str, transformers.image_utils.ChannelDimension, NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamImageProcessor.rescale.image",description:`<strong>image</strong> (<code>np.ndarray</code>) &#x2014;
Image to rescale.`,name:"image"},{anchor:"transformers.SamImageProcessor.rescale.scale",description:`<strong>scale</strong> (<code>int</code> or <code>float</code>) &#x2014;
Scale to apply to the image.`,name:"scale"},{anchor:"transformers.SamImageProcessor.rescale.data_format",description:`<strong>data_format</strong> (<code>str</code> or <code>ChannelDimension</code>, <em>optional</em>) &#x2014;
The channel dimension format of the image. If not provided, it will be the same as the input image.`,name:"data_format"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/sam/image_processing_sam.py#L215"}}),Po=new x({props:{name:"resize",anchor:"transformers.SamImageProcessor.resize",parameters:[{name:"image",val:": ndarray"},{name:"size",val:": typing.Dict[str, int]"},{name:"resample",val:": Resampling = <Resampling.BICUBIC: 3>"},{name:"data_format",val:": typing.Union[str, transformers.image_utils.ChannelDimension, NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamImageProcessor.resize.image",description:`<strong>image</strong> (<code>np.ndarray</code>) &#x2014;
Image to resize.`,name:"image"},{anchor:"transformers.SamImageProcessor.resize.size",description:`<strong>size</strong> (<code>Dict[str, int]</code>) &#x2014;
Dictionary in the format <code>{&quot;longest_edge&quot;: int}</code> specifying the size of the output image. The longest
edge of the image will be resized to the specified size, while the other edge will be resized to
maintain the aspect ratio.
resample &#x2014;
<code>PILImageResampling</code> filter to use when resizing the image e.g. <code>PILImageResampling.BILINEAR</code>.`,name:"size"},{anchor:"transformers.SamImageProcessor.resize.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>) &#x2014;
The channel dimension format for the output image. If unset, the channel dimension format of the input
image is used. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
</ul>`,name:"data_format"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/sam/image_processing_sam.py#L180",returnDescription:`
<p>The resized image.</p>
`,returnType:`
<p><code>np.ndarray</code></p>
`}}),No=new G({}),Ao=new x({props:{name:"class transformers.SamModel",anchor:"transformers.SamModel",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.SamModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.30.0/en/model_doc/sam#transformers.SamConfig">SamConfig</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.30.0/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.30.0/src/transformers/models/sam/modeling_sam.py#L1192"}}),Jo=new x({props:{name:"forward",anchor:"transformers.SamModel.forward",parameters:[{name:"pixel_values",val:": typing.Optional[torch.FloatTensor] = None"},{name:"input_points",val:": typing.Optional[torch.FloatTensor] = None"},{name:"input_labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"input_boxes",val:": typing.Optional[torch.FloatTensor] = None"},{name:"input_masks",val:": typing.Optional[torch.LongTensor] = None"},{name:"image_embeddings",val:": typing.Optional[torch.FloatTensor] = None"},{name:"multimask_output",val:": bool = True"},{name:"attention_similarity",val:": typing.Optional[torch.FloatTensor] = None"},{name:"target_embedding",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:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamModel.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.30.0/en/model_doc/sam#transformers.SamProcessor">SamProcessor</a>. See <code>SamProcessor.__call__()</code> for
details.`,name:"pixel_values"},{anchor:"transformers.SamModel.forward.input_points",description:`<strong>input_points</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_points, 2)</code>) &#x2014;
Input 2D spatial points, this is used by the prompt encoder to encode the prompt. Generally yields to much
better results. The points can be obtained by passing a list of list of list to the processor that will
create corresponding <code>torch</code> tensors of dimension 4. The first dimension is the image batch size, the
second dimension is the point batch size (i.e. how many segmentation masks do we want the model to predict
per input point), the third dimension is the number of points per segmentation mask (it is possible to pass
multiple points for a single mask), and the last dimension is the x (vertical) and y (horizontal)
coordinates of the point. If a different number of points is passed either for each image, or for each
mask, the processor will create &#x201C;PAD&#x201D; points that will correspond to the (0, 0) coordinate, and the
computation of the embedding will be skipped for these points using the labels.`,name:"input_points"},{anchor:"transformers.SamModel.forward.input_labels",description:`<strong>input_labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, point_batch_size, num_points)</code>) &#x2014;
Input labels for the points, this is used by the prompt encoder to encode the prompt. According to the
official implementation, there are 3 types of labels</p>
<ul>
<li><code>1</code>: the point is a point that contains the object of interest</li>
<li><code>0</code>: the point is a point that does not contain the object of interest</li>
<li><code>-1</code>: the point corresponds to the background</li>
</ul>
<p>We added the label:</p>
<ul>
<li><code>-10</code>: the point is a padding point, thus should be ignored by the prompt encoder</li>
</ul>
<p>The padding labels should be automatically done by the processor.`,name:"input_labels"},{anchor:"transformers.SamModel.forward.input_boxes",description:`<strong>input_boxes</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_boxes, 4)</code>) &#x2014;
Input boxes for the points, this is used by the prompt encoder to encode the prompt. Generally yields to
much better generated masks. The boxes can be obtained by passing a list of list of list to the processor,
that will generate a <code>torch</code> tensor, with each dimension corresponding respectively to the image batch
size, the number of boxes per image and the coordinates of the top left and botton right point of the box.
In the order (<code>x1</code>, <code>y1</code>, <code>x2</code>, <code>y2</code>):</p>
<ul>
<li><code>x1</code>: the x coordinate of the top left point of the input box</li>
<li><code>y1</code>: the y coordinate of the top left point of the input box</li>
<li><code>x2</code>: the x coordinate of the bottom right point of the input box</li>
<li><code>y2</code>: the y coordinate of the bottom right point of the input box</li>
</ul>`,name:"input_boxes"},{anchor:"transformers.SamModel.forward.input_masks",description:`<strong>input_masks</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, image_size, image_size)</code>) &#x2014;
SAM model also accepts segmentation masks as input. The mask will be embedded by the prompt encoder to
generate a corresponding embedding, that will be fed later on to the mask decoder. These masks needs to be
manually fed by the user, and they need to be of shape (<code>batch_size</code>, <code>image_size</code>, <code>image_size</code>).`,name:"input_masks"},{anchor:"transformers.SamModel.forward.image_embeddings",description:`<strong>image_embeddings</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, output_channels, window_size, window_size)</code>) &#x2014;
Image embeddings, this is used by the mask decder to generate masks and iou scores. For more memory
efficient computation, users can first retrieve the image embeddings using the <code>get_image_embeddings</code>
method, and then feed them to the <code>forward</code> method instead of feeding the <code>pixel_values</code>.`,name:"image_embeddings"},{anchor:"transformers.SamModel.forward.multimask_output",description:`<strong>multimask_output</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
In the original implementation and paper, the model always outputs 3 masks per image (or per point / per
bounding box if relevant). However, it is possible to just output a single mask, that corresponds to the
&#x201C;best&#x201D; mask, by specifying <code>multimask_output=False</code>.`,name:"multimask_output"},{anchor:"transformers.SamModel.forward.attention_similarity",description:`<strong>attention_similarity</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Attention similarity tensor, to be provided to the mask decoder for target-guided attention in case the
model is used for personalization as introduced in <a href="https://arxiv.org/abs/2305.03048" rel="nofollow">PerSAM</a>.`,name:"attention_similarity"},{anchor:"transformers.SamModel.forward.target_embedding",description:`<strong>target_embedding</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Embedding of the target concept, to be provided to the mask decoder for target-semantic prompting in case
the model is used for personalization as introduced in <a href="https://arxiv.org/abs/2305.03048" rel="nofollow">PerSAM</a>.`,name:"target_embedding"},{anchor:"transformers.SamModel.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.SamModel.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.SamModel.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.30.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.</p>
<p>Example &#x2014;`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/sam/modeling_sam.py#L1285"}}),Ne=new nl({props:{$$slots:{default:[gl]},$$scope:{ctx:pe}}}),Wo=new G({}),Fo=new x({props:{name:"class transformers.TFSamModel",anchor:"transformers.TFSamModel",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFSamModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.30.0/en/model_doc/sam#transformers.SamConfig">SamConfig</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.30.0/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/sam/modeling_tf_sam.py#L1236"}}),Zo=new x({props:{name:"call",anchor:"transformers.TFSamModel.call",parameters:[{name:"pixel_values",val:": TFModelInputType | None = None"},{name:"input_points",val:": tf.Tensor | None = None"},{name:"input_labels",val:": tf.Tensor | None = None"},{name:"input_boxes",val:": tf.Tensor | None = None"},{name:"input_masks",val:": tf.Tensor | None = None"},{name:"image_embeddings",val:": tf.Tensor | None = None"},{name:"multimask_output",val:": bool = True"},{name:"output_attentions",val:": Optional[bool] = None"},{name:"output_hidden_states",val:": Optional[bool] = None"},{name:"return_dict",val:" = None"},{name:"training",val:" = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFSamModel.call.pixel_values",description:`<strong>pixel_values</strong> (<code>tf.Tensor</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.30.0/en/model_doc/sam#transformers.SamProcessor">SamProcessor</a>. See <code>SamProcessor.__call__()</code> for
details.`,name:"pixel_values"},{anchor:"transformers.TFSamModel.call.input_points",description:`<strong>input_points</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, num_points, 2)</code>) &#x2014;
Input 2D spatial points, this is used by the prompt encoder to encode the prompt. Generally yields to much
better results. The points can be obtained by passing a list of list of list to the processor that will
create corresponding <code>tf</code> tensors of dimension 4. The first dimension is the image batch size, the second
dimension is the point batch size (i.e. how many segmentation masks do we want the model to predict per
input point), the third dimension is the number of points per segmentation mask (it is possible to pass
multiple points for a single mask), and the last dimension is the x (vertical) and y (horizontal)
coordinates of the point. If a different number of points is passed either for each image, or for each
mask, the processor will create &#x201C;PAD&#x201D; points that will correspond to the (0, 0) coordinate, and the
computation of the embedding will be skipped for these points using the labels.`,name:"input_points"},{anchor:"transformers.TFSamModel.call.input_labels",description:`<strong>input_labels</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, point_batch_size, num_points)</code>) &#x2014;
Input labels for the points, this is used by the prompt encoder to encode the prompt. According to the
official implementation, there are 3 types of labels</p>
<ul>
<li><code>1</code>: the point is a point that contains the object of interest</li>
<li><code>0</code>: the point is a point that does not contain the object of interest</li>
<li><code>-1</code>: the point corresponds to the background</li>
</ul>
<p>We added the label:</p>
<ul>
<li><code>-10</code>: the point is a padding point, thus should be ignored by the prompt encoder</li>
</ul>
<p>The padding labels should be automatically done by the processor.`,name:"input_labels"},{anchor:"transformers.TFSamModel.call.input_boxes",description:`<strong>input_boxes</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, num_boxes, 4)</code>) &#x2014;
Input boxes for the points, this is used by the prompt encoder to encode the prompt. Generally yields to
much better generated masks. The boxes can be obtained by passing a list of list of list to the processor,
that will generate a <code>tf</code> tensor, with each dimension corresponding respectively to the image batch size,
the number of boxes per image and the coordinates of the top left and botton right point of the box. In the
order (<code>x1</code>, <code>y1</code>, <code>x2</code>, <code>y2</code>):</p>
<ul>
<li><code>x1</code>: the x coordinate of the top left point of the input box</li>
<li><code>y1</code>: the y coordinate of the top left point of the input box</li>
<li><code>x2</code>: the x coordinate of the bottom right point of the input box</li>
<li><code>y2</code>: the y coordinate of the bottom right point of the input box</li>
</ul>`,name:"input_boxes"},{anchor:"transformers.TFSamModel.call.input_masks",description:`<strong>input_masks</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, image_size, image_size)</code>) &#x2014;
SAM model also accepts segmentation masks as input. The mask will be embedded by the prompt encoder to
generate a corresponding embedding, that will be fed later on to the mask decoder. These masks needs to be
manually fed by the user, and they need to be of shape (<code>batch_size</code>, <code>image_size</code>, <code>image_size</code>).`,name:"input_masks"},{anchor:"transformers.TFSamModel.call.image_embeddings",description:`<strong>image_embeddings</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, output_channels, window_size, window_size)</code>) &#x2014;
Image embeddings, this is used by the mask decder to generate masks and iou scores. For more memory
efficient computation, users can first retrieve the image embeddings using the <code>get_image_embeddings</code>
method, and then feed them to the <code>call</code> method instead of feeding the <code>pixel_values</code>.`,name:"image_embeddings"},{anchor:"transformers.TFSamModel.call.multimask_output",description:`<strong>multimask_output</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
In the original implementation and paper, the model always outputs 3 masks per image (or per point / per
bounding box if relevant). However, it is possible to just output a single mask, that corresponds to the
&#x201C;best&#x201D; mask, by specifying <code>multimask_output=False</code>.`,name:"multimask_output"},{anchor:"transformers.TFSamModel.call.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.TFSamModel.call.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.TFSamModel.call.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.30.0/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.30.0/src/transformers/models/sam/modeling_tf_sam.py#L1326"}}),De=new nl({props:{$$slots:{default:[ul]},$$scope:{ctx:pe}}}),{c(){y=r("meta"),$=d(),w=r("h1"),T=r("a"),z=r("span"),f(h.$$.fragment),M=d(),D=r("span"),An=s("SAM"),zr=d(),X=r("h2"),he=r("a"),Jt=r("span"),f(Re.$$.fragment),Dn=d(),Wt=r("span"),jn=s("Overview"),$r=d(),fe=r("p"),Un=s("SAM (Segment Anything Model) was proposed in "),Ve=r("a"),Jn=s("Segment Anything"),Wn=s(" by Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alex Berg, Wan-Yen Lo, Piotr Dollar, Ross Girshick."),Ir=d(),Xo=r("p"),Fn=s("The model can be used to predict segmentation masks of any object of interest given an input image."),Er=d(),Yo=r("p"),Ho=r("img"),Pr=d(),Oo=r("p"),Rn=s("The abstract from the paper is the following:"),Cr=d(),Qo=r("p"),Le=r("em"),Vn=s("We introduce the Segment Anything (SA) project: a new task, model, and dataset for image segmentation. Using our efficient model in a data collection loop, we built the largest segmentation dataset to date (by far), with over 1 billion masks on 11M licensed and privacy respecting images. The model is designed and trained to be promptable, so it can transfer zero-shot to new image distributions and tasks. We evaluate its capabilities on numerous tasks and find that its zero-shot performance is impressive \u2014 often competitive with or even superior to prior fully supervised results. We are releasing the Segment Anything Model (SAM) and corresponding dataset (SA-1B) of 1B masks and 11M images at "),Ze=r("a"),Ln=s("https://segment-anything.com"),Zn=s(" to foster research into foundation models for computer vision."),Nr=d(),Ko=r("p"),Bn=s("Tips:"),Ar=d(),E=r("ul"),Ft=r("li"),qn=s("The model predicts binary masks that states the presence or not of the object of interest given an image."),Gn=d(),Rt=r("li"),Xn=s("The model predicts much better results if input 2D points and/or input bounding boxes are provided"),Yn=d(),Vt=r("li"),Hn=s("You can prompt multiple points for the same image, and predict a single mask."),On=d(),Lt=r("li"),Qn=s("Fine-tuning the model is not supported yet"),Kn=d(),Be=r("li"),ea=s("According to the paper, textual input should be also supported. However, at this time of writing this seems to be not supported according to "),qe=r("a"),oa=s("the official repository"),ta=s("."),Dr=d(),N=r("p"),ra=s("This model was contributed by "),Ge=r("a"),na=s("ybelkada"),aa=s(" and "),Xe=r("a"),sa=s("ArthurZ"),ia=s(`.
The original code can be found `),Ye=r("a"),ma=s("here"),da=s("."),jr=d(),et=r("p"),la=s("Below is an example on how to run mask generation given an image and a 2D point:"),Ur=d(),f(He.$$.fragment),Jr=d(),ot=r("p"),ca=s("Resources:"),Wr=d(),A=r("ul"),tt=r("li"),Oe=r("a"),pa=s("Demo notebook"),ha=s(" for using the model."),fa=d(),rt=r("li"),Qe=r("a"),ga=s("Demo notebook"),ua=s(" for using the automatic mask generation pipeline."),_a=d(),nt=r("li"),Ke=r("a"),ba=s("Demo notebook"),va=s(" for inference with MedSAM, a fine-tuned version of SAM on the medical domain."),ya=d(),at=r("li"),eo=r("a"),Sa=s("Demo notebook"),wa=s(" for fine-tuning the model on custom data."),Fr=d(),Y=r("h2"),ge=r("a"),Zt=r("span"),f(oo.$$.fragment),Ta=d(),Bt=r("span"),Ma=s("SamConfig"),Rr=d(),I=r("div"),f(to.$$.fragment),ka=d(),R=r("p"),st=r("a"),xa=s("SamConfig"),za=s(" is the configuration class to store the configuration of a "),it=r("a"),$a=s("SamModel"),Ia=s(`. It is used to instantiate a
SAM model according to the specified arguments, defining the vision model, prompt-encoder model and mask decoder
configs. Instantiating a configuration with the defaults will yield a similar configuration to that of the
SAM-ViT-H `),ro=r("a"),Ea=s("facebook/sam-vit-huge"),Pa=s(" architecture."),Ca=d(),H=r("p"),Na=s("Configuration objects inherit from "),mt=r("a"),Aa=s("PretrainedConfig"),Da=s(` and can be used to control the model outputs. Read the
documentation from `),dt=r("a"),ja=s("PretrainedConfig"),Ua=s(" for more information."),Ja=d(),f(ue.$$.fragment),Wa=d(),_e=r("div"),f(no.$$.fragment),Fa=d(),ao=r("p"),Ra=s("Serializes this instance to a Python dictionary. Override the default "),lt=r("a"),Va=s("to_dict()"),La=s("."),Vr=d(),O=r("h2"),be=r("a"),qt=r("span"),f(so.$$.fragment),Za=d(),Gt=r("span"),Ba=s("SamVisionConfig"),Lr=d(),j=r("div"),f(io.$$.fragment),qa=d(),Q=r("p"),Ga=s("This is the configuration class to store the configuration of a "),Xt=r("code"),Xa=s("SamVisionModel"),Ya=s(`. It is used to instantiate a SAM
vision encoder according to the specified arguments, defining the model architecture. Instantiating a configuration
defaults will yield a similar configuration to that of the SAM ViT-h
`),mo=r("a"),Ha=s("facebook/sam-vit-huge"),Oa=s(" architecture."),Qa=d(),K=r("p"),Ka=s("Configuration objects inherit from "),ct=r("a"),es=s("PretrainedConfig"),os=s(` and can be used to control the model outputs. Read the
documentation from `),pt=r("a"),ts=s("PretrainedConfig"),rs=s(" for more information."),Zr=d(),ee=r("h2"),ve=r("a"),Yt=r("span"),f(lo.$$.fragment),ns=d(),Ht=r("span"),as=s("SamMaskDecoderConfig"),Br=d(),U=r("div"),f(co.$$.fragment),ss=d(),oe=r("p"),is=s("This is the configuration class to store the configuration of a "),Ot=r("code"),ms=s("SamMaskDecoder"),ds=s(`. It is used to instantiate a SAM
mask decoder to the specified arguments, defining the model architecture. Instantiating a configuration defaults
will yield a similar configuration to that of the SAM-vit-h
`),po=r("a"),ls=s("facebook/sam-vit-huge"),cs=s(" architecture."),ps=d(),te=r("p"),hs=s("Configuration objects inherit from "),ht=r("a"),fs=s("PretrainedConfig"),gs=s(` and can be used to control the model outputs. Read the
documentation from `),ft=r("a"),us=s("PretrainedConfig"),_s=s(" for more information."),qr=d(),re=r("h2"),ye=r("a"),Qt=r("span"),f(ho.$$.fragment),bs=d(),Kt=r("span"),vs=s("SamPromptEncoderConfig"),Gr=d(),J=r("div"),f(fo.$$.fragment),ys=d(),W=r("p"),Ss=s("This is the configuration class to store the configuration of a "),er=r("code"),ws=s("SamPromptEncoder"),Ts=s(". The "),or=r("code"),Ms=s("SamPromptEncoder"),ks=s(`
module is used to encode the input 2D points and bounding boxes. Instantiating a configuration defaults will yield
a similar configuration to that of the SAM-vit-h
`),go=r("a"),xs=s("facebook/sam-vit-huge"),zs=s(" architecture."),$s=d(),ne=r("p"),Is=s("Configuration objects inherit from "),gt=r("a"),Es=s("PretrainedConfig"),Ps=s(` and can be used to control the model outputs. Read the
documentation from `),ut=r("a"),Cs=s("PretrainedConfig"),Ns=s(" for more information."),Xr=d(),ae=r("h2"),Se=r("a"),tr=r("span"),f(uo.$$.fragment),As=d(),rr=r("span"),Ds=s("SamProcessor"),Yr=d(),F=r("div"),f(_o.$$.fragment),js=d(),nr=r("p"),Us=s(`Constructs a SAM processor which wraps a SAM image processor and an 2D points & Bounding boxes processor into a
single processor.`),Js=d(),V=r("p"),_t=r("a"),Ws=s("SamProcessor"),Fs=s(" offers all the functionalities of "),bt=r("a"),Rs=s("SamImageProcessor"),Vs=s(`. See the docstring of
`),bo=r("a"),ar=r("strong"),Ls=s("call"),Zs=s("()"),Bs=s(" for more information."),Hr=d(),se=r("h2"),we=r("a"),sr=r("span"),f(vo.$$.fragment),qs=d(),ir=r("span"),Gs=s("SamImageProcessor"),Or=d(),S=r("div"),f(yo.$$.fragment),Xs=d(),mr=r("p"),Ys=s("Constructs a SAM image processor."),Hs=d(),Te=r("div"),f(So.$$.fragment),Os=d(),ie=r("p"),Qs=s(`Filters the predicted masks by selecting only the ones that meets several criteria. The first criterion being
that the iou scores needs to be greater than `),dr=r("code"),Ks=s("pred_iou_thresh"),ei=s(`. The second criterion is that the stability
score needs to be greater than `),lr=r("code"),oi=s("stability_score_thresh"),ti=s(`. The method also converts the predicted masks to
bounding boxes and pad the predicted masks if necessary.`),ri=d(),Me=r("div"),f(wo.$$.fragment),ni=d(),To=r("p"),ai=s("Generates a list of crop boxes of different sizes. Each layer has (2"),cr=r("strong"),si=s("i)"),ii=s("2 boxes for the ith layer."),mi=d(),ke=r("div"),f(Mo.$$.fragment),di=d(),pr=r("p"),li=s("Normalize an image. image = (image - image_mean) / image_std."),ci=d(),xe=r("div"),f(ko.$$.fragment),pi=d(),xo=r("p"),hi=s("Pad an image to "),hr=r("code"),fi=s('(pad_size["height"], pad_size["width"])'),gi=s(" with zeros to the right and bottom."),ui=d(),ze=r("div"),f(zo.$$.fragment),_i=d(),fr=r("p"),bi=s("Post processes mask that are generated by calling the Non Maximum Suppression algorithm on the predicted masks."),vi=d(),$e=r("div"),f($o.$$.fragment),yi=d(),gr=r("p"),Si=s("Remove padding and upscale masks to the original image size."),wi=d(),Ie=r("div"),f(Io.$$.fragment),Ti=d(),ur=r("p"),Mi=s("Preprocess an image or batch of images."),ki=d(),Ee=r("div"),f(Eo.$$.fragment),xi=d(),_r=r("p"),zi=s("Rescale an image by a scale factor. image = image * scale."),$i=d(),Pe=r("div"),f(Po.$$.fragment),Ii=d(),Co=r("p"),Ei=s("Resize an image to "),br=r("code"),Pi=s('(size["height"], size["width"])'),Ci=s("."),Qr=d(),me=r("h2"),Ce=r("a"),vr=r("span"),f(No.$$.fragment),Ni=d(),yr=r("span"),Ai=s("SamModel"),Kr=d(),P=r("div"),f(Ao.$$.fragment),Di=d(),Do=r("p"),ji=s(`Segment Anything Model (SAM) for generating segmentation masks, given an input image and  optional 2D location and bounding boxes.
This model inherits from `),vt=r("a"),Ui=s("PreTrainedModel"),Ji=s(`. 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.)`),Wi=d(),jo=r("p"),Fi=s("This model is also a PyTorch "),Uo=r("a"),Ri=s("torch.nn.Module"),Vi=s(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Li=d(),L=r("div"),f(Jo.$$.fragment),Zi=d(),de=r("p"),Bi=s("The "),yt=r("a"),qi=s("SamModel"),Gi=s(" forward method, overrides the "),Sr=r("code"),Xi=s("__call__"),Yi=s(" special method."),Hi=d(),f(Ne.$$.fragment),en=d(),le=r("h2"),Ae=r("a"),wr=r("span"),f(Wo.$$.fragment),Oi=d(),Tr=r("span"),Qi=s("TFSamModel"),on=d(),C=r("div"),f(Fo.$$.fragment),Ki=d(),Ro=r("p"),em=s(`Segment Anything Model (SAM) for generating segmentation masks, given an input image and  optional 2D location and bounding boxes.
This model inherits from `),St=r("a"),om=s("TFPreTrainedModel"),tm=s(`. 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.)`),rm=d(),Vo=r("p"),nm=s("This model is also a TensorFlow "),Lo=r("a"),am=s("tf.keras.Model"),sm=s(`
subclass. Use it as a regular TensorFlow Model and refer to the TensorFlow documentation for all matter related to
general usage and behavior.`),im=d(),Z=r("div"),f(Zo.$$.fragment),mm=d(),ce=r("p"),dm=s("The "),wt=r("a"),lm=s("TFSamModel"),cm=s(" forward method, overrides the "),Mr=r("code"),pm=s("__call__"),hm=s(" special method."),fm=d(),f(De.$$.fragment),this.h()},l(o){const c=dl('[data-svelte="svelte-1phssyn"]',document.head);y=n(c,"META",{name:!0,content:!0}),c.forEach(t),$=l(o),w=n(o,"H1",{class:!0});var Bo=a(w);T=n(Bo,"A",{id:!0,class:!0,href:!0});var kr=a(T);z=n(kr,"SPAN",{});var xr=a(z);g(h.$$.fragment,xr),xr.forEach(t),kr.forEach(t),M=l(Bo),D=n(Bo,"SPAN",{});var Sm=a(D);An=i(Sm,"SAM"),Sm.forEach(t),Bo.forEach(t),zr=l(o),X=n(o,"H2",{class:!0});var rn=a(X);he=n(rn,"A",{id:!0,class:!0,href:!0});var wm=a(he);Jt=n(wm,"SPAN",{});var Tm=a(Jt);g(Re.$$.fragment,Tm),Tm.forEach(t),wm.forEach(t),Dn=l(rn),Wt=n(rn,"SPAN",{});var Mm=a(Wt);jn=i(Mm,"Overview"),Mm.forEach(t),rn.forEach(t),$r=l(o),fe=n(o,"P",{});var nn=a(fe);Un=i(nn,"SAM (Segment Anything Model) was proposed in "),Ve=n(nn,"A",{href:!0,rel:!0});var km=a(Ve);Jn=i(km,"Segment Anything"),km.forEach(t),Wn=i(nn," by Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alex Berg, Wan-Yen Lo, Piotr Dollar, Ross Girshick."),nn.forEach(t),Ir=l(o),Xo=n(o,"P",{});var xm=a(Xo);Fn=i(xm,"The model can be used to predict segmentation masks of any object of interest given an input image."),xm.forEach(t),Er=l(o),Yo=n(o,"P",{});var zm=a(Yo);Ho=n(zm,"IMG",{src:!0,alt:!0}),zm.forEach(t),Pr=l(o),Oo=n(o,"P",{});var $m=a(Oo);Rn=i($m,"The abstract from the paper is the following:"),$m.forEach(t),Cr=l(o),Qo=n(o,"P",{});var Im=a(Qo);Le=n(Im,"EM",{});var an=a(Le);Vn=i(an,"We introduce the Segment Anything (SA) project: a new task, model, and dataset for image segmentation. Using our efficient model in a data collection loop, we built the largest segmentation dataset to date (by far), with over 1 billion masks on 11M licensed and privacy respecting images. The model is designed and trained to be promptable, so it can transfer zero-shot to new image distributions and tasks. We evaluate its capabilities on numerous tasks and find that its zero-shot performance is impressive \u2014 often competitive with or even superior to prior fully supervised results. We are releasing the Segment Anything Model (SAM) and corresponding dataset (SA-1B) of 1B masks and 11M images at "),Ze=n(an,"A",{href:!0,rel:!0});var Em=a(Ze);Ln=i(Em,"https://segment-anything.com"),Em.forEach(t),Zn=i(an," to foster research into foundation models for computer vision."),an.forEach(t),Im.forEach(t),Nr=l(o),Ko=n(o,"P",{});var Pm=a(Ko);Bn=i(Pm,"Tips:"),Pm.forEach(t),Ar=l(o),E=n(o,"UL",{});var B=a(E);Ft=n(B,"LI",{});var Cm=a(Ft);qn=i(Cm,"The model predicts binary masks that states the presence or not of the object of interest given an image."),Cm.forEach(t),Gn=l(B),Rt=n(B,"LI",{});var Nm=a(Rt);Xn=i(Nm,"The model predicts much better results if input 2D points and/or input bounding boxes are provided"),Nm.forEach(t),Yn=l(B),Vt=n(B,"LI",{});var Am=a(Vt);Hn=i(Am,"You can prompt multiple points for the same image, and predict a single mask."),Am.forEach(t),On=l(B),Lt=n(B,"LI",{});var Dm=a(Lt);Qn=i(Dm,"Fine-tuning the model is not supported yet"),Dm.forEach(t),Kn=l(B),Be=n(B,"LI",{});var sn=a(Be);ea=i(sn,"According to the paper, textual input should be also supported. However, at this time of writing this seems to be not supported according to "),qe=n(sn,"A",{href:!0,rel:!0});var jm=a(qe);oa=i(jm,"the official repository"),jm.forEach(t),ta=i(sn,"."),sn.forEach(t),B.forEach(t),Dr=l(o),N=n(o,"P",{});var je=a(N);ra=i(je,"This model was contributed by "),Ge=n(je,"A",{href:!0,rel:!0});var Um=a(Ge);na=i(Um,"ybelkada"),Um.forEach(t),aa=i(je," and "),Xe=n(je,"A",{href:!0,rel:!0});var Jm=a(Xe);sa=i(Jm,"ArthurZ"),Jm.forEach(t),ia=i(je,`.
The original code can be found `),Ye=n(je,"A",{href:!0,rel:!0});var Wm=a(Ye);ma=i(Wm,"here"),Wm.forEach(t),da=i(je,"."),je.forEach(t),jr=l(o),et=n(o,"P",{});var Fm=a(et);la=i(Fm,"Below is an example on how to run mask generation given an image and a 2D point:"),Fm.forEach(t),Ur=l(o),g(He.$$.fragment,o),Jr=l(o),ot=n(o,"P",{});var Rm=a(ot);ca=i(Rm,"Resources:"),Rm.forEach(t),Wr=l(o),A=n(o,"UL",{});var Ue=a(A);tt=n(Ue,"LI",{});var gm=a(tt);Oe=n(gm,"A",{href:!0,rel:!0});var Vm=a(Oe);pa=i(Vm,"Demo notebook"),Vm.forEach(t),ha=i(gm," for using the model."),gm.forEach(t),fa=l(Ue),rt=n(Ue,"LI",{});var um=a(rt);Qe=n(um,"A",{href:!0,rel:!0});var Lm=a(Qe);ga=i(Lm,"Demo notebook"),Lm.forEach(t),ua=i(um," for using the automatic mask generation pipeline."),um.forEach(t),_a=l(Ue),nt=n(Ue,"LI",{});var _m=a(nt);Ke=n(_m,"A",{href:!0,rel:!0});var Zm=a(Ke);ba=i(Zm,"Demo notebook"),Zm.forEach(t),va=i(_m," for inference with MedSAM, a fine-tuned version of SAM on the medical domain."),_m.forEach(t),ya=l(Ue),at=n(Ue,"LI",{});var bm=a(at);eo=n(bm,"A",{href:!0,rel:!0});var Bm=a(eo);Sa=i(Bm,"Demo notebook"),Bm.forEach(t),wa=i(bm," for fine-tuning the model on custom data."),bm.forEach(t),Ue.forEach(t),Fr=l(o),Y=n(o,"H2",{class:!0});var mn=a(Y);ge=n(mn,"A",{id:!0,class:!0,href:!0});var qm=a(ge);Zt=n(qm,"SPAN",{});var Gm=a(Zt);g(oo.$$.fragment,Gm),Gm.forEach(t),qm.forEach(t),Ta=l(mn),Bt=n(mn,"SPAN",{});var Xm=a(Bt);Ma=i(Xm,"SamConfig"),Xm.forEach(t),mn.forEach(t),Rr=l(o),I=n(o,"DIV",{class:!0});var q=a(I);g(to.$$.fragment,q),ka=l(q),R=n(q,"P",{});var qo=a(R);st=n(qo,"A",{href:!0});var Ym=a(st);xa=i(Ym,"SamConfig"),Ym.forEach(t),za=i(qo," is the configuration class to store the configuration of a "),it=n(qo,"A",{href:!0});var Hm=a(it);$a=i(Hm,"SamModel"),Hm.forEach(t),Ia=i(qo,`. It is used to instantiate a
SAM model according to the specified arguments, defining the vision model, prompt-encoder model and mask decoder
configs. Instantiating a configuration with the defaults will yield a similar configuration to that of the
SAM-ViT-H `),ro=n(qo,"A",{href:!0,rel:!0});var Om=a(ro);Ea=i(Om,"facebook/sam-vit-huge"),Om.forEach(t),Pa=i(qo," architecture."),qo.forEach(t),Ca=l(q),H=n(q,"P",{});var Tt=a(H);Na=i(Tt,"Configuration objects inherit from "),mt=n(Tt,"A",{href:!0});var Qm=a(mt);Aa=i(Qm,"PretrainedConfig"),Qm.forEach(t),Da=i(Tt,` and can be used to control the model outputs. Read the
documentation from `),dt=n(Tt,"A",{href:!0});var Km=a(dt);ja=i(Km,"PretrainedConfig"),Km.forEach(t),Ua=i(Tt," for more information."),Tt.forEach(t),Ja=l(q),g(ue.$$.fragment,q),Wa=l(q),_e=n(q,"DIV",{class:!0});var dn=a(_e);g(no.$$.fragment,dn),Fa=l(dn),ao=n(dn,"P",{});var ln=a(ao);Ra=i(ln,"Serializes this instance to a Python dictionary. Override the default "),lt=n(ln,"A",{href:!0});var ed=a(lt);Va=i(ed,"to_dict()"),ed.forEach(t),La=i(ln,"."),ln.forEach(t),dn.forEach(t),q.forEach(t),Vr=l(o),O=n(o,"H2",{class:!0});var cn=a(O);be=n(cn,"A",{id:!0,class:!0,href:!0});var od=a(be);qt=n(od,"SPAN",{});var td=a(qt);g(so.$$.fragment,td),td.forEach(t),od.forEach(t),Za=l(cn),Gt=n(cn,"SPAN",{});var rd=a(Gt);Ba=i(rd,"SamVisionConfig"),rd.forEach(t),cn.forEach(t),Lr=l(o),j=n(o,"DIV",{class:!0});var Mt=a(j);g(io.$$.fragment,Mt),qa=l(Mt),Q=n(Mt,"P",{});var kt=a(Q);Ga=i(kt,"This is the configuration class to store the configuration of a "),Xt=n(kt,"CODE",{});var nd=a(Xt);Xa=i(nd,"SamVisionModel"),nd.forEach(t),Ya=i(kt,`. It is used to instantiate a SAM
vision encoder according to the specified arguments, defining the model architecture. Instantiating a configuration
defaults will yield a similar configuration to that of the SAM ViT-h
`),mo=n(kt,"A",{href:!0,rel:!0});var ad=a(mo);Ha=i(ad,"facebook/sam-vit-huge"),ad.forEach(t),Oa=i(kt," architecture."),kt.forEach(t),Qa=l(Mt),K=n(Mt,"P",{});var xt=a(K);Ka=i(xt,"Configuration objects inherit from "),ct=n(xt,"A",{href:!0});var sd=a(ct);es=i(sd,"PretrainedConfig"),sd.forEach(t),os=i(xt,` and can be used to control the model outputs. Read the
documentation from `),pt=n(xt,"A",{href:!0});var id=a(pt);ts=i(id,"PretrainedConfig"),id.forEach(t),rs=i(xt," for more information."),xt.forEach(t),Mt.forEach(t),Zr=l(o),ee=n(o,"H2",{class:!0});var pn=a(ee);ve=n(pn,"A",{id:!0,class:!0,href:!0});var md=a(ve);Yt=n(md,"SPAN",{});var dd=a(Yt);g(lo.$$.fragment,dd),dd.forEach(t),md.forEach(t),ns=l(pn),Ht=n(pn,"SPAN",{});var ld=a(Ht);as=i(ld,"SamMaskDecoderConfig"),ld.forEach(t),pn.forEach(t),Br=l(o),U=n(o,"DIV",{class:!0});var zt=a(U);g(co.$$.fragment,zt),ss=l(zt),oe=n(zt,"P",{});var $t=a(oe);is=i($t,"This is the configuration class to store the configuration of a "),Ot=n($t,"CODE",{});var cd=a(Ot);ms=i(cd,"SamMaskDecoder"),cd.forEach(t),ds=i($t,`. It is used to instantiate a SAM
mask decoder to the specified arguments, defining the model architecture. Instantiating a configuration defaults
will yield a similar configuration to that of the SAM-vit-h
`),po=n($t,"A",{href:!0,rel:!0});var pd=a(po);ls=i(pd,"facebook/sam-vit-huge"),pd.forEach(t),cs=i($t," architecture."),$t.forEach(t),ps=l(zt),te=n(zt,"P",{});var It=a(te);hs=i(It,"Configuration objects inherit from "),ht=n(It,"A",{href:!0});var hd=a(ht);fs=i(hd,"PretrainedConfig"),hd.forEach(t),gs=i(It,` and can be used to control the model outputs. Read the
documentation from `),ft=n(It,"A",{href:!0});var fd=a(ft);us=i(fd,"PretrainedConfig"),fd.forEach(t),_s=i(It," for more information."),It.forEach(t),zt.forEach(t),qr=l(o),re=n(o,"H2",{class:!0});var hn=a(re);ye=n(hn,"A",{id:!0,class:!0,href:!0});var gd=a(ye);Qt=n(gd,"SPAN",{});var ud=a(Qt);g(ho.$$.fragment,ud),ud.forEach(t),gd.forEach(t),bs=l(hn),Kt=n(hn,"SPAN",{});var _d=a(Kt);vs=i(_d,"SamPromptEncoderConfig"),_d.forEach(t),hn.forEach(t),Gr=l(o),J=n(o,"DIV",{class:!0});var Et=a(J);g(fo.$$.fragment,Et),ys=l(Et),W=n(Et,"P",{});var Je=a(W);Ss=i(Je,"This is the configuration class to store the configuration of a "),er=n(Je,"CODE",{});var bd=a(er);ws=i(bd,"SamPromptEncoder"),bd.forEach(t),Ts=i(Je,". The "),or=n(Je,"CODE",{});var vd=a(or);Ms=i(vd,"SamPromptEncoder"),vd.forEach(t),ks=i(Je,`
module is used to encode the input 2D points and bounding boxes. Instantiating a configuration defaults will yield
a similar configuration to that of the SAM-vit-h
`),go=n(Je,"A",{href:!0,rel:!0});var yd=a(go);xs=i(yd,"facebook/sam-vit-huge"),yd.forEach(t),zs=i(Je," architecture."),Je.forEach(t),$s=l(Et),ne=n(Et,"P",{});var Pt=a(ne);Is=i(Pt,"Configuration objects inherit from "),gt=n(Pt,"A",{href:!0});var Sd=a(gt);Es=i(Sd,"PretrainedConfig"),Sd.forEach(t),Ps=i(Pt,` and can be used to control the model outputs. Read the
documentation from `),ut=n(Pt,"A",{href:!0});var wd=a(ut);Cs=i(wd,"PretrainedConfig"),wd.forEach(t),Ns=i(Pt," for more information."),Pt.forEach(t),Et.forEach(t),Xr=l(o),ae=n(o,"H2",{class:!0});var fn=a(ae);Se=n(fn,"A",{id:!0,class:!0,href:!0});var Td=a(Se);tr=n(Td,"SPAN",{});var Md=a(tr);g(uo.$$.fragment,Md),Md.forEach(t),Td.forEach(t),As=l(fn),rr=n(fn,"SPAN",{});var kd=a(rr);Ds=i(kd,"SamProcessor"),kd.forEach(t),fn.forEach(t),Yr=l(o),F=n(o,"DIV",{class:!0});var Ct=a(F);g(_o.$$.fragment,Ct),js=l(Ct),nr=n(Ct,"P",{});var xd=a(nr);Us=i(xd,`Constructs a SAM processor which wraps a SAM image processor and an 2D points & Bounding boxes processor into a
single processor.`),xd.forEach(t),Js=l(Ct),V=n(Ct,"P",{});var Go=a(V);_t=n(Go,"A",{href:!0});var zd=a(_t);Ws=i(zd,"SamProcessor"),zd.forEach(t),Fs=i(Go," offers all the functionalities of "),bt=n(Go,"A",{href:!0});var $d=a(bt);Rs=i($d,"SamImageProcessor"),$d.forEach(t),Vs=i(Go,`. See the docstring of
`),bo=n(Go,"A",{href:!0});var vm=a(bo);ar=n(vm,"STRONG",{});var Id=a(ar);Ls=i(Id,"call"),Id.forEach(t),Zs=i(vm,"()"),vm.forEach(t),Bs=i(Go," for more information."),Go.forEach(t),Ct.forEach(t),Hr=l(o),se=n(o,"H2",{class:!0});var gn=a(se);we=n(gn,"A",{id:!0,class:!0,href:!0});var Ed=a(we);sr=n(Ed,"SPAN",{});var Pd=a(sr);g(vo.$$.fragment,Pd),Pd.forEach(t),Ed.forEach(t),qs=l(gn),ir=n(gn,"SPAN",{});var Cd=a(ir);Gs=i(Cd,"SamImageProcessor"),Cd.forEach(t),gn.forEach(t),Or=l(o),S=n(o,"DIV",{class:!0});var k=a(S);g(yo.$$.fragment,k),Xs=l(k),mr=n(k,"P",{});var Nd=a(mr);Ys=i(Nd,"Constructs a SAM image processor."),Nd.forEach(t),Hs=l(k),Te=n(k,"DIV",{class:!0});var un=a(Te);g(So.$$.fragment,un),Os=l(un),ie=n(un,"P",{});var Nt=a(ie);Qs=i(Nt,`Filters the predicted masks by selecting only the ones that meets several criteria. The first criterion being
that the iou scores needs to be greater than `),dr=n(Nt,"CODE",{});var Ad=a(dr);Ks=i(Ad,"pred_iou_thresh"),Ad.forEach(t),ei=i(Nt,`. The second criterion is that the stability
score needs to be greater than `),lr=n(Nt,"CODE",{});var Dd=a(lr);oi=i(Dd,"stability_score_thresh"),Dd.forEach(t),ti=i(Nt,`. The method also converts the predicted masks to
bounding boxes and pad the predicted masks if necessary.`),Nt.forEach(t),un.forEach(t),ri=l(k),Me=n(k,"DIV",{class:!0});var _n=a(Me);g(wo.$$.fragment,_n),ni=l(_n),To=n(_n,"P",{});var bn=a(To);ai=i(bn,"Generates a list of crop boxes of different sizes. Each layer has (2"),cr=n(bn,"STRONG",{});var jd=a(cr);si=i(jd,"i)"),jd.forEach(t),ii=i(bn,"2 boxes for the ith layer."),bn.forEach(t),_n.forEach(t),mi=l(k),ke=n(k,"DIV",{class:!0});var vn=a(ke);g(Mo.$$.fragment,vn),di=l(vn),pr=n(vn,"P",{});var Ud=a(pr);li=i(Ud,"Normalize an image. image = (image - image_mean) / image_std."),Ud.forEach(t),vn.forEach(t),ci=l(k),xe=n(k,"DIV",{class:!0});var yn=a(xe);g(ko.$$.fragment,yn),pi=l(yn),xo=n(yn,"P",{});var Sn=a(xo);hi=i(Sn,"Pad an image to "),hr=n(Sn,"CODE",{});var Jd=a(hr);fi=i(Jd,'(pad_size["height"], pad_size["width"])'),Jd.forEach(t),gi=i(Sn," with zeros to the right and bottom."),Sn.forEach(t),yn.forEach(t),ui=l(k),ze=n(k,"DIV",{class:!0});var wn=a(ze);g(zo.$$.fragment,wn),_i=l(wn),fr=n(wn,"P",{});var Wd=a(fr);bi=i(Wd,"Post processes mask that are generated by calling the Non Maximum Suppression algorithm on the predicted masks."),Wd.forEach(t),wn.forEach(t),vi=l(k),$e=n(k,"DIV",{class:!0});var Tn=a($e);g($o.$$.fragment,Tn),yi=l(Tn),gr=n(Tn,"P",{});var Fd=a(gr);Si=i(Fd,"Remove padding and upscale masks to the original image size."),Fd.forEach(t),Tn.forEach(t),wi=l(k),Ie=n(k,"DIV",{class:!0});var Mn=a(Ie);g(Io.$$.fragment,Mn),Ti=l(Mn),ur=n(Mn,"P",{});var Rd=a(ur);Mi=i(Rd,"Preprocess an image or batch of images."),Rd.forEach(t),Mn.forEach(t),ki=l(k),Ee=n(k,"DIV",{class:!0});var kn=a(Ee);g(Eo.$$.fragment,kn),xi=l(kn),_r=n(kn,"P",{});var Vd=a(_r);zi=i(Vd,"Rescale an image by a scale factor. image = image * scale."),Vd.forEach(t),kn.forEach(t),$i=l(k),Pe=n(k,"DIV",{class:!0});var xn=a(Pe);g(Po.$$.fragment,xn),Ii=l(xn),Co=n(xn,"P",{});var zn=a(Co);Ei=i(zn,"Resize an image to "),br=n(zn,"CODE",{});var Ld=a(br);Pi=i(Ld,'(size["height"], size["width"])'),Ld.forEach(t),Ci=i(zn,"."),zn.forEach(t),xn.forEach(t),k.forEach(t),Qr=l(o),me=n(o,"H2",{class:!0});var $n=a(me);Ce=n($n,"A",{id:!0,class:!0,href:!0});var Zd=a(Ce);vr=n(Zd,"SPAN",{});var Bd=a(vr);g(No.$$.fragment,Bd),Bd.forEach(t),Zd.forEach(t),Ni=l($n),yr=n($n,"SPAN",{});var qd=a(yr);Ai=i(qd,"SamModel"),qd.forEach(t),$n.forEach(t),Kr=l(o),P=n(o,"DIV",{class:!0});var We=a(P);g(Ao.$$.fragment,We),Di=l(We),Do=n(We,"P",{});var In=a(Do);ji=i(In,`Segment Anything Model (SAM) for generating segmentation masks, given an input image and  optional 2D location and bounding boxes.
This model inherits from `),vt=n(In,"A",{href:!0});var Gd=a(vt);Ui=i(Gd,"PreTrainedModel"),Gd.forEach(t),Ji=i(In,`. 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.)`),In.forEach(t),Wi=l(We),jo=n(We,"P",{});var En=a(jo);Fi=i(En,"This model is also a PyTorch "),Uo=n(En,"A",{href:!0,rel:!0});var Xd=a(Uo);Ri=i(Xd,"torch.nn.Module"),Xd.forEach(t),Vi=i(En,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),En.forEach(t),Li=l(We),L=n(We,"DIV",{class:!0});var At=a(L);g(Jo.$$.fragment,At),Zi=l(At),de=n(At,"P",{});var Dt=a(de);Bi=i(Dt,"The "),yt=n(Dt,"A",{href:!0});var Yd=a(yt);qi=i(Yd,"SamModel"),Yd.forEach(t),Gi=i(Dt," forward method, overrides the "),Sr=n(Dt,"CODE",{});var Hd=a(Sr);Xi=i(Hd,"__call__"),Hd.forEach(t),Yi=i(Dt," special method."),Dt.forEach(t),Hi=l(At),g(Ne.$$.fragment,At),At.forEach(t),We.forEach(t),en=l(o),le=n(o,"H2",{class:!0});var Pn=a(le);Ae=n(Pn,"A",{id:!0,class:!0,href:!0});var Od=a(Ae);wr=n(Od,"SPAN",{});var Qd=a(wr);g(Wo.$$.fragment,Qd),Qd.forEach(t),Od.forEach(t),Oi=l(Pn),Tr=n(Pn,"SPAN",{});var Kd=a(Tr);Qi=i(Kd,"TFSamModel"),Kd.forEach(t),Pn.forEach(t),on=l(o),C=n(o,"DIV",{class:!0});var Fe=a(C);g(Fo.$$.fragment,Fe),Ki=l(Fe),Ro=n(Fe,"P",{});var Cn=a(Ro);em=i(Cn,`Segment Anything Model (SAM) for generating segmentation masks, given an input image and  optional 2D location and bounding boxes.
This model inherits from `),St=n(Cn,"A",{href:!0});var el=a(St);om=i(el,"TFPreTrainedModel"),el.forEach(t),tm=i(Cn,`. 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.)`),Cn.forEach(t),rm=l(Fe),Vo=n(Fe,"P",{});var Nn=a(Vo);nm=i(Nn,"This model is also a TensorFlow "),Lo=n(Nn,"A",{href:!0,rel:!0});var ol=a(Lo);am=i(ol,"tf.keras.Model"),ol.forEach(t),sm=i(Nn,`
subclass. Use it as a regular TensorFlow Model and refer to the TensorFlow documentation for all matter related to
general usage and behavior.`),Nn.forEach(t),im=l(Fe),Z=n(Fe,"DIV",{class:!0});var jt=a(Z);g(Zo.$$.fragment,jt),mm=l(jt),ce=n(jt,"P",{});var Ut=a(ce);dm=i(Ut,"The "),wt=n(Ut,"A",{href:!0});var tl=a(wt);lm=i(tl,"TFSamModel"),tl.forEach(t),cm=i(Ut," forward method, overrides the "),Mr=n(Ut,"CODE",{});var rl=a(Mr);pm=i(rl,"__call__"),rl.forEach(t),hm=i(Ut," special method."),Ut.forEach(t),fm=l(jt),g(De.$$.fragment,jt),jt.forEach(t),Fe.forEach(t),this.h()},h(){m(y,"name","hf:doc:metadata"),m(y,"content",JSON.stringify(bl)),m(T,"id","sam"),m(T,"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"),m(T,"href","#sam"),m(w,"class","relative group"),m(he,"id","overview"),m(he,"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"),m(he,"href","#overview"),m(X,"class","relative group"),m(Ve,"href","https://arxiv.org/pdf/2304.02643v1.pdf"),m(Ve,"rel","nofollow"),ll(Ho.src,ym="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/sam-output.png")||m(Ho,"src",ym),m(Ho,"alt","example image"),m(Ze,"href","https://segment-anything.com"),m(Ze,"rel","nofollow"),m(qe,"href","https://github.com/facebookresearch/segment-anything/issues/4#issuecomment-1497626844"),m(qe,"rel","nofollow"),m(Ge,"href","https://huggingface.co/ybelkada"),m(Ge,"rel","nofollow"),m(Xe,"href","https://huggingface.co/ArthurZ"),m(Xe,"rel","nofollow"),m(Ye,"href","https://github.com/facebookresearch/segment-anything"),m(Ye,"rel","nofollow"),m(Oe,"href","https://github.com/huggingface/notebooks/blob/main/examples/segment_anything.ipynb"),m(Oe,"rel","nofollow"),m(Qe,"href","https://github.com/huggingface/notebooks/blob/main/examples/automatic_mask_generation.ipynb"),m(Qe,"rel","nofollow"),m(Ke,"href","https://github.com/NielsRogge/Transformers-Tutorials/blob/master/SAM/Run_inference_with_MedSAM_using_HuggingFace_Transformers.ipynb"),m(Ke,"rel","nofollow"),m(eo,"href","https://github.com/NielsRogge/Transformers-Tutorials/blob/master/SAM/Fine_tune_SAM_(segment_anything)_on_a_custom_dataset.ipynb"),m(eo,"rel","nofollow"),m(ge,"id","transformers.SamConfig"),m(ge,"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"),m(ge,"href","#transformers.SamConfig"),m(Y,"class","relative group"),m(st,"href","/docs/transformers/v4.30.0/en/model_doc/sam#transformers.SamConfig"),m(it,"href","/docs/transformers/v4.30.0/en/model_doc/sam#transformers.SamModel"),m(ro,"href","https://huggingface.co/facebook/sam-vit-huge"),m(ro,"rel","nofollow"),m(mt,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(dt,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(lt,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig.to_dict"),m(_e,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(be,"id","transformers.SamVisionConfig"),m(be,"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"),m(be,"href","#transformers.SamVisionConfig"),m(O,"class","relative group"),m(mo,"href","https://huggingface.co/facebook/sam-vit-huge"),m(mo,"rel","nofollow"),m(ct,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(pt,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ve,"id","transformers.SamMaskDecoderConfig"),m(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"),m(ve,"href","#transformers.SamMaskDecoderConfig"),m(ee,"class","relative group"),m(po,"href","https://huggingface.co/facebook/sam-vit-huge"),m(po,"rel","nofollow"),m(ht,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(ft,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ye,"id","transformers.SamPromptEncoderConfig"),m(ye,"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"),m(ye,"href","#transformers.SamPromptEncoderConfig"),m(re,"class","relative group"),m(go,"href","https://huggingface.co/facebook/sam-vit-huge"),m(go,"rel","nofollow"),m(gt,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(ut,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Se,"id","transformers.SamProcessor"),m(Se,"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"),m(Se,"href","#transformers.SamProcessor"),m(ae,"class","relative group"),m(_t,"href","/docs/transformers/v4.30.0/en/model_doc/sam#transformers.SamProcessor"),m(bt,"href","/docs/transformers/v4.30.0/en/model_doc/sam#transformers.SamImageProcessor"),m(bo,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor.__call__"),m(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(we,"id","transformers.SamImageProcessor"),m(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"),m(we,"href","#transformers.SamImageProcessor"),m(se,"class","relative group"),m(Te,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Me,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ke,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(xe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ze,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m($e,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Ie,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Pe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Ce,"id","transformers.SamModel"),m(Ce,"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"),m(Ce,"href","#transformers.SamModel"),m(me,"class","relative group"),m(vt,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.PreTrainedModel"),m(Uo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(Uo,"rel","nofollow"),m(yt,"href","/docs/transformers/v4.30.0/en/model_doc/sam#transformers.SamModel"),m(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Ae,"id","transformers.TFSamModel"),m(Ae,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(Ae,"href","#transformers.TFSamModel"),m(le,"class","relative group"),m(St,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.TFPreTrainedModel"),m(Lo,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),m(Lo,"rel","nofollow"),m(wt,"href","/docs/transformers/v4.30.0/en/model_doc/sam#transformers.TFSamModel"),m(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(o,c){e(document.head,y),p(o,$,c),p(o,w,c),e(w,T),e(T,z),u(h,z,null),e(w,M),e(w,D),e(D,An),p(o,zr,c),p(o,X,c),e(X,he),e(he,Jt),u(Re,Jt,null),e(X,Dn),e(X,Wt),e(Wt,jn),p(o,$r,c),p(o,fe,c),e(fe,Un),e(fe,Ve),e(Ve,Jn),e(fe,Wn),p(o,Ir,c),p(o,Xo,c),e(Xo,Fn),p(o,Er,c),p(o,Yo,c),e(Yo,Ho),p(o,Pr,c),p(o,Oo,c),e(Oo,Rn),p(o,Cr,c),p(o,Qo,c),e(Qo,Le),e(Le,Vn),e(Le,Ze),e(Ze,Ln),e(Le,Zn),p(o,Nr,c),p(o,Ko,c),e(Ko,Bn),p(o,Ar,c),p(o,E,c),e(E,Ft),e(Ft,qn),e(E,Gn),e(E,Rt),e(Rt,Xn),e(E,Yn),e(E,Vt),e(Vt,Hn),e(E,On),e(E,Lt),e(Lt,Qn),e(E,Kn),e(E,Be),e(Be,ea),e(Be,qe),e(qe,oa),e(Be,ta),p(o,Dr,c),p(o,N,c),e(N,ra),e(N,Ge),e(Ge,na),e(N,aa),e(N,Xe),e(Xe,sa),e(N,ia),e(N,Ye),e(Ye,ma),e(N,da),p(o,jr,c),p(o,et,c),e(et,la),p(o,Ur,c),u(He,o,c),p(o,Jr,c),p(o,ot,c),e(ot,ca),p(o,Wr,c),p(o,A,c),e(A,tt),e(tt,Oe),e(Oe,pa),e(tt,ha),e(A,fa),e(A,rt),e(rt,Qe),e(Qe,ga),e(rt,ua),e(A,_a),e(A,nt),e(nt,Ke),e(Ke,ba),e(nt,va),e(A,ya),e(A,at),e(at,eo),e(eo,Sa),e(at,wa),p(o,Fr,c),p(o,Y,c),e(Y,ge),e(ge,Zt),u(oo,Zt,null),e(Y,Ta),e(Y,Bt),e(Bt,Ma),p(o,Rr,c),p(o,I,c),u(to,I,null),e(I,ka),e(I,R),e(R,st),e(st,xa),e(R,za),e(R,it),e(it,$a),e(R,Ia),e(R,ro),e(ro,Ea),e(R,Pa),e(I,Ca),e(I,H),e(H,Na),e(H,mt),e(mt,Aa),e(H,Da),e(H,dt),e(dt,ja),e(H,Ua),e(I,Ja),u(ue,I,null),e(I,Wa),e(I,_e),u(no,_e,null),e(_e,Fa),e(_e,ao),e(ao,Ra),e(ao,lt),e(lt,Va),e(ao,La),p(o,Vr,c),p(o,O,c),e(O,be),e(be,qt),u(so,qt,null),e(O,Za),e(O,Gt),e(Gt,Ba),p(o,Lr,c),p(o,j,c),u(io,j,null),e(j,qa),e(j,Q),e(Q,Ga),e(Q,Xt),e(Xt,Xa),e(Q,Ya),e(Q,mo),e(mo,Ha),e(Q,Oa),e(j,Qa),e(j,K),e(K,Ka),e(K,ct),e(ct,es),e(K,os),e(K,pt),e(pt,ts),e(K,rs),p(o,Zr,c),p(o,ee,c),e(ee,ve),e(ve,Yt),u(lo,Yt,null),e(ee,ns),e(ee,Ht),e(Ht,as),p(o,Br,c),p(o,U,c),u(co,U,null),e(U,ss),e(U,oe),e(oe,is),e(oe,Ot),e(Ot,ms),e(oe,ds),e(oe,po),e(po,ls),e(oe,cs),e(U,ps),e(U,te),e(te,hs),e(te,ht),e(ht,fs),e(te,gs),e(te,ft),e(ft,us),e(te,_s),p(o,qr,c),p(o,re,c),e(re,ye),e(ye,Qt),u(ho,Qt,null),e(re,bs),e(re,Kt),e(Kt,vs),p(o,Gr,c),p(o,J,c),u(fo,J,null),e(J,ys),e(J,W),e(W,Ss),e(W,er),e(er,ws),e(W,Ts),e(W,or),e(or,Ms),e(W,ks),e(W,go),e(go,xs),e(W,zs),e(J,$s),e(J,ne),e(ne,Is),e(ne,gt),e(gt,Es),e(ne,Ps),e(ne,ut),e(ut,Cs),e(ne,Ns),p(o,Xr,c),p(o,ae,c),e(ae,Se),e(Se,tr),u(uo,tr,null),e(ae,As),e(ae,rr),e(rr,Ds),p(o,Yr,c),p(o,F,c),u(_o,F,null),e(F,js),e(F,nr),e(nr,Us),e(F,Js),e(F,V),e(V,_t),e(_t,Ws),e(V,Fs),e(V,bt),e(bt,Rs),e(V,Vs),e(V,bo),e(bo,ar),e(ar,Ls),e(bo,Zs),e(V,Bs),p(o,Hr,c),p(o,se,c),e(se,we),e(we,sr),u(vo,sr,null),e(se,qs),e(se,ir),e(ir,Gs),p(o,Or,c),p(o,S,c),u(yo,S,null),e(S,Xs),e(S,mr),e(mr,Ys),e(S,Hs),e(S,Te),u(So,Te,null),e(Te,Os),e(Te,ie),e(ie,Qs),e(ie,dr),e(dr,Ks),e(ie,ei),e(ie,lr),e(lr,oi),e(ie,ti),e(S,ri),e(S,Me),u(wo,Me,null),e(Me,ni),e(Me,To),e(To,ai),e(To,cr),e(cr,si),e(To,ii),e(S,mi),e(S,ke),u(Mo,ke,null),e(ke,di),e(ke,pr),e(pr,li),e(S,ci),e(S,xe),u(ko,xe,null),e(xe,pi),e(xe,xo),e(xo,hi),e(xo,hr),e(hr,fi),e(xo,gi),e(S,ui),e(S,ze),u(zo,ze,null),e(ze,_i),e(ze,fr),e(fr,bi),e(S,vi),e(S,$e),u($o,$e,null),e($e,yi),e($e,gr),e(gr,Si),e(S,wi),e(S,Ie),u(Io,Ie,null),e(Ie,Ti),e(Ie,ur),e(ur,Mi),e(S,ki),e(S,Ee),u(Eo,Ee,null),e(Ee,xi),e(Ee,_r),e(_r,zi),e(S,$i),e(S,Pe),u(Po,Pe,null),e(Pe,Ii),e(Pe,Co),e(Co,Ei),e(Co,br),e(br,Pi),e(Co,Ci),p(o,Qr,c),p(o,me,c),e(me,Ce),e(Ce,vr),u(No,vr,null),e(me,Ni),e(me,yr),e(yr,Ai),p(o,Kr,c),p(o,P,c),u(Ao,P,null),e(P,Di),e(P,Do),e(Do,ji),e(Do,vt),e(vt,Ui),e(Do,Ji),e(P,Wi),e(P,jo),e(jo,Fi),e(jo,Uo),e(Uo,Ri),e(jo,Vi),e(P,Li),e(P,L),u(Jo,L,null),e(L,Zi),e(L,de),e(de,Bi),e(de,yt),e(yt,qi),e(de,Gi),e(de,Sr),e(Sr,Xi),e(de,Yi),e(L,Hi),u(Ne,L,null),p(o,en,c),p(o,le,c),e(le,Ae),e(Ae,wr),u(Wo,wr,null),e(le,Oi),e(le,Tr),e(Tr,Qi),p(o,on,c),p(o,C,c),u(Fo,C,null),e(C,Ki),e(C,Ro),e(Ro,em),e(Ro,St),e(St,om),e(Ro,tm),e(C,rm),e(C,Vo),e(Vo,nm),e(Vo,Lo),e(Lo,am),e(Vo,sm),e(C,im),e(C,Z),u(Zo,Z,null),e(Z,mm),e(Z,ce),e(ce,dm),e(ce,wt),e(wt,lm),e(ce,cm),e(ce,Mr),e(Mr,pm),e(ce,hm),e(Z,fm),u(De,Z,null),tn=!0},p(o,[c]){const Bo={};c&2&&(Bo.$$scope={dirty:c,ctx:o}),ue.$set(Bo);const kr={};c&2&&(kr.$$scope={dirty:c,ctx:o}),Ne.$set(kr);const xr={};c&2&&(xr.$$scope={dirty:c,ctx:o}),De.$set(xr)},i(o){tn||(_(h.$$.fragment,o),_(Re.$$.fragment,o),_(He.$$.fragment,o),_(oo.$$.fragment,o),_(to.$$.fragment,o),_(ue.$$.fragment,o),_(no.$$.fragment,o),_(so.$$.fragment,o),_(io.$$.fragment,o),_(lo.$$.fragment,o),_(co.$$.fragment,o),_(ho.$$.fragment,o),_(fo.$$.fragment,o),_(uo.$$.fragment,o),_(_o.$$.fragment,o),_(vo.$$.fragment,o),_(yo.$$.fragment,o),_(So.$$.fragment,o),_(wo.$$.fragment,o),_(Mo.$$.fragment,o),_(ko.$$.fragment,o),_(zo.$$.fragment,o),_($o.$$.fragment,o),_(Io.$$.fragment,o),_(Eo.$$.fragment,o),_(Po.$$.fragment,o),_(No.$$.fragment,o),_(Ao.$$.fragment,o),_(Jo.$$.fragment,o),_(Ne.$$.fragment,o),_(Wo.$$.fragment,o),_(Fo.$$.fragment,o),_(Zo.$$.fragment,o),_(De.$$.fragment,o),tn=!0)},o(o){b(h.$$.fragment,o),b(Re.$$.fragment,o),b(He.$$.fragment,o),b(oo.$$.fragment,o),b(to.$$.fragment,o),b(ue.$$.fragment,o),b(no.$$.fragment,o),b(so.$$.fragment,o),b(io.$$.fragment,o),b(lo.$$.fragment,o),b(co.$$.fragment,o),b(ho.$$.fragment,o),b(fo.$$.fragment,o),b(uo.$$.fragment,o),b(_o.$$.fragment,o),b(vo.$$.fragment,o),b(yo.$$.fragment,o),b(So.$$.fragment,o),b(wo.$$.fragment,o),b(Mo.$$.fragment,o),b(ko.$$.fragment,o),b(zo.$$.fragment,o),b($o.$$.fragment,o),b(Io.$$.fragment,o),b(Eo.$$.fragment,o),b(Po.$$.fragment,o),b(No.$$.fragment,o),b(Ao.$$.fragment,o),b(Jo.$$.fragment,o),b(Ne.$$.fragment,o),b(Wo.$$.fragment,o),b(Fo.$$.fragment,o),b(Zo.$$.fragment,o),b(De.$$.fragment,o),tn=!1},d(o){t(y),o&&t($),o&&t(w),v(h),o&&t(zr),o&&t(X),v(Re),o&&t($r),o&&t(fe),o&&t(Ir),o&&t(Xo),o&&t(Er),o&&t(Yo),o&&t(Pr),o&&t(Oo),o&&t(Cr),o&&t(Qo),o&&t(Nr),o&&t(Ko),o&&t(Ar),o&&t(E),o&&t(Dr),o&&t(N),o&&t(jr),o&&t(et),o&&t(Ur),v(He,o),o&&t(Jr),o&&t(ot),o&&t(Wr),o&&t(A),o&&t(Fr),o&&t(Y),v(oo),o&&t(Rr),o&&t(I),v(to),v(ue),v(no),o&&t(Vr),o&&t(O),v(so),o&&t(Lr),o&&t(j),v(io),o&&t(Zr),o&&t(ee),v(lo),o&&t(Br),o&&t(U),v(co),o&&t(qr),o&&t(re),v(ho),o&&t(Gr),o&&t(J),v(fo),o&&t(Xr),o&&t(ae),v(uo),o&&t(Yr),o&&t(F),v(_o),o&&t(Hr),o&&t(se),v(vo),o&&t(Or),o&&t(S),v(yo),v(So),v(wo),v(Mo),v(ko),v(zo),v($o),v(Io),v(Eo),v(Po),o&&t(Qr),o&&t(me),v(No),o&&t(Kr),o&&t(P),v(Ao),v(Jo),v(Ne),o&&t(en),o&&t(le),v(Wo),o&&t(on),o&&t(C),v(Fo),v(Zo),v(De)}}}const bl={local:"sam",sections:[{local:"overview",title:"Overview"},{local:"transformers.SamConfig",title:"SamConfig"},{local:"transformers.SamVisionConfig",title:"SamVisionConfig"},{local:"transformers.SamMaskDecoderConfig",title:"SamMaskDecoderConfig"},{local:"transformers.SamPromptEncoderConfig",title:"SamPromptEncoderConfig"},{local:"transformers.SamProcessor",title:"SamProcessor"},{local:"transformers.SamImageProcessor",title:"SamImageProcessor"},{local:"transformers.SamModel",title:"SamModel"},{local:"transformers.TFSamModel",title:"TFSamModel"}],title:"SAM"};function vl(pe){return cl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class xl extends sl{constructor(y){super();il(this,y,vl,_l,ml,{})}}export{xl as default,bl as metadata};
