import{S as Pm,i as Nm,s as Am,e as n,k as m,w as g,t as s,M as Dm,c as r,d as t,m as l,a,x as u,h as i,b as d,N as Um,G as e,g as p,y as _,q as b,o as v,B as y,v as jm,L as Jm}from"../../chunks/vendor-hf-doc-builder.js";import{T as Em}from"../../chunks/Tip-hf-doc-builder.js";import{D as I}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Cm}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as q}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Fm}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Wm(ce){let f,z,w,S,k;return S=new Cm({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=m(),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:Jm,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 Rm(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 Vm(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 Zm(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,da,Cn,X,fe,Ut,Qe,ma,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,ds,ms,ne,ls,it,cs,ps,dt,hs,fs,Fn,re,ve,Xt,co,gs,Yt,us,Wn,W,po,_s,Ht,bs,vs,V,mt,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,dn,ti,ni,Ie,Mo,ri,ko,ai,mn,si,ii,Zn,ie,ze,ln,xo,di,cn,mi,Bn,C,Io,li,zo,ci,ct,pi,hi,fi,$o,gi,Eo,ui,_i,bi,Z,Co,vi,de,yi,pt,wi,Si,pn,Ti,Mi,ki,$e,Ln,me,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 Cm({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/v4.33.0/en/model_doc/sam#transformers.SamVisionConfig">SamVisionConfig</a>.`,name:"vision_config"},{anchor:"transformers.SamConfig.prompt_encoder_config",description:`<strong>prompt_encoder_config</strong> (Union[<code>dict</code>, <code>SamPromptEncoderConfig</code>], <em>optional</em>) &#x2014;
Dictionary of configuration options used to initialize <a href="/docs/transformers/v4.33.0/en/model_doc/sam#transformers.SamPromptEncoderConfig">SamPromptEncoderConfig</a>.`,name:"prompt_encoder_config"},{anchor:"transformers.SamConfig.mask_decoder_config",description:`<strong>mask_decoder_config</strong> (Union[<code>dict</code>, <code>SamMaskDecoderConfig</code>], <em>optional</em>) &#x2014;
Dictionary of configuration options used to initialize <a href="/docs/transformers/v4.33.0/en/model_doc/sam#transformers.SamMaskDecoderConfig">SamMaskDecoderConfig</a>.`,name:"mask_decoder_config"},{anchor:"transformers.SamConfig.kwargs",description:`<strong>kwargs</strong> (<em>optional</em>) &#x2014;
Dictionary of keyword arguments.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/sam/configuration_sam.py#L237"}}),ge=new Fm({props:{anchor:"transformers.SamConfig.example",$$slots:{default:[Wm]},$$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/v4.33.0/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/v4.33.0/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/v4.33.0/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/v4.33.0/en/model_doc/sam#transformers.SamImageProcessor">SamImageProcessor</a>. The image processor is a required input.`,name:"image_processor"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/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/v4.33.0/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/v4.33.0/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/v4.33.0/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/v4.33.0/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/v4.33.0/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/v4.33.0/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/v4.33.0/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/v4.33.0/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/v4.33.0/en/model_doc/sam#transformers.SamConfig">SamConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/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/v4.33.0/en/model_doc/sam#transformers.SamProcessor">SamProcessor</a>. See <code>SamProcessor.__call__()</code> for
details.`,name:"pixel_values"},{anchor:"transformers.SamModel.forward.input_points",description:`<strong>input_points</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_points, 2)</code>) &#x2014;
Input 2D spatial points, this is used by the prompt encoder to encode the prompt. Generally yields to much
better results. The points can be obtained by passing a list of list of list to the processor that will
create corresponding <code>torch</code> tensors of dimension 4. The first dimension is the image batch size, the
second dimension is the point batch size (i.e. how many segmentation masks do we want the model to predict
per input point), the third dimension is the number of points per segmentation mask (it is possible to pass
multiple points for a single mask), and the last dimension is the x (vertical) and y (horizontal)
coordinates of the point. If a different number of points is passed either for each image, or for each
mask, the processor will create &#x201C;PAD&#x201D; points that will correspond to the (0, 0) coordinate, and the
computation of the embedding will be skipped for these points using the labels.`,name:"input_points"},{anchor:"transformers.SamModel.forward.input_labels",description:`<strong>input_labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, point_batch_size, num_points)</code>) &#x2014;
Input labels for the points, this is used by the prompt encoder to encode the prompt. According to the
official implementation, there are 3 types of labels</p>
<ul>
<li><code>1</code>: the point is a point that contains the object of interest</li>
<li><code>0</code>: the point is a point that does not contain the object of interest</li>
<li><code>-1</code>: the point corresponds to the background</li>
</ul>
<p>We added the label:</p>
<ul>
<li><code>-10</code>: the point is a padding point, thus should be ignored by the prompt encoder</li>
</ul>
<p>The padding labels should be automatically done by the processor.`,name:"input_labels"},{anchor:"transformers.SamModel.forward.input_boxes",description:`<strong>input_boxes</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_boxes, 4)</code>) &#x2014;
Input boxes for the points, this is used by the prompt encoder to encode the prompt. Generally yields to
much better generated masks. The boxes can be obtained by passing a list of list of list to the processor,
that will generate a <code>torch</code> tensor, with each dimension corresponding respectively to the image batch
size, the number of boxes per image and the coordinates of the top left and botton right point of the box.
In the order (<code>x1</code>, <code>y1</code>, <code>x2</code>, <code>y2</code>):</p>
<ul>
<li><code>x1</code>: the x coordinate of the top left point of the input box</li>
<li><code>y1</code>: the y coordinate of the top left point of the input box</li>
<li><code>x2</code>: the x coordinate of the bottom right point of the input box</li>
<li><code>y2</code>: the y coordinate of the bottom right point of the input box</li>
</ul>`,name:"input_boxes"},{anchor:"transformers.SamModel.forward.input_masks",description:`<strong>input_masks</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, image_size, image_size)</code>) &#x2014;
SAM model also accepts segmentation masks as input. The mask will be embedded by the prompt encoder to
generate a corresponding embedding, that will be fed later on to the mask decoder. These masks needs to be
manually fed by the user, and they need to be of shape (<code>batch_size</code>, <code>image_size</code>, <code>image_size</code>).`,name:"input_masks"},{anchor:"transformers.SamModel.forward.image_embeddings",description:`<strong>image_embeddings</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, output_channels, window_size, window_size)</code>) &#x2014;
Image embeddings, this is used by the mask decder to generate masks and iou scores. For more memory
efficient computation, users can first retrieve the image embeddings using the <code>get_image_embeddings</code>
method, and then feed them to the <code>forward</code> method instead of feeding the <code>pixel_values</code>.`,name:"image_embeddings"},{anchor:"transformers.SamModel.forward.multimask_output",description:`<strong>multimask_output</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
In the original implementation and paper, the model always outputs 3 masks per image (or per point / per
bounding box if relevant). However, it is possible to just output a single mask, that corresponds to the
&#x201C;best&#x201D; mask, by specifying <code>multimask_output=False</code>.`,name:"multimask_output"},{anchor:"transformers.SamModel.forward.attention_similarity",description:`<strong>attention_similarity</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Attention similarity tensor, to be provided to the mask decoder for target-guided attention in case the
model is used for personalization as introduced in <a href="https://arxiv.org/abs/2305.03048" rel="nofollow">PerSAM</a>.`,name:"attention_similarity"},{anchor:"transformers.SamModel.forward.target_embedding",description:`<strong>target_embedding</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Embedding of the target concept, to be provided to the mask decoder for target-semantic prompting in case
the model is used for personalization as introduced in <a href="https://arxiv.org/abs/2305.03048" rel="nofollow">PerSAM</a>.`,name:"target_embedding"},{anchor:"transformers.SamModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.SamModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.SamModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.33.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.</p>
<p>Example &#x2014;`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/sam/modeling_sam.py#L1285"}}),$e=new Em({props:{$$slots:{default:[Rm]},$$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/v4.33.0/en/model_doc/sam#transformers.SamConfig">SamConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/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/v4.33.0/en/model_doc/sam#transformers.SamProcessor">SamProcessor</a>. See <code>SamProcessor.__call__()</code> for
details.`,name:"pixel_values"},{anchor:"transformers.TFSamModel.call.input_points",description:`<strong>input_points</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, num_points, 2)</code>) &#x2014;
Input 2D spatial points, this is used by the prompt encoder to encode the prompt. Generally yields to much
better results. The points can be obtained by passing a list of list of list to the processor that will
create corresponding <code>tf</code> tensors of dimension 4. The first dimension is the image batch size, the second
dimension is the point batch size (i.e. how many segmentation masks do we want the model to predict per
input point), the third dimension is the number of points per segmentation mask (it is possible to pass
multiple points for a single mask), and the last dimension is the x (vertical) and y (horizontal)
coordinates of the point. If a different number of points is passed either for each image, or for each
mask, the processor will create &#x201C;PAD&#x201D; points that will correspond to the (0, 0) coordinate, and the
computation of the embedding will be skipped for these points using the labels.`,name:"input_points"},{anchor:"transformers.TFSamModel.call.input_labels",description:`<strong>input_labels</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, point_batch_size, num_points)</code>) &#x2014;
Input labels for the points, this is used by the prompt encoder to encode the prompt. According to the
official implementation, there are 3 types of labels</p>
<ul>
<li><code>1</code>: the point is a point that contains the object of interest</li>
<li><code>0</code>: the point is a point that does not contain the object of interest</li>
<li><code>-1</code>: the point corresponds to the background</li>
</ul>
<p>We added the label:</p>
<ul>
<li><code>-10</code>: the point is a padding point, thus should be ignored by the prompt encoder</li>
</ul>
<p>The padding labels should be automatically done by the processor.`,name:"input_labels"},{anchor:"transformers.TFSamModel.call.input_boxes",description:`<strong>input_boxes</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, num_boxes, 4)</code>) &#x2014;
Input boxes for the points, this is used by the prompt encoder to encode the prompt. Generally yields to
much better generated masks. The boxes can be obtained by passing a list of list of list to the processor,
that will generate a <code>tf</code> tensor, with each dimension corresponding respectively to the image batch size,
the number of boxes per image and the coordinates of the top left and botton right point of the box. In the
order (<code>x1</code>, <code>y1</code>, <code>x2</code>, <code>y2</code>):</p>
<ul>
<li><code>x1</code>: the x coordinate of the top left point of the input box</li>
<li><code>y1</code>: the y coordinate of the top left point of the input box</li>
<li><code>x2</code>: the x coordinate of the bottom right point of the input box</li>
<li><code>y2</code>: the y coordinate of the bottom right point of the input box</li>
</ul>`,name:"input_boxes"},{anchor:"transformers.TFSamModel.call.input_masks",description:`<strong>input_masks</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, image_size, image_size)</code>) &#x2014;
SAM model also accepts segmentation masks as input. The mask will be embedded by the prompt encoder to
generate a corresponding embedding, that will be fed later on to the mask decoder. These masks needs to be
manually fed by the user, and they need to be of shape (<code>batch_size</code>, <code>image_size</code>, <code>image_size</code>).`,name:"input_masks"},{anchor:"transformers.TFSamModel.call.image_embeddings",description:`<strong>image_embeddings</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, output_channels, window_size, window_size)</code>) &#x2014;
Image embeddings, this is used by the mask decder to generate masks and iou scores. For more memory
efficient computation, users can first retrieve the image embeddings using the <code>get_image_embeddings</code>
method, and then feed them to the <code>call</code> method instead of feeding the <code>pixel_values</code>.`,name:"image_embeddings"},{anchor:"transformers.TFSamModel.call.multimask_output",description:`<strong>multimask_output</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
In the original implementation and paper, the model always outputs 3 masks per image (or per point / per
bounding box if relevant). However, it is possible to just output a single mask, that corresponds to the
&#x201C;best&#x201D; mask, by specifying <code>multimask_output=False</code>.`,name:"multimask_output"},{anchor:"transformers.TFSamModel.call.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.TFSamModel.call.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.TFSamModel.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.33.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/sam/modeling_tf_sam.py#L1327"}}),Ce=new Em({props:{$$slots:{default:[Vm]},$$scope:{ctx:ce}}}),{c(){f=n("meta"),z=m(),w=n("h1"),S=n("a"),k=n("span"),g(h.$$.fragment),T=m(),D=n("span"),yr=s("SAM"),bn=m(),G=n("h2"),pe=n("a"),Et=n("span"),g(Je.$$.fragment),wr=m(),Ct=n("span"),Sr=s("Overview"),vn=m(),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=m(),Ro=n("p"),xr=s("The model can be used to predict segmentation masks of any object of interest given an input image."),wn=m(),Vo=n("p"),Zo=n("img"),Sn=m(),Bo=n("p"),Ir=s("The abstract from the paper is the following:"),Tn=m(),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=m(),qo=n("p"),Cr=s("Tips:"),kn=m(),$=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=m(),Nt=n("li"),Ar=s("The model predicts much better results if input 2D points and/or input bounding boxes are provided"),Dr=m(),At=n("li"),Ur=s("You can prompt multiple points for the same image, and predict a single mask."),jr=m(),Dt=n("li"),Jr=s("Fine-tuning the model is not supported yet"),Fr=m(),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=m(),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=m(),Go=n("p"),Hr=s("Below is an example on how to run mask generation given an image and a 2D point:"),zn=m(),g(Ge.$$.fragment),$n=m(),Xo=n("p"),Or=s("Resources:"),En=m(),A=n("ul"),Yo=n("li"),Xe=n("a"),Qr=s("Demo notebook"),Kr=s(" for using the model."),ea=m(),Ho=n("li"),Ye=n("a"),oa=s("Demo notebook"),ta=s(" for using the automatic mask generation pipeline."),na=m(),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=m(),Qo=n("li"),Oe=n("a"),ia=s("Demo notebook"),da=s(" for fine-tuning the model on custom data."),Cn=m(),X=n("h2"),fe=n("a"),Ut=n("span"),g(Qe.$$.fragment),ma=m(),jt=n("span"),la=s("SamConfig"),Pn=m(),E=n("div"),g(Ke.$$.fragment),ca=m(),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=m(),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=m(),g(ge.$$.fragment),Nn=m(),H=n("h2"),ue=n("a"),Jt=n("span"),g(oo.$$.fragment),ka=m(),Ft=n("span"),xa=s("SamVisionConfig"),An=m(),U=n("div"),g(to.$$.fragment),Ia=m(),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=m(),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=m(),K=n("h2"),_e=n("a"),Rt=n("span"),g(ro.$$.fragment),Fa=m(),Vt=n("span"),Wa=s("SamMaskDecoderConfig"),Un=m(),j=n("div"),g(ao.$$.fragment),Ra=m(),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=m(),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=m(),te=n("h2"),be=n("a"),Bt=n("span"),g(io.$$.fragment),Ka=m(),Lt=n("span"),es=s("SamPromptEncoderConfig"),Jn=m(),J=n("div"),g(mo.$$.fragment),os=m(),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"),ds=s(" architecture."),ms=m(),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 `),dt=n("a"),hs=s("PretrainedConfig"),fs=s(" for more information."),Fn=m(),re=n("h2"),ve=n("a"),Xt=n("span"),g(co.$$.fragment),gs=m(),Yt=n("span"),us=s("SamProcessor"),Wn=m(),W=n("div"),g(po.$$.fragment),_s=m(),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=m(),V=n("p"),mt=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=m(),ae=n("h2"),ye=n("a"),Qt=n("span"),g(fo.$$.fragment),Is=m(),Kt=n("span"),zs=s("SamImageProcessor"),Vn=m(),M=n("div"),g(go.$$.fragment),$s=m(),en=n("p"),Es=s("Constructs a SAM image processor."),Cs=m(),we=n("div"),g(uo.$$.fragment),Ps=m(),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=m(),Se=n("div"),g(_o.$$.fragment),Fs=m(),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=m(),Te=n("div"),g(vo.$$.fragment),Bs=m(),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=m(),Me=n("div"),g(wo.$$.fragment),Ys=m(),an=n("p"),Hs=s("Post processes mask that are generated by calling the Non Maximum Suppression algorithm on the predicted masks."),Os=m(),ke=n("div"),g(So.$$.fragment),Qs=m(),sn=n("p"),Ks=s("Remove padding and upscale masks to the original image size."),ei=m(),xe=n("div"),g(To.$$.fragment),oi=m(),dn=n("p"),ti=s("Preprocess an image or batch of images."),ni=m(),Ie=n("div"),g(Mo.$$.fragment),ri=m(),ko=n("p"),ai=s("Resize an image to "),mn=n("code"),si=s('(size["height"], size["width"])'),ii=s("."),Zn=m(),ie=n("h2"),ze=n("a"),ln=n("span"),g(xo.$$.fragment),di=m(),cn=n("span"),mi=s("SamModel"),Bn=m(),C=n("div"),g(Io.$$.fragment),li=m(),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=m(),$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=m(),Z=n("div"),g(Co.$$.fragment),vi=m(),de=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=m(),g($e.$$.fragment),Ln=m(),me=n("h2"),Ee=n("a"),hn=n("span"),g(Po.$$.fragment),xi=m(),fn=n("span"),Ii=s("TFSamModel"),qn=m(),P=n("div"),g(No.$$.fragment),zi=m(),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=m(),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=m(),B=n("div"),g(jo.$$.fragment),ji=m(),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=m(),g(Ce.$$.fragment),this.h()},l(o){const c=Dm('[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 ed=a(Fe);Mr=i(ed,"Segment Anything"),ed.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 od=a(Ro);xr=i(od,"The model can be used to predict segmentation masks of any object of interest given an input image."),od.forEach(t),wn=l(o),Vo=r(o,"P",{});var td=a(Vo);Zo=r(td,"IMG",{src:!0,alt:!0}),td.forEach(t),Sn=l(o),Bo=r(o,"P",{});var nd=a(Bo);Ir=i(nd,"The abstract from the paper is the following:"),nd.forEach(t),Tn=l(o),Lo=r(o,"P",{});var rd=a(Lo);We=r(rd,"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 ad=a(Re);$r=i(ad,"https://segment-anything.com"),ad.forEach(t),Er=i(Hn," to foster research into foundation models for computer vision."),Hn.forEach(t),rd.forEach(t),Mn=l(o),qo=r(o,"P",{});var sd=a(qo);Cr=i(sd,"Tips:"),sd.forEach(t),kn=l(o),$=r(o,"UL",{});var L=a($);Pt=r(L,"LI",{});var id=a(Pt);Pr=i(id,"The model predicts binary masks that states the presence or not of the object of interest given an image."),id.forEach(t),Nr=l(L),Nt=r(L,"LI",{});var dd=a(Nt);Ar=i(dd,"The model predicts much better results if input 2D points and/or input bounding boxes are provided"),dd.forEach(t),Dr=l(L),At=r(L,"LI",{});var md=a(At);Ur=i(md,"You can prompt multiple points for the same image, and predict a single mask."),md.forEach(t),jr=l(L),Dt=r(L,"LI",{});var ld=a(Dt);Jr=i(ld,"Fine-tuning the model is not supported yet"),ld.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 cd=a(Ze);Rr=i(cd,"the official repository"),cd.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 pd=a(Be);Br=i(pd,"ybelkada"),pd.forEach(t),Lr=i(Pe," and "),Le=r(Pe,"A",{href:!0,rel:!0});var hd=a(Le);qr=i(hd,"ArthurZ"),hd.forEach(t),Gr=i(Pe,`.
The original code can be found `),qe=r(Pe,"A",{href:!0,rel:!0});var fd=a(qe);Xr=i(fd,"here"),fd.forEach(t),Yr=i(Pe,"."),Pe.forEach(t),In=l(o),Go=r(o,"P",{});var gd=a(Go);Hr=i(gd,"Below is an example on how to run mask generation given an image and a 2D point:"),gd.forEach(t),zn=l(o),u(Ge.$$.fragment,o),$n=l(o),Xo=r(o,"P",{});var ud=a(Xo);Or=i(ud,"Resources:"),ud.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 _d=a(Xe);Qr=i(_d,"Demo notebook"),_d.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 bd=a(Ye);oa=i(bd,"Demo notebook"),bd.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 vd=a(He);ra=i(vd,"Demo notebook"),vd.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 yd=a(Oe);ia=i(yd,"Demo notebook"),yd.forEach(t),da=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 wd=a(fe);Ut=r(wd,"SPAN",{});var Sd=a(Ut);u(Qe.$$.fragment,Sd),Sd.forEach(t),wd.forEach(t),ma=l(Qn),jt=r(Qn,"SPAN",{});var Td=a(jt);la=i(Td,"SamConfig"),Td.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 Md=a(Ko);pa=i(Md,"SamConfig"),Md.forEach(t),ha=i(Fo," is the configuration class to store the configuration of a "),et=r(Fo,"A",{href:!0});var kd=a(et);fa=i(kd,"SamModel"),kd.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 xd=a(eo);ua=i(xd,"facebook/sam-vit-huge"),xd.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 Id=a(ot);ya=i(Id,"PretrainedConfig"),Id.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 zd=a(tt);Sa=i(zd,"PretrainedConfig"),zd.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 $d=a(ue);Jt=r($d,"SPAN",{});var Ed=a(Jt);u(oo.$$.fragment,Ed),Ed.forEach(t),$d.forEach(t),ka=l(Kn),Ft=r(Kn,"SPAN",{});var Cd=a(Ft);xa=i(Cd,"SamVisionConfig"),Cd.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 Pd=a(Wt);$a=i(Pd,"SamVisionModel"),Pd.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 Nd=a(no);Ca=i(Nd,"facebook/sam-vit-huge"),Nd.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 Ad=a(nt);Da=i(Ad,"PretrainedConfig"),Ad.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 Dd=a(rt);ja=i(Dd,"PretrainedConfig"),Dd.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 Ud=a(_e);Rt=r(Ud,"SPAN",{});var jd=a(Rt);u(ro.$$.fragment,jd),jd.forEach(t),Ud.forEach(t),Fa=l(er),Vt=r(er,"SPAN",{});var Jd=a(Vt);Wa=i(Jd,"SamMaskDecoderConfig"),Jd.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 Fd=a(Zt);Za=i(Fd,"SamMaskDecoder"),Fd.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 Wd=a(so);La=i(Wd,"facebook/sam-vit-huge"),Wd.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 Rd=a(at);Ya=i(Rd,"PretrainedConfig"),Rd.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 Vd=a(st);Oa=i(Vd,"PretrainedConfig"),Vd.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 Zd=a(be);Bt=r(Zd,"SPAN",{});var Bd=a(Bt);u(io.$$.fragment,Bd),Bd.forEach(t),Zd.forEach(t),Ka=l(or),Lt=r(or,"SPAN",{});var Ld=a(Lt);es=i(Ld,"SamPromptEncoderConfig"),Ld.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 qd=a(qt);ns=i(qd,"SamPromptEncoder"),qd.forEach(t),rs=i(De,". The "),Gt=r(De,"CODE",{});var Gd=a(Gt);as=i(Gd,"SamPromptEncoder"),Gd.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 Xd=a(lo);is=i(Xd,"facebook/sam-vit-huge"),Xd.forEach(t),ds=i(De," architecture."),De.forEach(t),ms=l(St),ne=r(St,"P",{});var Tt=a(ne);ls=i(Tt,"Configuration objects inherit from "),it=r(Tt,"A",{href:!0});var Yd=a(it);cs=i(Yd,"PretrainedConfig"),Yd.forEach(t),ps=i(Tt,` and can be used to control the model outputs. Read the
documentation from `),dt=r(Tt,"A",{href:!0});var Hd=a(dt);hs=i(Hd,"PretrainedConfig"),Hd.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 Od=a(ve);Xt=r(Od,"SPAN",{});var Qd=a(Xt);u(co.$$.fragment,Qd),Qd.forEach(t),Od.forEach(t),gs=l(tr),Yt=r(tr,"SPAN",{});var Kd=a(Yt);us=i(Kd,"SamProcessor"),Kd.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 em=a(Ht);bs=i(em,`Constructs a SAM processor which wraps a SAM image processor and an 2D points & Bounding boxes processor into a
single processor.`),em.forEach(t),vs=l(Mt),V=r(Mt,"P",{});var Wo=a(V);mt=r(Wo,"A",{href:!0});var om=a(mt);ys=i(om,"SamProcessor"),om.forEach(t),ws=i(Wo," offers all the functionalities of "),lt=r(Wo,"A",{href:!0});var tm=a(lt);Ss=i(tm,"SamImageProcessor"),tm.forEach(t),Ts=i(Wo,`. See the docstring of
`),ho=r(Wo,"A",{href:!0});var Xi=a(ho);Ot=r(Xi,"STRONG",{});var nm=a(Ot);Ms=i(nm,"call"),nm.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 rm=a(ye);Qt=r(rm,"SPAN",{});var am=a(Qt);u(fo.$$.fragment,am),am.forEach(t),rm.forEach(t),Is=l(nr),Kt=r(nr,"SPAN",{});var sm=a(Kt);zs=i(sm,"SamImageProcessor"),sm.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 im=a(en);Es=i(im,"Constructs a SAM image processor."),im.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 dm=a(on);As=i(dm,"pred_iou_thresh"),dm.forEach(t),Ds=i(kt,`. The second criterion is that the stability
score needs to be greater than `),tn=r(kt,"CODE",{});var mm=a(tn);Us=i(mm,"stability_score_thresh"),mm.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 lm=a(nn);Rs=i(lm,"i)"),lm.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 dr=a(yo);Ls=i(dr,"Pad an image to "),rn=r(dr,"CODE",{});var cm=a(rn);qs=i(cm,'(pad_size["height"], pad_size["width"])'),cm.forEach(t),Gs=i(dr," with zeros to the right and bottom."),dr.forEach(t),ir.forEach(t),Xs=l(x),Me=r(x,"DIV",{class:!0});var mr=a(Me);u(wo.$$.fragment,mr),Ys=l(mr),an=r(mr,"P",{});var pm=a(an);Hs=i(pm,"Post processes mask that are generated by calling the Non Maximum Suppression algorithm on the predicted masks."),pm.forEach(t),mr.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 hm=a(sn);Ks=i(hm,"Remove padding and upscale masks to the original image size."),hm.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),dn=r(cr,"P",{});var fm=a(dn);ti=i(fm,"Preprocess an image or batch of images."),fm.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 "),mn=r(hr,"CODE",{});var gm=a(mn);si=i(gm,'(size["height"], size["width"])'),gm.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 um=a(ze);ln=r(um,"SPAN",{});var _m=a(ln);u(xo.$$.fragment,_m),_m.forEach(t),um.forEach(t),di=l(fr),cn=r(fr,"SPAN",{});var bm=a(cn);mi=i(bm,"SamModel"),bm.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 vm=a(ct);pi=i(vm,"PreTrainedModel"),vm.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 ym=a(Eo);ui=i(ym,"torch.nn.Module"),ym.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),de=r(xt,"P",{});var It=a(de);yi=i(It,"The "),pt=r(It,"A",{href:!0});var wm=a(pt);wi=i(wm,"SamModel"),wm.forEach(t),Si=i(It," forward method, overrides the "),pn=r(It,"CODE",{});var Sm=a(pn);Ti=i(Sm,"__call__"),Sm.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),me=r(o,"H2",{class:!0});var _r=a(me);Ee=r(_r,"A",{id:!0,class:!0,href:!0});var Tm=a(Ee);hn=r(Tm,"SPAN",{});var Mm=a(hn);u(Po.$$.fragment,Mm),Mm.forEach(t),Tm.forEach(t),xi=l(_r),fn=r(_r,"SPAN",{});var km=a(fn);Ii=i(km,"TFSamModel"),km.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 xm=a(ht);Ei=i(xm,"TFPreTrainedModel"),xm.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 Im=a(Uo);Ai=i(Im,"tf.keras.Model"),Im.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 zm=a(ft);Fi=i(zm,"TFSamModel"),zm.forEach(t),Wi=i($t," forward method, overrides the "),gn=r($t,"CODE",{});var $m=a(gn);Ri=i($m,"__call__"),$m.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(){d(f,"name","hf:doc:metadata"),d(f,"content",JSON.stringify(Bm)),d(S,"id","sam"),d(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"),d(S,"href","#sam"),d(w,"class","relative group"),d(pe,"id","overview"),d(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"),d(pe,"href","#overview"),d(G,"class","relative group"),d(Fe,"href","https://arxiv.org/pdf/2304.02643v1.pdf"),d(Fe,"rel","nofollow"),Um(Zo.src,Yi="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/sam-output.png")||d(Zo,"src",Yi),d(Zo,"alt","example image"),d(Re,"href","https://segment-anything.com"),d(Re,"rel","nofollow"),d(Ze,"href","https://github.com/facebookresearch/segment-anything/issues/4#issuecomment-1497626844"),d(Ze,"rel","nofollow"),d(Be,"href","https://huggingface.co/ybelkada"),d(Be,"rel","nofollow"),d(Le,"href","https://huggingface.co/ArthurZ"),d(Le,"rel","nofollow"),d(qe,"href","https://github.com/facebookresearch/segment-anything"),d(qe,"rel","nofollow"),d(Xe,"href","https://github.com/huggingface/notebooks/blob/main/examples/segment_anything.ipynb"),d(Xe,"rel","nofollow"),d(Ye,"href","https://github.com/huggingface/notebooks/blob/main/examples/automatic_mask_generation.ipynb"),d(Ye,"rel","nofollow"),d(He,"href","https://github.com/NielsRogge/Transformers-Tutorials/blob/master/SAM/Run_inference_with_MedSAM_using_HuggingFace_Transformers.ipynb"),d(He,"rel","nofollow"),d(Oe,"href","https://github.com/NielsRogge/Transformers-Tutorials/blob/master/SAM/Fine_tune_SAM_(segment_anything)_on_a_custom_dataset.ipynb"),d(Oe,"rel","nofollow"),d(fe,"id","transformers.SamConfig"),d(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"),d(fe,"href","#transformers.SamConfig"),d(X,"class","relative group"),d(Ko,"href","/docs/transformers/v4.33.0/en/model_doc/sam#transformers.SamConfig"),d(et,"href","/docs/transformers/v4.33.0/en/model_doc/sam#transformers.SamModel"),d(eo,"href","https://huggingface.co/facebook/sam-vit-huge"),d(eo,"rel","nofollow"),d(ot,"href","/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig"),d(tt,"href","/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig"),d(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(ue,"id","transformers.SamVisionConfig"),d(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"),d(ue,"href","#transformers.SamVisionConfig"),d(H,"class","relative group"),d(no,"href","https://huggingface.co/facebook/sam-vit-huge"),d(no,"rel","nofollow"),d(nt,"href","/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig"),d(rt,"href","/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig"),d(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(_e,"id","transformers.SamMaskDecoderConfig"),d(_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"),d(_e,"href","#transformers.SamMaskDecoderConfig"),d(K,"class","relative group"),d(so,"href","https://huggingface.co/facebook/sam-vit-huge"),d(so,"rel","nofollow"),d(at,"href","/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig"),d(st,"href","/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig"),d(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(be,"id","transformers.SamPromptEncoderConfig"),d(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"),d(be,"href","#transformers.SamPromptEncoderConfig"),d(te,"class","relative group"),d(lo,"href","https://huggingface.co/facebook/sam-vit-huge"),d(lo,"rel","nofollow"),d(it,"href","/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig"),d(dt,"href","/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig"),d(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(ve,"id","transformers.SamProcessor"),d(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"),d(ve,"href","#transformers.SamProcessor"),d(re,"class","relative group"),d(mt,"href","/docs/transformers/v4.33.0/en/model_doc/sam#transformers.SamProcessor"),d(lt,"href","/docs/transformers/v4.33.0/en/model_doc/sam#transformers.SamImageProcessor"),d(ho,"href","/docs/transformers/v4.33.0/en/model_doc/donut#transformers.DonutFeatureExtractor.__call__"),d(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(ye,"id","transformers.SamImageProcessor"),d(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"),d(ye,"href","#transformers.SamImageProcessor"),d(ae,"class","relative group"),d(we,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(Se,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(Te,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(Me,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(ke,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(xe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(Ie,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(ze,"id","transformers.SamModel"),d(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"),d(ze,"href","#transformers.SamModel"),d(ie,"class","relative group"),d(ct,"href","/docs/transformers/v4.33.0/en/main_classes/model#transformers.PreTrainedModel"),d(Eo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),d(Eo,"rel","nofollow"),d(pt,"href","/docs/transformers/v4.33.0/en/model_doc/sam#transformers.SamModel"),d(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(Ee,"id","transformers.TFSamModel"),d(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"),d(Ee,"href","#transformers.TFSamModel"),d(me,"class","relative group"),d(ht,"href","/docs/transformers/v4.33.0/en/main_classes/model#transformers.TFPreTrainedModel"),d(Uo,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),d(Uo,"rel","nofollow"),d(ft,"href","/docs/transformers/v4.33.0/en/model_doc/sam#transformers.TFSamModel"),d(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(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,da),p(o,Cn,c),p(o,X,c),e(X,fe),e(fe,Ut),_(Qe,Ut,null),e(X,ma),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,ds),e(J,ms),e(J,ne),e(ne,ls),e(ne,it),e(it,cs),e(ne,ps),e(ne,dt),e(dt,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,mt),e(mt,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,dn),e(dn,ti),e(M,ni),e(M,Ie),_(Mo,Ie,null),e(Ie,ri),e(Ie,ko),e(ko,ai),e(ko,mn),e(mn,si),e(ko,ii),p(o,Zn,c),p(o,ie,c),e(ie,ze),e(ze,ln),_(xo,ln,null),e(ie,di),e(ie,cn),e(cn,mi),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,de),e(de,yi),e(de,pt),e(pt,wi),e(de,Si),e(de,pn),e(pn,Ti),e(de,Mi),e(Z,ki),_($e,Z,null),p(o,Ln,c),p(o,me,c),e(me,Ee),e(Ee,hn),_(Po,hn,null),e(me,xi),e(me,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(me),y(Po),o&&t(qn),o&&t(P),y(No),y(jo),y(Ce)}}}const Bm={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 Lm(ce){return jm(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Qm extends Pm{constructor(f){super();Nm(this,f,Lm,Zm,Am,{})}}export{Qm as default,Bm as metadata};
