import{S as Pd,i as Nd,s as Ad,e as n,k as d,w as g,t as s,M as Dd,c as r,d as t,m as l,a,x as u,h as i,b as m,N as Ud,G as e,g as p,y as _,q as b,o as v,B as y,v as jd,L as Jd}from"../../chunks/vendor-hf-doc-builder.js";import{T as Ed}from"../../chunks/Tip-hf-doc-builder.js";import{D as I}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Cd}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as q}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Fd}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Wd(ce){let f,z,w,S,k;return S=new Cd({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(){f=n("p"),z=s("Example:"),w=d(),g(S.$$.fragment)},l(h){f=r(h,"P",{});var T=a(f);z=i(T,"Example:"),T.forEach(t),w=l(h),u(S.$$.fragment,h)},m(h,T){p(h,f,T),e(f,z),p(h,w,T),_(S,h,T),k=!0},p:Jd,i(h){k||(b(S.$$.fragment,h),k=!0)},o(h){v(S.$$.fragment,h),k=!1},d(h){h&&t(f),h&&t(w),y(S,h)}}}function Rd(ce){let f,z,w,S,k;return{c(){f=n("p"),z=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),w=n("code"),S=s("Module"),k=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){f=r(h,"P",{});var T=a(f);z=i(T,"Although the recipe for forward pass needs to be defined within this function, one should call the "),w=r(T,"CODE",{});var D=a(w);S=i(D,"Module"),D.forEach(t),k=i(T,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),T.forEach(t)},m(h,T){p(h,f,T),e(f,z),e(f,w),e(w,S),e(f,k)},d(h){h&&t(f)}}}function Vd(ce){let f,z,w,S,k;return{c(){f=n("p"),z=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),w=n("code"),S=s("Module"),k=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){f=r(h,"P",{});var T=a(f);z=i(T,"Although the recipe for forward pass needs to be defined within this function, one should call the "),w=r(T,"CODE",{});var D=a(w);S=i(D,"Module"),D.forEach(t),k=i(T,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),T.forEach(t)},m(h,T){p(h,f,T),e(f,z),e(f,w),e(w,S),e(f,k)},d(h){h&&t(f)}}}function Zd(ce){let f,z,w,S,k,h,T,D,yr,bn,G,pe,Et,Je,wr,Ct,Sr,vn,he,Tr,Fe,Mr,kr,yn,Ro,xr,wn,Vo,Zo,Yi,Sn,Bo,Ir,Tn,Lo,We,zr,Re,$r,Er,Mn,qo,Cr,kn,$,Pt,Pr,Nr,Nt,Ar,Dr,At,Ur,jr,Dt,Jr,Fr,Ve,Wr,Ze,Rr,Vr,xn,N,Zr,Be,Br,Lr,Le,qr,Gr,qe,Xr,Yr,In,Go,Hr,zn,Ge,$n,Xo,Or,En,A,Yo,Xe,Qr,Kr,ea,Ho,Ye,oa,ta,na,Oo,He,ra,aa,sa,Qo,Oe,ia,ma,Cn,X,fe,Ut,Qe,da,jt,la,Pn,E,Ke,ca,R,Ko,pa,ha,et,fa,ga,eo,ua,_a,ba,Y,va,ot,ya,wa,tt,Sa,Ta,Ma,ge,Nn,H,ue,Jt,oo,ka,Ft,xa,An,U,to,Ia,O,za,Wt,$a,Ea,no,Ca,Pa,Na,Q,Aa,nt,Da,Ua,rt,ja,Ja,Dn,K,_e,Rt,ro,Fa,Vt,Wa,Un,j,ao,Ra,ee,Va,Zt,Za,Ba,so,La,qa,Ga,oe,Xa,at,Ya,Ha,st,Oa,Qa,jn,te,be,Bt,io,Ka,Lt,es,Jn,J,mo,os,F,ts,qt,ns,rs,Gt,as,ss,lo,is,ms,ds,ne,ls,it,cs,ps,mt,hs,fs,Fn,re,ve,Xt,co,gs,Yt,us,Wn,W,po,_s,Ht,bs,vs,V,dt,ys,ws,lt,Ss,Ts,ho,Ot,Ms,ks,xs,Rn,ae,ye,Qt,fo,Is,Kt,zs,Vn,M,go,$s,en,Es,Cs,we,uo,Ps,se,Ns,on,As,Ds,tn,Us,js,Js,Se,_o,Fs,bo,Ws,nn,Rs,Vs,Zs,Te,vo,Bs,yo,Ls,rn,qs,Gs,Xs,Me,wo,Ys,an,Hs,Os,ke,So,Qs,sn,Ks,ei,xe,To,oi,mn,ti,ni,Ie,Mo,ri,ko,ai,dn,si,ii,Zn,ie,ze,ln,xo,mi,cn,di,Bn,C,Io,li,zo,ci,ct,pi,hi,fi,$o,gi,Eo,ui,_i,bi,Z,Co,vi,me,yi,pt,wi,Si,pn,Ti,Mi,ki,$e,Ln,de,Ee,hn,Po,xi,fn,Ii,qn,P,No,zi,Ao,$i,ht,Ei,Ci,Pi,Do,Ni,Uo,Ai,Di,Ui,B,jo,ji,le,Ji,ft,Fi,Wi,gn,Ri,Vi,Zi,Ce,Gn;return h=new q({}),Je=new q({}),Ge=new Cd({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`}}),Qe=new q({}),Ke=new I({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/main/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/main/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/main/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/main/src/transformers/models/sam/configuration_sam.py#L237"}}),ge=new Fd({props:{anchor:"transformers.SamConfig.example",$$slots:{default:[Wd]},$$scope:{ctx:ce}}}),oo=new q({}),to=new I({props:{name:"class transformers.SamVisionConfig",anchor:"transformers.SamVisionConfig",parameters:[{name:"hidden_size",val:" = 768"},{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:"attention_dropout",val:" = 0.0"},{name:"initializer_range",val:" = 1e-10"},{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.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.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.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/main/src/transformers/models/sam/configuration_sam.py#L139"}}),ro=new q({}),ao=new I({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/main/src/transformers/models/sam/configuration_sam.py#L78"}}),io=new q({}),mo=new I({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/main/src/transformers/models/sam/configuration_sam.py#L31"}}),co=new q({}),po=new I({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/main/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/main/src/transformers/models/sam/processing_sam.py#L35"}}),fo=new q({}),go=new I({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/main/src/transformers/models/sam/image_processing_sam.py#L64"}}),uo=new I({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/main/src/transformers/models/sam/image_processing_sam.py#L631"}}),_o=new I({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:"input_data_format",val:": typing.Union[str, transformers.image_utils.ChannelDimension, NoneType] = 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.input_data_format",description:`<strong>input_data_format</strong> (<code>str</code> or <code>ChannelDimension</code>, <em>optional</em>) &#x2014;
The channel dimension format of the input image. If not provided, it will be inferred.`,name:"input_data_format"},{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/main/src/transformers/models/sam/image_processing_sam.py#L566"}}),vo=new I({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:"input_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"},{anchor:"transformers.SamImageProcessor.pad_image.input_data_format",description:`<strong>input_data_format</strong> (<code>str</code> or <code>ChannelDimension</code>, <em>optional</em>) &#x2014;
The channel dimension format of the input image. If not provided, it will be inferred.`,name:"input_data_format"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/image_processing_sam.py#L142"}}),wo=new I({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/main/src/transformers/models/sam/image_processing_sam.py#L543"}}),So=new I({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/main/src/transformers/models/sam/image_processing_sam.py#L399",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>
`}}),To=new I({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:"input_data_format",val:": typing.Union[str, transformers.image_utils.ChannelDimension, NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamImageProcessor.preprocess.images",description:`<strong>images</strong> (<code>ImageInput</code>) &#x2014;
Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If
passing in images with pixel values between 0 and 1, set <code>do_rescale=False</code>.`,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"},{anchor:"transformers.SamImageProcessor.preprocess.input_data_format",description:`<strong>input_data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>) &#x2014;
The channel dimension format for the input image. If unset, the channel dimension format is inferred
from the input 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><code>&quot;none&quot;</code> or <code>ChannelDimension.NONE</code>: image in (height, width) format.</li>
</ul>`,name:"input_data_format"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/image_processing_sam.py#L239"}}),Mo=new I({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:"input_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"},{anchor:"transformers.SamImageProcessor.resize.input_data_format",description:`<strong>input_data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>) &#x2014;
The channel dimension format for the input image. If unset, the channel dimension format is inferred
from the input 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>
</ul>`,name:"input_data_format"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/image_processing_sam.py#L190",returnDescription:`
<p>The resized image.</p>
`,returnType:`
<p><code>np.ndarray</code></p>
`}}),xo=new q({}),Io=new I({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/main/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/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/modeling_sam.py#L1192"}}),Co=new I({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:": typing.Optional[bool] = 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/main/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/main/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/main/src/transformers/models/sam/modeling_sam.py#L1285"}}),$e=new Ed({props:{$$slots:{default:[Rd]},$$scope:{ctx:ce}}}),Po=new q({}),No=new I({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/main/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/main/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/main/src/transformers/models/sam/modeling_tf_sam.py#L1237"}}),jo=new I({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:": bool | None = None"},{name:"output_hidden_states",val:": bool | None = None"},{name:"return_dict",val:": bool | None = None"},{name:"training",val:": bool = 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/main/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/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/modeling_tf_sam.py#L1327"}}),Ce=new Ed({props:{$$slots:{default:[Vd]},$$scope:{ctx:ce}}}),{c(){f=n("meta"),z=d(),w=n("h1"),S=n("a"),k=n("span"),g(h.$$.fragment),T=d(),D=n("span"),yr=s("SAM"),bn=d(),G=n("h2"),pe=n("a"),Et=n("span"),g(Je.$$.fragment),wr=d(),Ct=n("span"),Sr=s("Overview"),vn=d(),he=n("p"),Tr=s("SAM (Segment Anything Model) was proposed in "),Fe=n("a"),Mr=s("Segment Anything"),kr=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."),yn=d(),Ro=n("p"),xr=s("The model can be used to predict segmentation masks of any object of interest given an input image."),wn=d(),Vo=n("p"),Zo=n("img"),Sn=d(),Bo=n("p"),Ir=s("The abstract from the paper is the following:"),Tn=d(),Lo=n("p"),We=n("em"),zr=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 "),Re=n("a"),$r=s("https://segment-anything.com"),Er=s(" to foster research into foundation models for computer vision."),Mn=d(),qo=n("p"),Cr=s("Tips:"),kn=d(),$=n("ul"),Pt=n("li"),Pr=s("The model predicts binary masks that states the presence or not of the object of interest given an image."),Nr=d(),Nt=n("li"),Ar=s("The model predicts much better results if input 2D points and/or input bounding boxes are provided"),Dr=d(),At=n("li"),Ur=s("You can prompt multiple points for the same image, and predict a single mask."),jr=d(),Dt=n("li"),Jr=s("Fine-tuning the model is not supported yet"),Fr=d(),Ve=n("li"),Wr=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 "),Ze=n("a"),Rr=s("the official repository"),Vr=s("."),xn=d(),N=n("p"),Zr=s("This model was contributed by "),Be=n("a"),Br=s("ybelkada"),Lr=s(" and "),Le=n("a"),qr=s("ArthurZ"),Gr=s(`.
The original code can be found `),qe=n("a"),Xr=s("here"),Yr=s("."),In=d(),Go=n("p"),Hr=s("Below is an example on how to run mask generation given an image and a 2D point:"),zn=d(),g(Ge.$$.fragment),$n=d(),Xo=n("p"),Or=s("Resources:"),En=d(),A=n("ul"),Yo=n("li"),Xe=n("a"),Qr=s("Demo notebook"),Kr=s(" for using the model."),ea=d(),Ho=n("li"),Ye=n("a"),oa=s("Demo notebook"),ta=s(" for using the automatic mask generation pipeline."),na=d(),Oo=n("li"),He=n("a"),ra=s("Demo notebook"),aa=s(" for inference with MedSAM, a fine-tuned version of SAM on the medical domain."),sa=d(),Qo=n("li"),Oe=n("a"),ia=s("Demo notebook"),ma=s(" for fine-tuning the model on custom data."),Cn=d(),X=n("h2"),fe=n("a"),Ut=n("span"),g(Qe.$$.fragment),da=d(),jt=n("span"),la=s("SamConfig"),Pn=d(),E=n("div"),g(Ke.$$.fragment),ca=d(),R=n("p"),Ko=n("a"),pa=s("SamConfig"),ha=s(" is the configuration class to store the configuration of a "),et=n("a"),fa=s("SamModel"),ga=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 `),eo=n("a"),ua=s("facebook/sam-vit-huge"),_a=s(" architecture."),ba=d(),Y=n("p"),va=s("Configuration objects inherit from "),ot=n("a"),ya=s("PretrainedConfig"),wa=s(` and can be used to control the model outputs. Read the
documentation from `),tt=n("a"),Sa=s("PretrainedConfig"),Ta=s(" for more information."),Ma=d(),g(ge.$$.fragment),Nn=d(),H=n("h2"),ue=n("a"),Jt=n("span"),g(oo.$$.fragment),ka=d(),Ft=n("span"),xa=s("SamVisionConfig"),An=d(),U=n("div"),g(to.$$.fragment),Ia=d(),O=n("p"),za=s("This is the configuration class to store the configuration of a "),Wt=n("code"),$a=s("SamVisionModel"),Ea=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
`),no=n("a"),Ca=s("facebook/sam-vit-huge"),Pa=s(" architecture."),Na=d(),Q=n("p"),Aa=s("Configuration objects inherit from "),nt=n("a"),Da=s("PretrainedConfig"),Ua=s(` and can be used to control the model outputs. Read the
documentation from `),rt=n("a"),ja=s("PretrainedConfig"),Ja=s(" for more information."),Dn=d(),K=n("h2"),_e=n("a"),Rt=n("span"),g(ro.$$.fragment),Fa=d(),Vt=n("span"),Wa=s("SamMaskDecoderConfig"),Un=d(),j=n("div"),g(ao.$$.fragment),Ra=d(),ee=n("p"),Va=s("This is the configuration class to store the configuration of a "),Zt=n("code"),Za=s("SamMaskDecoder"),Ba=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
`),so=n("a"),La=s("facebook/sam-vit-huge"),qa=s(" architecture."),Ga=d(),oe=n("p"),Xa=s("Configuration objects inherit from "),at=n("a"),Ya=s("PretrainedConfig"),Ha=s(` and can be used to control the model outputs. Read the
documentation from `),st=n("a"),Oa=s("PretrainedConfig"),Qa=s(" for more information."),jn=d(),te=n("h2"),be=n("a"),Bt=n("span"),g(io.$$.fragment),Ka=d(),Lt=n("span"),es=s("SamPromptEncoderConfig"),Jn=d(),J=n("div"),g(mo.$$.fragment),os=d(),F=n("p"),ts=s("This is the configuration class to store the configuration of a "),qt=n("code"),ns=s("SamPromptEncoder"),rs=s(". The "),Gt=n("code"),as=s("SamPromptEncoder"),ss=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
`),lo=n("a"),is=s("facebook/sam-vit-huge"),ms=s(" architecture."),ds=d(),ne=n("p"),ls=s("Configuration objects inherit from "),it=n("a"),cs=s("PretrainedConfig"),ps=s(` and can be used to control the model outputs. Read the
documentation from `),mt=n("a"),hs=s("PretrainedConfig"),fs=s(" for more information."),Fn=d(),re=n("h2"),ve=n("a"),Xt=n("span"),g(co.$$.fragment),gs=d(),Yt=n("span"),us=s("SamProcessor"),Wn=d(),W=n("div"),g(po.$$.fragment),_s=d(),Ht=n("p"),bs=s(`Constructs a SAM processor which wraps a SAM image processor and an 2D points & Bounding boxes processor into a
single processor.`),vs=d(),V=n("p"),dt=n("a"),ys=s("SamProcessor"),ws=s(" offers all the functionalities of "),lt=n("a"),Ss=s("SamImageProcessor"),Ts=s(`. See the docstring of
`),ho=n("a"),Ot=n("strong"),Ms=s("call"),ks=s("()"),xs=s(" for more information."),Rn=d(),ae=n("h2"),ye=n("a"),Qt=n("span"),g(fo.$$.fragment),Is=d(),Kt=n("span"),zs=s("SamImageProcessor"),Vn=d(),M=n("div"),g(go.$$.fragment),$s=d(),en=n("p"),Es=s("Constructs a SAM image processor."),Cs=d(),we=n("div"),g(uo.$$.fragment),Ps=d(),se=n("p"),Ns=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 `),on=n("code"),As=s("pred_iou_thresh"),Ds=s(`. The second criterion is that the stability
score needs to be greater than `),tn=n("code"),Us=s("stability_score_thresh"),js=s(`. The method also converts the predicted masks to
bounding boxes and pad the predicted masks if necessary.`),Js=d(),Se=n("div"),g(_o.$$.fragment),Fs=d(),bo=n("p"),Ws=s("Generates a list of crop boxes of different sizes. Each layer has (2"),nn=n("strong"),Rs=s("i)"),Vs=s("2 boxes for the ith layer."),Zs=d(),Te=n("div"),g(vo.$$.fragment),Bs=d(),yo=n("p"),Ls=s("Pad an image to "),rn=n("code"),qs=s('(pad_size["height"], pad_size["width"])'),Gs=s(" with zeros to the right and bottom."),Xs=d(),Me=n("div"),g(wo.$$.fragment),Ys=d(),an=n("p"),Hs=s("Post processes mask that are generated by calling the Non Maximum Suppression algorithm on the predicted masks."),Os=d(),ke=n("div"),g(So.$$.fragment),Qs=d(),sn=n("p"),Ks=s("Remove padding and upscale masks to the original image size."),ei=d(),xe=n("div"),g(To.$$.fragment),oi=d(),mn=n("p"),ti=s("Preprocess an image or batch of images."),ni=d(),Ie=n("div"),g(Mo.$$.fragment),ri=d(),ko=n("p"),ai=s("Resize an image to "),dn=n("code"),si=s('(size["height"], size["width"])'),ii=s("."),Zn=d(),ie=n("h2"),ze=n("a"),ln=n("span"),g(xo.$$.fragment),mi=d(),cn=n("span"),di=s("SamModel"),Bn=d(),C=n("div"),g(Io.$$.fragment),li=d(),zo=n("p"),ci=s(`Segment Anything Model (SAM) for generating segmentation masks, given an input image and  optional 2D location and bounding boxes.
This model inherits from `),ct=n("a"),pi=s("PreTrainedModel"),hi=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.)`),fi=d(),$o=n("p"),gi=s("This model is also a PyTorch "),Eo=n("a"),ui=s("torch.nn.Module"),_i=s(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),bi=d(),Z=n("div"),g(Co.$$.fragment),vi=d(),me=n("p"),yi=s("The "),pt=n("a"),wi=s("SamModel"),Si=s(" forward method, overrides the "),pn=n("code"),Ti=s("__call__"),Mi=s(" special method."),ki=d(),g($e.$$.fragment),Ln=d(),de=n("h2"),Ee=n("a"),hn=n("span"),g(Po.$$.fragment),xi=d(),fn=n("span"),Ii=s("TFSamModel"),qn=d(),P=n("div"),g(No.$$.fragment),zi=d(),Ao=n("p"),$i=s(`Segment Anything Model (SAM) for generating segmentation masks, given an input image and  optional 2D location and bounding boxes.
This model inherits from `),ht=n("a"),Ei=s("TFPreTrainedModel"),Ci=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.)`),Pi=d(),Do=n("p"),Ni=s("This model is also a TensorFlow "),Uo=n("a"),Ai=s("tf.keras.Model"),Di=s(`
subclass. Use it as a regular TensorFlow Model and refer to the TensorFlow documentation for all matter related to
general usage and behavior.`),Ui=d(),B=n("div"),g(jo.$$.fragment),ji=d(),le=n("p"),Ji=s("The "),ft=n("a"),Fi=s("TFSamModel"),Wi=s(" forward method, overrides the "),gn=n("code"),Ri=s("__call__"),Vi=s(" special method."),Zi=d(),g(Ce.$$.fragment),this.h()},l(o){const c=Dd('[data-svelte="svelte-1phssyn"]',document.head);f=r(c,"META",{name:!0,content:!0}),c.forEach(t),z=l(o),w=r(o,"H1",{class:!0});var Jo=a(w);S=r(Jo,"A",{id:!0,class:!0,href:!0});var un=a(S);k=r(un,"SPAN",{});var _n=a(k);u(h.$$.fragment,_n),_n.forEach(t),un.forEach(t),T=l(Jo),D=r(Jo,"SPAN",{});var Hi=a(D);yr=i(Hi,"SAM"),Hi.forEach(t),Jo.forEach(t),bn=l(o),G=r(o,"H2",{class:!0});var Xn=a(G);pe=r(Xn,"A",{id:!0,class:!0,href:!0});var Oi=a(pe);Et=r(Oi,"SPAN",{});var Qi=a(Et);u(Je.$$.fragment,Qi),Qi.forEach(t),Oi.forEach(t),wr=l(Xn),Ct=r(Xn,"SPAN",{});var Ki=a(Ct);Sr=i(Ki,"Overview"),Ki.forEach(t),Xn.forEach(t),vn=l(o),he=r(o,"P",{});var Yn=a(he);Tr=i(Yn,"SAM (Segment Anything Model) was proposed in "),Fe=r(Yn,"A",{href:!0,rel:!0});var em=a(Fe);Mr=i(em,"Segment Anything"),em.forEach(t),kr=i(Yn," 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."),Yn.forEach(t),yn=l(o),Ro=r(o,"P",{});var om=a(Ro);xr=i(om,"The model can be used to predict segmentation masks of any object of interest given an input image."),om.forEach(t),wn=l(o),Vo=r(o,"P",{});var tm=a(Vo);Zo=r(tm,"IMG",{src:!0,alt:!0}),tm.forEach(t),Sn=l(o),Bo=r(o,"P",{});var nm=a(Bo);Ir=i(nm,"The abstract from the paper is the following:"),nm.forEach(t),Tn=l(o),Lo=r(o,"P",{});var rm=a(Lo);We=r(rm,"EM",{});var Hn=a(We);zr=i(Hn,"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 "),Re=r(Hn,"A",{href:!0,rel:!0});var am=a(Re);$r=i(am,"https://segment-anything.com"),am.forEach(t),Er=i(Hn," to foster research into foundation models for computer vision."),Hn.forEach(t),rm.forEach(t),Mn=l(o),qo=r(o,"P",{});var sm=a(qo);Cr=i(sm,"Tips:"),sm.forEach(t),kn=l(o),$=r(o,"UL",{});var L=a($);Pt=r(L,"LI",{});var im=a(Pt);Pr=i(im,"The model predicts binary masks that states the presence or not of the object of interest given an image."),im.forEach(t),Nr=l(L),Nt=r(L,"LI",{});var mm=a(Nt);Ar=i(mm,"The model predicts much better results if input 2D points and/or input bounding boxes are provided"),mm.forEach(t),Dr=l(L),At=r(L,"LI",{});var dm=a(At);Ur=i(dm,"You can prompt multiple points for the same image, and predict a single mask."),dm.forEach(t),jr=l(L),Dt=r(L,"LI",{});var lm=a(Dt);Jr=i(lm,"Fine-tuning the model is not supported yet"),lm.forEach(t),Fr=l(L),Ve=r(L,"LI",{});var On=a(Ve);Wr=i(On,"According to the paper, textual input should be also supported. However, at this time of writing this seems to be not supported according to "),Ze=r(On,"A",{href:!0,rel:!0});var cm=a(Ze);Rr=i(cm,"the official repository"),cm.forEach(t),Vr=i(On,"."),On.forEach(t),L.forEach(t),xn=l(o),N=r(o,"P",{});var Pe=a(N);Zr=i(Pe,"This model was contributed by "),Be=r(Pe,"A",{href:!0,rel:!0});var pm=a(Be);Br=i(pm,"ybelkada"),pm.forEach(t),Lr=i(Pe," and "),Le=r(Pe,"A",{href:!0,rel:!0});var hm=a(Le);qr=i(hm,"ArthurZ"),hm.forEach(t),Gr=i(Pe,`.
The original code can be found `),qe=r(Pe,"A",{href:!0,rel:!0});var fm=a(qe);Xr=i(fm,"here"),fm.forEach(t),Yr=i(Pe,"."),Pe.forEach(t),In=l(o),Go=r(o,"P",{});var gm=a(Go);Hr=i(gm,"Below is an example on how to run mask generation given an image and a 2D point:"),gm.forEach(t),zn=l(o),u(Ge.$$.fragment,o),$n=l(o),Xo=r(o,"P",{});var um=a(Xo);Or=i(um,"Resources:"),um.forEach(t),En=l(o),A=r(o,"UL",{});var Ne=a(A);Yo=r(Ne,"LI",{});var Bi=a(Yo);Xe=r(Bi,"A",{href:!0,rel:!0});var _m=a(Xe);Qr=i(_m,"Demo notebook"),_m.forEach(t),Kr=i(Bi," for using the model."),Bi.forEach(t),ea=l(Ne),Ho=r(Ne,"LI",{});var Li=a(Ho);Ye=r(Li,"A",{href:!0,rel:!0});var bm=a(Ye);oa=i(bm,"Demo notebook"),bm.forEach(t),ta=i(Li," for using the automatic mask generation pipeline."),Li.forEach(t),na=l(Ne),Oo=r(Ne,"LI",{});var qi=a(Oo);He=r(qi,"A",{href:!0,rel:!0});var vm=a(He);ra=i(vm,"Demo notebook"),vm.forEach(t),aa=i(qi," for inference with MedSAM, a fine-tuned version of SAM on the medical domain."),qi.forEach(t),sa=l(Ne),Qo=r(Ne,"LI",{});var Gi=a(Qo);Oe=r(Gi,"A",{href:!0,rel:!0});var ym=a(Oe);ia=i(ym,"Demo notebook"),ym.forEach(t),ma=i(Gi," for fine-tuning the model on custom data."),Gi.forEach(t),Ne.forEach(t),Cn=l(o),X=r(o,"H2",{class:!0});var Qn=a(X);fe=r(Qn,"A",{id:!0,class:!0,href:!0});var wm=a(fe);Ut=r(wm,"SPAN",{});var Sm=a(Ut);u(Qe.$$.fragment,Sm),Sm.forEach(t),wm.forEach(t),da=l(Qn),jt=r(Qn,"SPAN",{});var Tm=a(jt);la=i(Tm,"SamConfig"),Tm.forEach(t),Qn.forEach(t),Pn=l(o),E=r(o,"DIV",{class:!0});var Ae=a(E);u(Ke.$$.fragment,Ae),ca=l(Ae),R=r(Ae,"P",{});var Fo=a(R);Ko=r(Fo,"A",{href:!0});var Mm=a(Ko);pa=i(Mm,"SamConfig"),Mm.forEach(t),ha=i(Fo," is the configuration class to store the configuration of a "),et=r(Fo,"A",{href:!0});var km=a(et);fa=i(km,"SamModel"),km.forEach(t),ga=i(Fo,`. 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 `),eo=r(Fo,"A",{href:!0,rel:!0});var xm=a(eo);ua=i(xm,"facebook/sam-vit-huge"),xm.forEach(t),_a=i(Fo," architecture."),Fo.forEach(t),ba=l(Ae),Y=r(Ae,"P",{});var gt=a(Y);va=i(gt,"Configuration objects inherit from "),ot=r(gt,"A",{href:!0});var Im=a(ot);ya=i(Im,"PretrainedConfig"),Im.forEach(t),wa=i(gt,` and can be used to control the model outputs. Read the
documentation from `),tt=r(gt,"A",{href:!0});var zm=a(tt);Sa=i(zm,"PretrainedConfig"),zm.forEach(t),Ta=i(gt," for more information."),gt.forEach(t),Ma=l(Ae),u(ge.$$.fragment,Ae),Ae.forEach(t),Nn=l(o),H=r(o,"H2",{class:!0});var Kn=a(H);ue=r(Kn,"A",{id:!0,class:!0,href:!0});var $m=a(ue);Jt=r($m,"SPAN",{});var Em=a(Jt);u(oo.$$.fragment,Em),Em.forEach(t),$m.forEach(t),ka=l(Kn),Ft=r(Kn,"SPAN",{});var Cm=a(Ft);xa=i(Cm,"SamVisionConfig"),Cm.forEach(t),Kn.forEach(t),An=l(o),U=r(o,"DIV",{class:!0});var ut=a(U);u(to.$$.fragment,ut),Ia=l(ut),O=r(ut,"P",{});var _t=a(O);za=i(_t,"This is the configuration class to store the configuration of a "),Wt=r(_t,"CODE",{});var Pm=a(Wt);$a=i(Pm,"SamVisionModel"),Pm.forEach(t),Ea=i(_t,`. 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
`),no=r(_t,"A",{href:!0,rel:!0});var Nm=a(no);Ca=i(Nm,"facebook/sam-vit-huge"),Nm.forEach(t),Pa=i(_t," architecture."),_t.forEach(t),Na=l(ut),Q=r(ut,"P",{});var bt=a(Q);Aa=i(bt,"Configuration objects inherit from "),nt=r(bt,"A",{href:!0});var Am=a(nt);Da=i(Am,"PretrainedConfig"),Am.forEach(t),Ua=i(bt,` and can be used to control the model outputs. Read the
documentation from `),rt=r(bt,"A",{href:!0});var Dm=a(rt);ja=i(Dm,"PretrainedConfig"),Dm.forEach(t),Ja=i(bt," for more information."),bt.forEach(t),ut.forEach(t),Dn=l(o),K=r(o,"H2",{class:!0});var er=a(K);_e=r(er,"A",{id:!0,class:!0,href:!0});var Um=a(_e);Rt=r(Um,"SPAN",{});var jm=a(Rt);u(ro.$$.fragment,jm),jm.forEach(t),Um.forEach(t),Fa=l(er),Vt=r(er,"SPAN",{});var Jm=a(Vt);Wa=i(Jm,"SamMaskDecoderConfig"),Jm.forEach(t),er.forEach(t),Un=l(o),j=r(o,"DIV",{class:!0});var vt=a(j);u(ao.$$.fragment,vt),Ra=l(vt),ee=r(vt,"P",{});var yt=a(ee);Va=i(yt,"This is the configuration class to store the configuration of a "),Zt=r(yt,"CODE",{});var Fm=a(Zt);Za=i(Fm,"SamMaskDecoder"),Fm.forEach(t),Ba=i(yt,`. 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
`),so=r(yt,"A",{href:!0,rel:!0});var Wm=a(so);La=i(Wm,"facebook/sam-vit-huge"),Wm.forEach(t),qa=i(yt," architecture."),yt.forEach(t),Ga=l(vt),oe=r(vt,"P",{});var wt=a(oe);Xa=i(wt,"Configuration objects inherit from "),at=r(wt,"A",{href:!0});var Rm=a(at);Ya=i(Rm,"PretrainedConfig"),Rm.forEach(t),Ha=i(wt,` and can be used to control the model outputs. Read the
documentation from `),st=r(wt,"A",{href:!0});var Vm=a(st);Oa=i(Vm,"PretrainedConfig"),Vm.forEach(t),Qa=i(wt," for more information."),wt.forEach(t),vt.forEach(t),jn=l(o),te=r(o,"H2",{class:!0});var or=a(te);be=r(or,"A",{id:!0,class:!0,href:!0});var Zm=a(be);Bt=r(Zm,"SPAN",{});var Bm=a(Bt);u(io.$$.fragment,Bm),Bm.forEach(t),Zm.forEach(t),Ka=l(or),Lt=r(or,"SPAN",{});var Lm=a(Lt);es=i(Lm,"SamPromptEncoderConfig"),Lm.forEach(t),or.forEach(t),Jn=l(o),J=r(o,"DIV",{class:!0});var St=a(J);u(mo.$$.fragment,St),os=l(St),F=r(St,"P",{});var De=a(F);ts=i(De,"This is the configuration class to store the configuration of a "),qt=r(De,"CODE",{});var qm=a(qt);ns=i(qm,"SamPromptEncoder"),qm.forEach(t),rs=i(De,". The "),Gt=r(De,"CODE",{});var Gm=a(Gt);as=i(Gm,"SamPromptEncoder"),Gm.forEach(t),ss=i(De,`
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
`),lo=r(De,"A",{href:!0,rel:!0});var Xm=a(lo);is=i(Xm,"facebook/sam-vit-huge"),Xm.forEach(t),ms=i(De," architecture."),De.forEach(t),ds=l(St),ne=r(St,"P",{});var Tt=a(ne);ls=i(Tt,"Configuration objects inherit from "),it=r(Tt,"A",{href:!0});var Ym=a(it);cs=i(Ym,"PretrainedConfig"),Ym.forEach(t),ps=i(Tt,` and can be used to control the model outputs. Read the
documentation from `),mt=r(Tt,"A",{href:!0});var Hm=a(mt);hs=i(Hm,"PretrainedConfig"),Hm.forEach(t),fs=i(Tt," for more information."),Tt.forEach(t),St.forEach(t),Fn=l(o),re=r(o,"H2",{class:!0});var tr=a(re);ve=r(tr,"A",{id:!0,class:!0,href:!0});var Om=a(ve);Xt=r(Om,"SPAN",{});var Qm=a(Xt);u(co.$$.fragment,Qm),Qm.forEach(t),Om.forEach(t),gs=l(tr),Yt=r(tr,"SPAN",{});var Km=a(Yt);us=i(Km,"SamProcessor"),Km.forEach(t),tr.forEach(t),Wn=l(o),W=r(o,"DIV",{class:!0});var Mt=a(W);u(po.$$.fragment,Mt),_s=l(Mt),Ht=r(Mt,"P",{});var ed=a(Ht);bs=i(ed,`Constructs a SAM processor which wraps a SAM image processor and an 2D points & Bounding boxes processor into a
single processor.`),ed.forEach(t),vs=l(Mt),V=r(Mt,"P",{});var Wo=a(V);dt=r(Wo,"A",{href:!0});var od=a(dt);ys=i(od,"SamProcessor"),od.forEach(t),ws=i(Wo," offers all the functionalities of "),lt=r(Wo,"A",{href:!0});var td=a(lt);Ss=i(td,"SamImageProcessor"),td.forEach(t),Ts=i(Wo,`. See the docstring of
`),ho=r(Wo,"A",{href:!0});var Xi=a(ho);Ot=r(Xi,"STRONG",{});var nd=a(Ot);Ms=i(nd,"call"),nd.forEach(t),ks=i(Xi,"()"),Xi.forEach(t),xs=i(Wo," for more information."),Wo.forEach(t),Mt.forEach(t),Rn=l(o),ae=r(o,"H2",{class:!0});var nr=a(ae);ye=r(nr,"A",{id:!0,class:!0,href:!0});var rd=a(ye);Qt=r(rd,"SPAN",{});var ad=a(Qt);u(fo.$$.fragment,ad),ad.forEach(t),rd.forEach(t),Is=l(nr),Kt=r(nr,"SPAN",{});var sd=a(Kt);zs=i(sd,"SamImageProcessor"),sd.forEach(t),nr.forEach(t),Vn=l(o),M=r(o,"DIV",{class:!0});var x=a(M);u(go.$$.fragment,x),$s=l(x),en=r(x,"P",{});var id=a(en);Es=i(id,"Constructs a SAM image processor."),id.forEach(t),Cs=l(x),we=r(x,"DIV",{class:!0});var rr=a(we);u(uo.$$.fragment,rr),Ps=l(rr),se=r(rr,"P",{});var kt=a(se);Ns=i(kt,`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 `),on=r(kt,"CODE",{});var md=a(on);As=i(md,"pred_iou_thresh"),md.forEach(t),Ds=i(kt,`. The second criterion is that the stability
score needs to be greater than `),tn=r(kt,"CODE",{});var dd=a(tn);Us=i(dd,"stability_score_thresh"),dd.forEach(t),js=i(kt,`. The method also converts the predicted masks to
bounding boxes and pad the predicted masks if necessary.`),kt.forEach(t),rr.forEach(t),Js=l(x),Se=r(x,"DIV",{class:!0});var ar=a(Se);u(_o.$$.fragment,ar),Fs=l(ar),bo=r(ar,"P",{});var sr=a(bo);Ws=i(sr,"Generates a list of crop boxes of different sizes. Each layer has (2"),nn=r(sr,"STRONG",{});var ld=a(nn);Rs=i(ld,"i)"),ld.forEach(t),Vs=i(sr,"2 boxes for the ith layer."),sr.forEach(t),ar.forEach(t),Zs=l(x),Te=r(x,"DIV",{class:!0});var ir=a(Te);u(vo.$$.fragment,ir),Bs=l(ir),yo=r(ir,"P",{});var mr=a(yo);Ls=i(mr,"Pad an image to "),rn=r(mr,"CODE",{});var cd=a(rn);qs=i(cd,'(pad_size["height"], pad_size["width"])'),cd.forEach(t),Gs=i(mr," with zeros to the right and bottom."),mr.forEach(t),ir.forEach(t),Xs=l(x),Me=r(x,"DIV",{class:!0});var dr=a(Me);u(wo.$$.fragment,dr),Ys=l(dr),an=r(dr,"P",{});var pd=a(an);Hs=i(pd,"Post processes mask that are generated by calling the Non Maximum Suppression algorithm on the predicted masks."),pd.forEach(t),dr.forEach(t),Os=l(x),ke=r(x,"DIV",{class:!0});var lr=a(ke);u(So.$$.fragment,lr),Qs=l(lr),sn=r(lr,"P",{});var hd=a(sn);Ks=i(hd,"Remove padding and upscale masks to the original image size."),hd.forEach(t),lr.forEach(t),ei=l(x),xe=r(x,"DIV",{class:!0});var cr=a(xe);u(To.$$.fragment,cr),oi=l(cr),mn=r(cr,"P",{});var fd=a(mn);ti=i(fd,"Preprocess an image or batch of images."),fd.forEach(t),cr.forEach(t),ni=l(x),Ie=r(x,"DIV",{class:!0});var pr=a(Ie);u(Mo.$$.fragment,pr),ri=l(pr),ko=r(pr,"P",{});var hr=a(ko);ai=i(hr,"Resize an image to "),dn=r(hr,"CODE",{});var gd=a(dn);si=i(gd,'(size["height"], size["width"])'),gd.forEach(t),ii=i(hr,"."),hr.forEach(t),pr.forEach(t),x.forEach(t),Zn=l(o),ie=r(o,"H2",{class:!0});var fr=a(ie);ze=r(fr,"A",{id:!0,class:!0,href:!0});var ud=a(ze);ln=r(ud,"SPAN",{});var _d=a(ln);u(xo.$$.fragment,_d),_d.forEach(t),ud.forEach(t),mi=l(fr),cn=r(fr,"SPAN",{});var bd=a(cn);di=i(bd,"SamModel"),bd.forEach(t),fr.forEach(t),Bn=l(o),C=r(o,"DIV",{class:!0});var Ue=a(C);u(Io.$$.fragment,Ue),li=l(Ue),zo=r(Ue,"P",{});var gr=a(zo);ci=i(gr,`Segment Anything Model (SAM) for generating segmentation masks, given an input image and  optional 2D location and bounding boxes.
This model inherits from `),ct=r(gr,"A",{href:!0});var vd=a(ct);pi=i(vd,"PreTrainedModel"),vd.forEach(t),hi=i(gr,`. 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.)`),gr.forEach(t),fi=l(Ue),$o=r(Ue,"P",{});var ur=a($o);gi=i(ur,"This model is also a PyTorch "),Eo=r(ur,"A",{href:!0,rel:!0});var yd=a(Eo);ui=i(yd,"torch.nn.Module"),yd.forEach(t),_i=i(ur,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ur.forEach(t),bi=l(Ue),Z=r(Ue,"DIV",{class:!0});var xt=a(Z);u(Co.$$.fragment,xt),vi=l(xt),me=r(xt,"P",{});var It=a(me);yi=i(It,"The "),pt=r(It,"A",{href:!0});var wd=a(pt);wi=i(wd,"SamModel"),wd.forEach(t),Si=i(It," forward method, overrides the "),pn=r(It,"CODE",{});var Sd=a(pn);Ti=i(Sd,"__call__"),Sd.forEach(t),Mi=i(It," special method."),It.forEach(t),ki=l(xt),u($e.$$.fragment,xt),xt.forEach(t),Ue.forEach(t),Ln=l(o),de=r(o,"H2",{class:!0});var _r=a(de);Ee=r(_r,"A",{id:!0,class:!0,href:!0});var Td=a(Ee);hn=r(Td,"SPAN",{});var Md=a(hn);u(Po.$$.fragment,Md),Md.forEach(t),Td.forEach(t),xi=l(_r),fn=r(_r,"SPAN",{});var kd=a(fn);Ii=i(kd,"TFSamModel"),kd.forEach(t),_r.forEach(t),qn=l(o),P=r(o,"DIV",{class:!0});var je=a(P);u(No.$$.fragment,je),zi=l(je),Ao=r(je,"P",{});var br=a(Ao);$i=i(br,`Segment Anything Model (SAM) for generating segmentation masks, given an input image and  optional 2D location and bounding boxes.
This model inherits from `),ht=r(br,"A",{href:!0});var xd=a(ht);Ei=i(xd,"TFPreTrainedModel"),xd.forEach(t),Ci=i(br,`. 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.)`),br.forEach(t),Pi=l(je),Do=r(je,"P",{});var vr=a(Do);Ni=i(vr,"This model is also a TensorFlow "),Uo=r(vr,"A",{href:!0,rel:!0});var Id=a(Uo);Ai=i(Id,"tf.keras.Model"),Id.forEach(t),Di=i(vr,`
subclass. Use it as a regular TensorFlow Model and refer to the TensorFlow documentation for all matter related to
general usage and behavior.`),vr.forEach(t),Ui=l(je),B=r(je,"DIV",{class:!0});var zt=a(B);u(jo.$$.fragment,zt),ji=l(zt),le=r(zt,"P",{});var $t=a(le);Ji=i($t,"The "),ft=r($t,"A",{href:!0});var zd=a(ft);Fi=i(zd,"TFSamModel"),zd.forEach(t),Wi=i($t," forward method, overrides the "),gn=r($t,"CODE",{});var $d=a(gn);Ri=i($d,"__call__"),$d.forEach(t),Vi=i($t," special method."),$t.forEach(t),Zi=l(zt),u(Ce.$$.fragment,zt),zt.forEach(t),je.forEach(t),this.h()},h(){m(f,"name","hf:doc:metadata"),m(f,"content",JSON.stringify(Bd)),m(S,"id","sam"),m(S,"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(S,"href","#sam"),m(w,"class","relative group"),m(pe,"id","overview"),m(pe,"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(pe,"href","#overview"),m(G,"class","relative group"),m(Fe,"href","https://arxiv.org/pdf/2304.02643v1.pdf"),m(Fe,"rel","nofollow"),Ud(Zo.src,Yi="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/sam-output.png")||m(Zo,"src",Yi),m(Zo,"alt","example image"),m(Re,"href","https://segment-anything.com"),m(Re,"rel","nofollow"),m(Ze,"href","https://github.com/facebookresearch/segment-anything/issues/4#issuecomment-1497626844"),m(Ze,"rel","nofollow"),m(Be,"href","https://huggingface.co/ybelkada"),m(Be,"rel","nofollow"),m(Le,"href","https://huggingface.co/ArthurZ"),m(Le,"rel","nofollow"),m(qe,"href","https://github.com/facebookresearch/segment-anything"),m(qe,"rel","nofollow"),m(Xe,"href","https://github.com/huggingface/notebooks/blob/main/examples/segment_anything.ipynb"),m(Xe,"rel","nofollow"),m(Ye,"href","https://github.com/huggingface/notebooks/blob/main/examples/automatic_mask_generation.ipynb"),m(Ye,"rel","nofollow"),m(He,"href","https://github.com/NielsRogge/Transformers-Tutorials/blob/master/SAM/Run_inference_with_MedSAM_using_HuggingFace_Transformers.ipynb"),m(He,"rel","nofollow"),m(Oe,"href","https://github.com/NielsRogge/Transformers-Tutorials/blob/master/SAM/Fine_tune_SAM_(segment_anything)_on_a_custom_dataset.ipynb"),m(Oe,"rel","nofollow"),m(fe,"id","transformers.SamConfig"),m(fe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(fe,"href","#transformers.SamConfig"),m(X,"class","relative group"),m(Ko,"href","/docs/transformers/main/en/model_doc/sam#transformers.SamConfig"),m(et,"href","/docs/transformers/main/en/model_doc/sam#transformers.SamModel"),m(eo,"href","https://huggingface.co/facebook/sam-vit-huge"),m(eo,"rel","nofollow"),m(ot,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),m(tt,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),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(ue,"id","transformers.SamVisionConfig"),m(ue,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(ue,"href","#transformers.SamVisionConfig"),m(H,"class","relative group"),m(no,"href","https://huggingface.co/facebook/sam-vit-huge"),m(no,"rel","nofollow"),m(nt,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),m(rt,"href","/docs/transformers/main/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(_e,"id","transformers.SamMaskDecoderConfig"),m(_e,"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(_e,"href","#transformers.SamMaskDecoderConfig"),m(K,"class","relative group"),m(so,"href","https://huggingface.co/facebook/sam-vit-huge"),m(so,"rel","nofollow"),m(at,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),m(st,"href","/docs/transformers/main/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(be,"id","transformers.SamPromptEncoderConfig"),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.SamPromptEncoderConfig"),m(te,"class","relative group"),m(lo,"href","https://huggingface.co/facebook/sam-vit-huge"),m(lo,"rel","nofollow"),m(it,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),m(mt,"href","/docs/transformers/main/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.SamProcessor"),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.SamProcessor"),m(re,"class","relative group"),m(dt,"href","/docs/transformers/main/en/model_doc/sam#transformers.SamProcessor"),m(lt,"href","/docs/transformers/main/en/model_doc/sam#transformers.SamImageProcessor"),m(ho,"href","/docs/transformers/main/en/model_doc/mobilevit#transformers.MobileViTFeatureExtractor.__call__"),m(W,"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.SamImageProcessor"),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.SamImageProcessor"),m(ae,"class","relative group"),m(we,"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,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),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(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(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ze,"id","transformers.SamModel"),m(ze,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(ze,"href","#transformers.SamModel"),m(ie,"class","relative group"),m(ct,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),m(Eo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(Eo,"rel","nofollow"),m(pt,"href","/docs/transformers/main/en/model_doc/sam#transformers.SamModel"),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(Ee,"id","transformers.TFSamModel"),m(Ee,"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(Ee,"href","#transformers.TFSamModel"),m(de,"class","relative group"),m(ht,"href","/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel"),m(Uo,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),m(Uo,"rel","nofollow"),m(ft,"href","/docs/transformers/main/en/model_doc/sam#transformers.TFSamModel"),m(B,"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(o,c){e(document.head,f),p(o,z,c),p(o,w,c),e(w,S),e(S,k),_(h,k,null),e(w,T),e(w,D),e(D,yr),p(o,bn,c),p(o,G,c),e(G,pe),e(pe,Et),_(Je,Et,null),e(G,wr),e(G,Ct),e(Ct,Sr),p(o,vn,c),p(o,he,c),e(he,Tr),e(he,Fe),e(Fe,Mr),e(he,kr),p(o,yn,c),p(o,Ro,c),e(Ro,xr),p(o,wn,c),p(o,Vo,c),e(Vo,Zo),p(o,Sn,c),p(o,Bo,c),e(Bo,Ir),p(o,Tn,c),p(o,Lo,c),e(Lo,We),e(We,zr),e(We,Re),e(Re,$r),e(We,Er),p(o,Mn,c),p(o,qo,c),e(qo,Cr),p(o,kn,c),p(o,$,c),e($,Pt),e(Pt,Pr),e($,Nr),e($,Nt),e(Nt,Ar),e($,Dr),e($,At),e(At,Ur),e($,jr),e($,Dt),e(Dt,Jr),e($,Fr),e($,Ve),e(Ve,Wr),e(Ve,Ze),e(Ze,Rr),e(Ve,Vr),p(o,xn,c),p(o,N,c),e(N,Zr),e(N,Be),e(Be,Br),e(N,Lr),e(N,Le),e(Le,qr),e(N,Gr),e(N,qe),e(qe,Xr),e(N,Yr),p(o,In,c),p(o,Go,c),e(Go,Hr),p(o,zn,c),_(Ge,o,c),p(o,$n,c),p(o,Xo,c),e(Xo,Or),p(o,En,c),p(o,A,c),e(A,Yo),e(Yo,Xe),e(Xe,Qr),e(Yo,Kr),e(A,ea),e(A,Ho),e(Ho,Ye),e(Ye,oa),e(Ho,ta),e(A,na),e(A,Oo),e(Oo,He),e(He,ra),e(Oo,aa),e(A,sa),e(A,Qo),e(Qo,Oe),e(Oe,ia),e(Qo,ma),p(o,Cn,c),p(o,X,c),e(X,fe),e(fe,Ut),_(Qe,Ut,null),e(X,da),e(X,jt),e(jt,la),p(o,Pn,c),p(o,E,c),_(Ke,E,null),e(E,ca),e(E,R),e(R,Ko),e(Ko,pa),e(R,ha),e(R,et),e(et,fa),e(R,ga),e(R,eo),e(eo,ua),e(R,_a),e(E,ba),e(E,Y),e(Y,va),e(Y,ot),e(ot,ya),e(Y,wa),e(Y,tt),e(tt,Sa),e(Y,Ta),e(E,Ma),_(ge,E,null),p(o,Nn,c),p(o,H,c),e(H,ue),e(ue,Jt),_(oo,Jt,null),e(H,ka),e(H,Ft),e(Ft,xa),p(o,An,c),p(o,U,c),_(to,U,null),e(U,Ia),e(U,O),e(O,za),e(O,Wt),e(Wt,$a),e(O,Ea),e(O,no),e(no,Ca),e(O,Pa),e(U,Na),e(U,Q),e(Q,Aa),e(Q,nt),e(nt,Da),e(Q,Ua),e(Q,rt),e(rt,ja),e(Q,Ja),p(o,Dn,c),p(o,K,c),e(K,_e),e(_e,Rt),_(ro,Rt,null),e(K,Fa),e(K,Vt),e(Vt,Wa),p(o,Un,c),p(o,j,c),_(ao,j,null),e(j,Ra),e(j,ee),e(ee,Va),e(ee,Zt),e(Zt,Za),e(ee,Ba),e(ee,so),e(so,La),e(ee,qa),e(j,Ga),e(j,oe),e(oe,Xa),e(oe,at),e(at,Ya),e(oe,Ha),e(oe,st),e(st,Oa),e(oe,Qa),p(o,jn,c),p(o,te,c),e(te,be),e(be,Bt),_(io,Bt,null),e(te,Ka),e(te,Lt),e(Lt,es),p(o,Jn,c),p(o,J,c),_(mo,J,null),e(J,os),e(J,F),e(F,ts),e(F,qt),e(qt,ns),e(F,rs),e(F,Gt),e(Gt,as),e(F,ss),e(F,lo),e(lo,is),e(F,ms),e(J,ds),e(J,ne),e(ne,ls),e(ne,it),e(it,cs),e(ne,ps),e(ne,mt),e(mt,hs),e(ne,fs),p(o,Fn,c),p(o,re,c),e(re,ve),e(ve,Xt),_(co,Xt,null),e(re,gs),e(re,Yt),e(Yt,us),p(o,Wn,c),p(o,W,c),_(po,W,null),e(W,_s),e(W,Ht),e(Ht,bs),e(W,vs),e(W,V),e(V,dt),e(dt,ys),e(V,ws),e(V,lt),e(lt,Ss),e(V,Ts),e(V,ho),e(ho,Ot),e(Ot,Ms),e(ho,ks),e(V,xs),p(o,Rn,c),p(o,ae,c),e(ae,ye),e(ye,Qt),_(fo,Qt,null),e(ae,Is),e(ae,Kt),e(Kt,zs),p(o,Vn,c),p(o,M,c),_(go,M,null),e(M,$s),e(M,en),e(en,Es),e(M,Cs),e(M,we),_(uo,we,null),e(we,Ps),e(we,se),e(se,Ns),e(se,on),e(on,As),e(se,Ds),e(se,tn),e(tn,Us),e(se,js),e(M,Js),e(M,Se),_(_o,Se,null),e(Se,Fs),e(Se,bo),e(bo,Ws),e(bo,nn),e(nn,Rs),e(bo,Vs),e(M,Zs),e(M,Te),_(vo,Te,null),e(Te,Bs),e(Te,yo),e(yo,Ls),e(yo,rn),e(rn,qs),e(yo,Gs),e(M,Xs),e(M,Me),_(wo,Me,null),e(Me,Ys),e(Me,an),e(an,Hs),e(M,Os),e(M,ke),_(So,ke,null),e(ke,Qs),e(ke,sn),e(sn,Ks),e(M,ei),e(M,xe),_(To,xe,null),e(xe,oi),e(xe,mn),e(mn,ti),e(M,ni),e(M,Ie),_(Mo,Ie,null),e(Ie,ri),e(Ie,ko),e(ko,ai),e(ko,dn),e(dn,si),e(ko,ii),p(o,Zn,c),p(o,ie,c),e(ie,ze),e(ze,ln),_(xo,ln,null),e(ie,mi),e(ie,cn),e(cn,di),p(o,Bn,c),p(o,C,c),_(Io,C,null),e(C,li),e(C,zo),e(zo,ci),e(zo,ct),e(ct,pi),e(zo,hi),e(C,fi),e(C,$o),e($o,gi),e($o,Eo),e(Eo,ui),e($o,_i),e(C,bi),e(C,Z),_(Co,Z,null),e(Z,vi),e(Z,me),e(me,yi),e(me,pt),e(pt,wi),e(me,Si),e(me,pn),e(pn,Ti),e(me,Mi),e(Z,ki),_($e,Z,null),p(o,Ln,c),p(o,de,c),e(de,Ee),e(Ee,hn),_(Po,hn,null),e(de,xi),e(de,fn),e(fn,Ii),p(o,qn,c),p(o,P,c),_(No,P,null),e(P,zi),e(P,Ao),e(Ao,$i),e(Ao,ht),e(ht,Ei),e(Ao,Ci),e(P,Pi),e(P,Do),e(Do,Ni),e(Do,Uo),e(Uo,Ai),e(Do,Di),e(P,Ui),e(P,B),_(jo,B,null),e(B,ji),e(B,le),e(le,Ji),e(le,ft),e(ft,Fi),e(le,Wi),e(le,gn),e(gn,Ri),e(le,Vi),e(B,Zi),_(Ce,B,null),Gn=!0},p(o,[c]){const Jo={};c&2&&(Jo.$$scope={dirty:c,ctx:o}),ge.$set(Jo);const un={};c&2&&(un.$$scope={dirty:c,ctx:o}),$e.$set(un);const _n={};c&2&&(_n.$$scope={dirty:c,ctx:o}),Ce.$set(_n)},i(o){Gn||(b(h.$$.fragment,o),b(Je.$$.fragment,o),b(Ge.$$.fragment,o),b(Qe.$$.fragment,o),b(Ke.$$.fragment,o),b(ge.$$.fragment,o),b(oo.$$.fragment,o),b(to.$$.fragment,o),b(ro.$$.fragment,o),b(ao.$$.fragment,o),b(io.$$.fragment,o),b(mo.$$.fragment,o),b(co.$$.fragment,o),b(po.$$.fragment,o),b(fo.$$.fragment,o),b(go.$$.fragment,o),b(uo.$$.fragment,o),b(_o.$$.fragment,o),b(vo.$$.fragment,o),b(wo.$$.fragment,o),b(So.$$.fragment,o),b(To.$$.fragment,o),b(Mo.$$.fragment,o),b(xo.$$.fragment,o),b(Io.$$.fragment,o),b(Co.$$.fragment,o),b($e.$$.fragment,o),b(Po.$$.fragment,o),b(No.$$.fragment,o),b(jo.$$.fragment,o),b(Ce.$$.fragment,o),Gn=!0)},o(o){v(h.$$.fragment,o),v(Je.$$.fragment,o),v(Ge.$$.fragment,o),v(Qe.$$.fragment,o),v(Ke.$$.fragment,o),v(ge.$$.fragment,o),v(oo.$$.fragment,o),v(to.$$.fragment,o),v(ro.$$.fragment,o),v(ao.$$.fragment,o),v(io.$$.fragment,o),v(mo.$$.fragment,o),v(co.$$.fragment,o),v(po.$$.fragment,o),v(fo.$$.fragment,o),v(go.$$.fragment,o),v(uo.$$.fragment,o),v(_o.$$.fragment,o),v(vo.$$.fragment,o),v(wo.$$.fragment,o),v(So.$$.fragment,o),v(To.$$.fragment,o),v(Mo.$$.fragment,o),v(xo.$$.fragment,o),v(Io.$$.fragment,o),v(Co.$$.fragment,o),v($e.$$.fragment,o),v(Po.$$.fragment,o),v(No.$$.fragment,o),v(jo.$$.fragment,o),v(Ce.$$.fragment,o),Gn=!1},d(o){t(f),o&&t(z),o&&t(w),y(h),o&&t(bn),o&&t(G),y(Je),o&&t(vn),o&&t(he),o&&t(yn),o&&t(Ro),o&&t(wn),o&&t(Vo),o&&t(Sn),o&&t(Bo),o&&t(Tn),o&&t(Lo),o&&t(Mn),o&&t(qo),o&&t(kn),o&&t($),o&&t(xn),o&&t(N),o&&t(In),o&&t(Go),o&&t(zn),y(Ge,o),o&&t($n),o&&t(Xo),o&&t(En),o&&t(A),o&&t(Cn),o&&t(X),y(Qe),o&&t(Pn),o&&t(E),y(Ke),y(ge),o&&t(Nn),o&&t(H),y(oo),o&&t(An),o&&t(U),y(to),o&&t(Dn),o&&t(K),y(ro),o&&t(Un),o&&t(j),y(ao),o&&t(jn),o&&t(te),y(io),o&&t(Jn),o&&t(J),y(mo),o&&t(Fn),o&&t(re),y(co),o&&t(Wn),o&&t(W),y(po),o&&t(Rn),o&&t(ae),y(fo),o&&t(Vn),o&&t(M),y(go),y(uo),y(_o),y(vo),y(wo),y(So),y(To),y(Mo),o&&t(Zn),o&&t(ie),y(xo),o&&t(Bn),o&&t(C),y(Io),y(Co),y($e),o&&t(Ln),o&&t(de),y(Po),o&&t(qn),o&&t(P),y(No),y(jo),y(Ce)}}}const Bd={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 Ld(ce){return jd(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Qd extends Pd{constructor(f){super();Nd(this,f,Ld,Zd,Ad,{})}}export{Qd as default,Bd as metadata};
