import{S as dd,i as cd,s as ld,e as r,k as d,w as f,t as s,M as pd,c as a,d as t,m as c,a as n,x as h,h as i,b as m,N as fd,G as e,g as p,y as g,q as u,o as _,B as v,v as hd,L as gd}from"../../chunks/vendor-hf-doc-builder.js";import{T as ud}from"../../chunks/Tip-hf-doc-builder.js";import{D as x}from"../../chunks/Docstring-hf-doc-builder.js";import{C as md}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as se}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as _d}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function vd(Ao){let S,E,k,$,C;return $=new md({props:{code:`from transformers import (
    SamVisionConfig,
    SamPromptEncoderConfig,
    SamMaskDecoderConfig,
    SamModel,
)

# Initializing a SamConfig with \`"facebook/sam-vit-huge"\` style configuration
configuration = SamConfig()

# Initializing a SamModel (with random weights) from the \`"facebook/sam-vit-huge"\` style configuration
model = SamModel(configuration)

# Accessing the model configuration
configuration = model.config

# We can also initialize a SamConfig from a SamVisionConfig, SamPromptEncoderConfig, and SamMaskDecoderConfig

# Initializing SAM vision, SAM Q-Former and language model configurations
vision_config = SamVisionConfig()
prompt_encoder_config = SamPromptEncoderConfig()
mask_decoder_config = SamMaskDecoderConfig()

config = SamConfig(vision_config, prompt_encoder_config, mask_decoder_config)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> (
<span class="hljs-meta">... </span>    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(){S=r("p"),E=s("Example:"),k=d(),f($.$$.fragment)},l(b){S=a(b,"P",{});var P=n(S);E=i(P,"Example:"),P.forEach(t),k=c(b),h($.$$.fragment,b)},m(b,P){p(b,S,P),e(S,E),p(b,k,P),g($,b,P),C=!0},p:gd,i(b){C||(u($.$$.fragment,b),C=!0)},o(b){_($.$$.fragment,b),C=!1},d(b){b&&t(S),b&&t(k),v($,b)}}}function bd(Ao){let S,E,k,$,C;return{c(){S=r("p"),E=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),k=r("code"),$=s("Module"),C=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(b){S=a(b,"P",{});var P=n(S);E=i(P,"Although the recipe for forward pass needs to be defined within this function, one should call the "),k=a(P,"CODE",{});var ie=n(k);$=i(ie,"Module"),ie.forEach(t),C=i(P,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),P.forEach(t)},m(b,P){p(b,S,P),e(S,E),e(S,k),e(k,$),e(S,C)},d(b){b&&t(S)}}}function yd(Ao){let S,E,k,$,C,b,P,ie,ia,sr,W,me,St,De,ma,wt,da,ir,de,ca,Ae,la,pa,mr,No,fa,dr,Lo,jo,Ii,cr,Ro,ha,lr,qo,Ne,ga,Le,ua,_a,pr,Vo,va,fr,T,kt,ba,ya,$t,Sa,wa,xt,ka,$a,Pt,xa,Pa,je,za,Re,Ca,Ta,hr,M,Ia,qe,Ea,Ma,Ve,Da,Aa,Ue,Na,La,gr,Uo,ja,ur,Oe,_r,Oo,Ra,vr,D,Fo,Fe,qa,Va,Ua,Wo,We,Oa,Fa,Wa,Bo,Be,Ba,Ga,Ha,Go,Ge,Ya,Xa,br,B,ce,zt,He,Za,Ct,Ja,yr,z,Ye,Ka,q,Ho,Qa,en,Yo,on,tn,Xe,rn,an,nn,G,sn,Xo,mn,dn,Zo,cn,ln,pn,le,fn,pe,Ze,hn,Je,gn,Jo,un,_n,Sr,H,fe,Tt,Ke,vn,It,bn,wr,A,Qe,yn,Y,Sn,Et,wn,kn,eo,$n,xn,Pn,X,zn,Ko,Cn,Tn,Qo,In,En,kr,Z,he,Mt,oo,Mn,Dt,Dn,$r,N,to,An,J,Nn,At,Ln,jn,ro,Rn,qn,Vn,K,Un,et,On,Fn,ot,Wn,Bn,xr,Q,ge,Nt,ao,Gn,Lt,Hn,Pr,L,no,Yn,j,Xn,jt,Zn,Jn,Rt,Kn,Qn,so,es,os,ts,ee,rs,tt,as,ns,rt,ss,is,zr,oe,ue,qt,io,ms,Vt,ds,Cr,R,mo,cs,Ut,ls,ps,V,at,fs,hs,nt,gs,us,co,Ot,_s,vs,bs,Tr,te,_e,Ft,lo,ys,Wt,Ss,Ir,y,po,ws,Bt,ks,$s,ve,fo,xs,re,Ps,Gt,zs,Cs,Ht,Ts,Is,Es,be,ho,Ms,go,Ds,Yt,As,Ns,Ls,ye,uo,js,Xt,Rs,qs,Se,_o,Vs,vo,Us,Zt,Os,Fs,Ws,we,bo,Bs,Jt,Gs,Hs,ke,yo,Ys,Kt,Xs,Zs,$e,So,Js,Qt,Ks,Qs,xe,wo,ei,er,oi,ti,Pe,ko,ri,$o,ai,or,ni,si,Er,ae,ze,tr,xo,ii,rr,mi,Mr,I,Po,di,zo,ci,st,li,pi,fi,Co,hi,To,gi,ui,_i,U,Io,vi,ne,bi,it,yi,Si,ar,wi,ki,$i,Ce,Dr;return b=new se({}),De=new se({}),Oe=new md({props:{code:`import torch
from PIL import Image
import requests
from transformers import SamModel, SamProcessor

device = "cuda" if torch.cuda.is_available() else "cpu"
model = SamModel.from_pretrained("facebook/sam-vit-huge").to(device)
processor = SamProcessor.from_pretrained("facebook/sam-vit-huge")

img_url = "https://huggingface.co/ybelkada/segment-anything/resolve/main/assets/car.png"
raw_image = Image.open(requests.get(img_url, stream=True).raw).convert("RGB")
input_points = [[[450, 600]]]  # 2D location of a window in the image

inputs = processor(raw_image, input_points=input_points, return_tensors="pt").to(device)
outputs = model(**inputs)

masks = processor.image_processor.post_process_masks(
    outputs.pred_masks.cpu(), inputs["original_sizes"].cpu(), inputs["reshaped_input_sizes"].cpu()
)
scores = outputs.iou_scores`,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`}}),He=new se({}),Ye=new x({props:{name:"class transformers.SamConfig",anchor:"transformers.SamConfig",parameters:[{name:"vision_config",val:" = None"},{name:"prompt_encoder_config",val:" = None"},{name:"mask_decoder_config",val:" = None"},{name:"initializer_range",val:" = 0.02"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamConfig.vision_config",description:`<strong>vision_config</strong> (Union[<code>dict</code>, <code>SamVisionConfig</code>], <em>optional</em>) &#x2014;
Dictionary of configuration options used to initialize <a href="/docs/transformers/v4.29.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.29.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.29.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.29.0/src/transformers/models/sam/configuration_sam.py#L254"}}),le=new _d({props:{anchor:"transformers.SamConfig.example",$$slots:{default:[vd]},$$scope:{ctx:Ao}}}),Ze=new x({props:{name:"to_dict",anchor:"transformers.SamConfig.to_dict",parameters:[],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/sam/configuration_sam.py#L332",returnDescription:`
<p>Dictionary of all the attributes that make up this configuration instance,</p>
`,returnType:`
<p><code>Dict[str, any]</code></p>
`}}),Ke=new se({}),Qe=new x({props:{name:"class transformers.SamVisionConfig",anchor:"transformers.SamVisionConfig",parameters:[{name:"hidden_size",val:" = 768"},{name:"intermediate_size",val:" = 6144"},{name:"projection_dim",val:" = 512"},{name:"output_channels",val:" = 256"},{name:"num_hidden_layers",val:" = 12"},{name:"num_attention_heads",val:" = 12"},{name:"num_channels",val:" = 3"},{name:"image_size",val:" = 1024"},{name:"patch_size",val:" = 16"},{name:"hidden_act",val:" = 'gelu'"},{name:"layer_norm_eps",val:" = 1e-06"},{name:"dropout",val:" = 0.0"},{name:"attention_dropout",val:" = 0.0"},{name:"initializer_range",val:" = 1e-10"},{name:"initializer_factor",val:" = 1.0"},{name:"qkv_bias",val:" = True"},{name:"mlp_ratio",val:" = 4.0"},{name:"use_abs_pos",val:" = True"},{name:"use_rel_pos",val:" = True"},{name:"window_size",val:" = 14"},{name:"global_attn_indexes",val:" = [2, 5, 8, 11]"},{name:"num_pos_feats",val:" = 128"},{name:"mlp_dim",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamVisionConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 768) &#x2014;
Dimensionality of the encoder layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.SamVisionConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 6144) &#x2014;
Dimensionality of the &#x201C;intermediate&#x201D; (i.e., feed-forward) layer in the Transformer encoder.`,name:"intermediate_size"},{anchor:"transformers.SamVisionConfig.projection_dim",description:`<strong>projection_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 512) &#x2014;
Dimensionality of the projection layer in the Transformer encoder.`,name:"projection_dim"},{anchor:"transformers.SamVisionConfig.output_channels",description:`<strong>output_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 256) &#x2014;
Dimensionality of the output channels in the Patch Encoder.`,name:"output_channels"},{anchor:"transformers.SamVisionConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"num_hidden_layers"},{anchor:"transformers.SamVisionConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_attention_heads"},{anchor:"transformers.SamVisionConfig.num_channels",description:`<strong>num_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 3) &#x2014;
Number of channels in the input image.`,name:"num_channels"},{anchor:"transformers.SamVisionConfig.image_size",description:`<strong>image_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
Expected resolution. Target size of the resized input image.`,name:"image_size"},{anchor:"transformers.SamVisionConfig.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
Size of the patches to be extracted from the input image.`,name:"patch_size"},{anchor:"transformers.SamVisionConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string)`,name:"hidden_act"},{anchor:"transformers.SamVisionConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-6) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.SamVisionConfig.dropout",description:`<strong>dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout probability.`,name:"dropout"},{anchor:"transformers.SamVisionConfig.attention_dropout",description:`<strong>attention_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout ratio for the attention probabilities.`,name:"attention_dropout"},{anchor:"transformers.SamVisionConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-10) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.SamVisionConfig.initializer_factor",description:`<strong>initializer_factor</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
A factor for multiplying the initializer range.`,name:"initializer_factor"},{anchor:"transformers.SamVisionConfig.qkv_bias",description:`<strong>qkv_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to add a bias to query, key, value projections.`,name:"qkv_bias"},{anchor:"transformers.SamVisionConfig.mlp_ratio",description:`<strong>mlp_ratio</strong> (<code>float</code>, <em>optional</em>, defaults to 4.0) &#x2014;
Ratio of mlp hidden dim to embedding dim.`,name:"mlp_ratio"},{anchor:"transformers.SamVisionConfig.use_abs_pos",description:`<strong>use_abs_pos</strong> (<code>bool</code>, <em>optional</em>, defaults to True) &#x2014;
Whether to use absolute position embedding.`,name:"use_abs_pos"},{anchor:"transformers.SamVisionConfig.use_rel_pos",description:`<strong>use_rel_pos</strong> (<code>bool</code>, <em>optional</em>, defaults to True) &#x2014;
Whether to use relative position embedding.`,name:"use_rel_pos"},{anchor:"transformers.SamVisionConfig.window_size",description:`<strong>window_size</strong> (<code>int</code>, <em>optional</em>, defaults to 14) &#x2014;
Window size for relative position.`,name:"window_size"},{anchor:"transformers.SamVisionConfig.global_attn_indexes",description:`<strong>global_attn_indexes</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[2, 5, 8, 11]</code>) &#x2014;
The indexes of the global attention layers.`,name:"global_attn_indexes"},{anchor:"transformers.SamVisionConfig.num_pos_feats",description:`<strong>num_pos_feats</strong> (<code>int</code>, <em>optional</em>, defaults to 128) &#x2014;
The dimensionality of the position embedding.`,name:"num_pos_feats"},{anchor:"transformers.SamVisionConfig.mlp_dim",description:`<strong>mlp_dim</strong> (<code>int</code>, <em>optional</em>, defaults to None) &#x2014;
The dimensionality of the MLP layer in the Transformer encoder. If <code>None</code>, defaults to <code>mlp_ratio * hidden_size</code>.`,name:"mlp_dim"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/sam/configuration_sam.py#L140"}}),oo=new se({}),to=new x({props:{name:"class transformers.SamMaskDecoderConfig",anchor:"transformers.SamMaskDecoderConfig",parameters:[{name:"hidden_size",val:" = 256"},{name:"hidden_act",val:" = 'relu'"},{name:"mlp_dim",val:" = 2048"},{name:"num_hidden_layers",val:" = 2"},{name:"num_attention_heads",val:" = 8"},{name:"attention_downsample_rate",val:" = 2"},{name:"num_multimask_outputs",val:" = 3"},{name:"iou_head_depth",val:" = 3"},{name:"iou_head_hidden_dim",val:" = 256"},{name:"layer_norm_eps",val:" = 1e-06"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamMaskDecoderConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 256) &#x2014;
Dimensionality of the hidden states.`,name:"hidden_size"},{anchor:"transformers.SamMaskDecoderConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;relu&quot;</code>) &#x2014;
The non-linear activation function used inside the <code>SamMaskDecoder</code> module.`,name:"hidden_act"},{anchor:"transformers.SamMaskDecoderConfig.mlp_dim",description:`<strong>mlp_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 2048) &#x2014;
Dimensionality of the &#x201C;intermediate&#x201D; (i.e., feed-forward) layer in the Transformer encoder.`,name:"mlp_dim"},{anchor:"transformers.SamMaskDecoderConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"num_hidden_layers"},{anchor:"transformers.SamMaskDecoderConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 8) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_attention_heads"},{anchor:"transformers.SamMaskDecoderConfig.attention_downsample_rate",description:`<strong>attention_downsample_rate</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
The downsampling rate of the attention layer.`,name:"attention_downsample_rate"},{anchor:"transformers.SamMaskDecoderConfig.num_multimask_outputs",description:`<strong>num_multimask_outputs</strong> (<code>int</code>, <em>optional</em>, defaults to 3) &#x2014;
The number of outputs from the <code>SamMaskDecoder</code> module. In the Segment Anything paper, this is set to 3.`,name:"num_multimask_outputs"},{anchor:"transformers.SamMaskDecoderConfig.iou_head_depth",description:`<strong>iou_head_depth</strong> (<code>int</code>, <em>optional</em>, defaults to 3) &#x2014;
The number of layers in the IoU head module.`,name:"iou_head_depth"},{anchor:"transformers.SamMaskDecoderConfig.iou_head_hidden_dim",description:`<strong>iou_head_hidden_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 256) &#x2014;
The dimensionality of the hidden states in the IoU head module.`,name:"iou_head_hidden_dim"},{anchor:"transformers.SamMaskDecoderConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-6) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/sam/configuration_sam.py#L79"}}),ao=new se({}),no=new x({props:{name:"class transformers.SamPromptEncoderConfig",anchor:"transformers.SamPromptEncoderConfig",parameters:[{name:"hidden_size",val:" = 256"},{name:"image_size",val:" = 1024"},{name:"patch_size",val:" = 16"},{name:"mask_input_channels",val:" = 16"},{name:"num_point_embeddings",val:" = 4"},{name:"hidden_act",val:" = 'gelu'"},{name:"layer_norm_eps",val:" = 1e-06"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamPromptEncoderConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 256) &#x2014;
Dimensionality of the hidden states.`,name:"hidden_size"},{anchor:"transformers.SamPromptEncoderConfig.image_size",description:`<strong>image_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
The expected output resolution of the image.`,name:"image_size"},{anchor:"transformers.SamPromptEncoderConfig.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
The size (resolution) of each patch.`,name:"patch_size"},{anchor:"transformers.SamPromptEncoderConfig.mask_input_channels",description:`<strong>mask_input_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
The number of channels to be fed to the <code>MaskDecoder</code> module.`,name:"mask_input_channels"},{anchor:"transformers.SamPromptEncoderConfig.num_point_embeddings",description:`<strong>num_point_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014;
The number of point embeddings to be used.`,name:"num_point_embeddings"},{anchor:"transformers.SamPromptEncoderConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function in the encoder and pooler.`,name:"hidden_act"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/sam/configuration_sam.py#L32"}}),io=new se({}),mo=new x({props:{name:"class transformers.SamProcessor",anchor:"transformers.SamProcessor",parameters:[{name:"image_processor",val:""}],parametersDescription:[{anchor:"transformers.SamProcessor.image_processor",description:`<strong>image_processor</strong> (<code>SamImageProcessor</code>) &#x2014;
An instance of <a href="/docs/transformers/v4.29.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.29.0/src/transformers/models/sam/processing_sam.py#L32"}}),lo=new se({}),po=new x({props:{name:"class transformers.SamImageProcessor",anchor:"transformers.SamImageProcessor",parameters:[{name:"do_resize",val:": bool = True"},{name:"size",val:": typing.Dict[str, int] = None"},{name:"resample",val:": Resampling = <Resampling.BILINEAR: 2>"},{name:"do_rescale",val:": bool = True"},{name:"rescale_factor",val:": typing.Union[int, float] = 0.00392156862745098"},{name:"do_normalize",val:": bool = True"},{name:"image_mean",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"image_std",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"do_pad",val:": bool = True"},{name:"pad_size",val:": int = None"},{name:"do_convert_rgb",val:": bool = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamImageProcessor.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to resize the image&#x2019;s (height, width) dimensions to the specified <code>size</code>. Can be overridden by the
<code>do_resize</code> parameter in the <code>preprocess</code> method.`,name:"do_resize"},{anchor:"transformers.SamImageProcessor.size",description:`<strong>size</strong> (<code>dict</code>, <em>optional</em>, defaults to <code>{&quot;longest_edge&quot; -- 1024}</code>):
Size of the output image after resizing. Resizes the longest edge of the image to match
<code>size[&quot;longest_edge&quot;]</code> while maintaining the aspect ratio. Can be overridden by the <code>size</code> parameter in the
<code>preprocess</code> method.`,name:"size"},{anchor:"transformers.SamImageProcessor.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code>, <em>optional</em>, defaults to <code>PILImageResampling.BICUBIC</code>) &#x2014;
Resampling filter to use if resizing the image. Can be overridden by the <code>resample</code> parameter in the
<code>preprocess</code> method.`,name:"resample"},{anchor:"transformers.SamImageProcessor.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Wwhether to rescale the image by the specified scale <code>rescale_factor</code>. Can be overridden by the
<code>do_rescale</code> parameter in the <code>preprocess</code> method.`,name:"do_rescale"},{anchor:"transformers.SamImageProcessor.rescale_factor",description:`<strong>rescale_factor</strong> (<code>int</code> or <code>float</code>, <em>optional</em>, defaults to <code>1/255</code>) &#x2014;
Scale factor to use if rescaling the image. Only has an effect if <code>do_rescale</code> is set to <code>True</code>. Can be
overridden by the <code>rescale_factor</code> parameter in the <code>preprocess</code> method.`,name:"rescale_factor"},{anchor:"transformers.SamImageProcessor.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to normalize the image. Can be overridden by the <code>do_normalize</code> parameter in the <code>preprocess</code>
method. Can be overridden by the <code>do_normalize</code> parameter in the <code>preprocess</code> method.`,name:"do_normalize"},{anchor:"transformers.SamImageProcessor.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IMAGENET_DEFAULT_MEAN</code>) &#x2014;
Mean to use if normalizing the image. This is a float or list of floats the length of the number of
channels in the image. Can be overridden by the <code>image_mean</code> parameter in the <code>preprocess</code> method. Can be
overridden by the <code>image_mean</code> parameter in the <code>preprocess</code> method.`,name:"image_mean"},{anchor:"transformers.SamImageProcessor.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IMAGENET_DEFAULT_STD</code>) &#x2014;
Standard deviation to use if normalizing the image. This is a float or list of floats the length of the
number of channels in the image. Can be overridden by the <code>image_std</code> parameter in the <code>preprocess</code> method.
Can be overridden by the <code>image_std</code> parameter in the <code>preprocess</code> method.`,name:"image_std"},{anchor:"transformers.SamImageProcessor.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to pad the image to the specified <code>pad_size</code>. Can be overridden by the <code>do_pad</code> parameter in the
<code>preprocess</code> method.`,name:"do_pad"},{anchor:"transformers.SamImageProcessor.pad_size",description:`<strong>pad_size</strong> (<code>dict</code>, <em>optional</em>, defaults to <code>{&quot;height&quot; -- 1024, &quot;width&quot;: 1024}</code>):
Size of the output image after padding. Can be overridden by the <code>pad_size</code> parameter in the <code>preprocess</code>
method.`,name:"pad_size"},{anchor:"transformers.SamImageProcessor.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to convert the image to RGB.`,name:"do_convert_rgb"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/sam/image_processing_sam.py#L50"}}),fo=new x({props:{name:"filter_masks",anchor:"transformers.SamImageProcessor.filter_masks",parameters:[{name:"masks",val:""},{name:"iou_scores",val:""},{name:"original_size",val:""},{name:"cropped_box_image",val:""},{name:"pred_iou_thresh",val:" = 0.88"},{name:"stability_score_thresh",val:" = 0.95"},{name:"mask_threshold",val:" = 0"},{name:"stability_score_offset",val:" = 1"}],parametersDescription:[{anchor:"transformers.SamImageProcessor.filter_masks.masks",description:`<strong>masks</strong> (<code>torch.Tensor</code>) &#x2014;
Input masks.`,name:"masks"},{anchor:"transformers.SamImageProcessor.filter_masks.iou_scores",description:`<strong>iou_scores</strong> (<code>torch.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"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/sam/image_processing_sam.py#L472"}}),ho=new x({props:{name:"generate_crop_boxes",anchor:"transformers.SamImageProcessor.generate_crop_boxes",parameters:[{name:"image",val:""},{name:"target_size",val:""},{name:"crop_n_layers",val:": int = 0"},{name:"overlap_ratio",val:": float = 0.3413333333333333"},{name:"points_per_crop",val:": typing.Optional[int] = 32"},{name:"crop_n_points_downscale_factor",val:": typing.Optional[typing.List[int]] = 1"},{name:"device",val:": typing.Optional[ForwardRef('torch.device')] = None"}],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"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/sam/image_processing_sam.py#L437"}}),uo=new x({props:{name:"normalize",anchor:"transformers.SamImageProcessor.normalize",parameters:[{name:"image",val:": ndarray"},{name:"mean",val:": typing.Union[float, typing.List[float]]"},{name:"std",val:": typing.Union[float, typing.List[float]]"},{name:"data_format",val:": typing.Union[str, transformers.image_utils.ChannelDimension, NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamImageProcessor.normalize.image",description:`<strong>image</strong> (<code>np.ndarray</code>) &#x2014;
Image to normalize.`,name:"image"},{anchor:"transformers.SamImageProcessor.normalize.mean",description:`<strong>mean</strong> (<code>float</code> or <code>List[float]</code>) &#x2014;
Image mean.`,name:"mean"},{anchor:"transformers.SamImageProcessor.normalize.std",description:`<strong>std</strong> (<code>float</code> or <code>List[float]</code>) &#x2014;
Image standard deviation.`,name:"std"},{anchor:"transformers.SamImageProcessor.normalize.data_format",description:`<strong>data_format</strong> (<code>str</code> or <code>ChannelDimension</code>, <em>optional</em>) &#x2014;
The channel dimension format of the image. If not provided, it will be the same as the input image.`,name:"data_format"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/sam/image_processing_sam.py#L222"}}),_o=new x({props:{name:"pad_image",anchor:"transformers.SamImageProcessor.pad_image",parameters:[{name:"image",val:": ndarray"},{name:"pad_size",val:": typing.Dict[str, int]"},{name:"data_format",val:": typing.Union[str, transformers.image_utils.ChannelDimension, NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamImageProcessor.pad_image.image",description:`<strong>image</strong> (<code>np.ndarray</code>) &#x2014;
Image to pad.`,name:"image"},{anchor:"transformers.SamImageProcessor.pad_image.pad_size",description:`<strong>pad_size</strong> (<code>Dict[str, int]</code>) &#x2014;
Size of the output image after padding.`,name:"pad_size"},{anchor:"transformers.SamImageProcessor.pad_image.data_format",description:`<strong>data_format</strong> (<code>str</code> or <code>ChannelDimension</code>, <em>optional</em>) &#x2014;
The data format of the image. Can be either &#x201C;channels_first&#x201D; or &#x201C;channels_last&#x201D;. If <code>None</code>, the
<code>data_format</code> of the <code>image</code> will be used.`,name:"data_format"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/sam/image_processing_sam.py#L128"}}),bo=new x({props:{name:"post_process_for_mask_generation",anchor:"transformers.SamImageProcessor.post_process_for_mask_generation",parameters:[{name:"all_masks",val:""},{name:"all_scores",val:""},{name:"all_boxes",val:""},{name:"crops_nms_thresh",val:""}],parametersDescription:[{anchor:"transformers.SamImageProcessor.post_process_for_mask_generation.all_masks",description:`<strong>all_masks</strong> (<code>List[torch.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>List[torch.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>List[torch.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"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/sam/image_processing_sam.py#L421"}}),yo=new x({props:{name:"post_process_masks",anchor:"transformers.SamImageProcessor.post_process_masks",parameters:[{name:"masks",val:""},{name:"original_sizes",val:""},{name:"reshaped_input_sizes",val:""},{name:"mask_threshold",val:" = 0.0"},{name:"binarize",val:" = True"},{name:"pad_size",val:" = None"}],parametersDescription:[{anchor:"transformers.SamImageProcessor.post_process_masks.masks",description:`<strong>masks</strong> (<code>Union[List[torch.Tensor], List[np.ndarray]]</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, 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, 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"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/sam/image_processing_sam.py#L374",returnDescription:`
<p>Batched masks in batch_size, num_channels, height, width) format, where (height, width)
is given by original_size.</p>
`,returnType:`
<p>(<code>torch.Tensor</code>)</p>
`}}),So=new x({props:{name:"preprocess",anchor:"transformers.SamImageProcessor.preprocess",parameters:[{name:"images",val:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), typing.List[ForwardRef('PIL.Image.Image')], typing.List[numpy.ndarray], typing.List[ForwardRef('torch.Tensor')]]"},{name:"do_resize",val:": typing.Optional[bool] = None"},{name:"size",val:": typing.Union[typing.Dict[str, int], NoneType] = None"},{name:"resample",val:": typing.Optional[ForwardRef('PILImageResampling')] = None"},{name:"do_rescale",val:": typing.Optional[bool] = None"},{name:"rescale_factor",val:": typing.Union[int, float, NoneType] = None"},{name:"do_normalize",val:": typing.Optional[bool] = None"},{name:"image_mean",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"image_std",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"do_pad",val:": typing.Optional[bool] = None"},{name:"pad_size",val:": typing.Union[typing.Dict[str, int], NoneType] = None"},{name:"do_convert_rgb",val:": bool = None"},{name:"return_tensors",val:": typing.Union[str, transformers.utils.generic.TensorType, NoneType] = None"},{name:"data_format",val:": ChannelDimension = <ChannelDimension.FIRST: 'channels_first'>"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamImageProcessor.preprocess.images",description:`<strong>images</strong> (<code>ImageInput</code>) &#x2014;
Image to preprocess.`,name:"images"},{anchor:"transformers.SamImageProcessor.preprocess.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_resize</code>) &#x2014;
Whether to resize the image.`,name:"do_resize"},{anchor:"transformers.SamImageProcessor.preprocess.size",description:`<strong>size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>self.size</code>) &#x2014;
Controls the size of the image after <code>resize</code>. The longest edge of the image is resized to
<code>size[&quot;longest_edge&quot;]</code> whilst preserving the aspect ratio.`,name:"size"},{anchor:"transformers.SamImageProcessor.preprocess.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code>, <em>optional</em>, defaults to <code>self.resample</code>) &#x2014;
<code>PILImageResampling</code> filter to use when resizing the image e.g. <code>PILImageResampling.BILINEAR</code>.`,name:"resample"},{anchor:"transformers.SamImageProcessor.preprocess.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_rescale</code>) &#x2014;
Whether to rescale the image pixel values by rescaling factor.`,name:"do_rescale"},{anchor:"transformers.SamImageProcessor.preprocess.rescale_factor",description:`<strong>rescale_factor</strong> (<code>int</code> or <code>float</code>, <em>optional</em>, defaults to <code>self.rescale_factor</code>) &#x2014;
Rescale factor to apply to the image pixel values.`,name:"rescale_factor"},{anchor:"transformers.SamImageProcessor.preprocess.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_normalize</code>) &#x2014;
Whether to normalize the image.`,name:"do_normalize"},{anchor:"transformers.SamImageProcessor.preprocess.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_mean</code>) &#x2014;
Image mean to normalize the image by if <code>do_normalize</code> is set to <code>True</code>.`,name:"image_mean"},{anchor:"transformers.SamImageProcessor.preprocess.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_std</code>) &#x2014;
Image standard deviation to normalize the image by if <code>do_normalize</code> is set to <code>True</code>.`,name:"image_std"},{anchor:"transformers.SamImageProcessor.preprocess.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_pad</code>) &#x2014;
Whether to pad the image.`,name:"do_pad"},{anchor:"transformers.SamImageProcessor.preprocess.pad_size",description:`<strong>pad_size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>self.pad_size</code>) &#x2014;
Controls the size of the padding applied to the image. The image is padded to <code>pad_size[&quot;height&quot;]</code> and
<code>pad_size[&quot;width&quot;]</code> if <code>do_pad</code> is set to <code>True</code>.`,name:"pad_size"},{anchor:"transformers.SamImageProcessor.preprocess.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_convert_rgb</code>) &#x2014;
Whether to convert the image to RGB.`,name:"do_convert_rgb"},{anchor:"transformers.SamImageProcessor.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <code>TensorType</code>, <em>optional</em>) &#x2014;
The type of tensors to return. Can be one of:<ul>
<li>Unset: Return a list of <code>np.ndarray</code>.</li>
<li><code>TensorType.TENSORFLOW</code> or <code>&apos;tf&apos;</code>: Return a batch of type <code>tf.Tensor</code>.</li>
<li><code>TensorType.PYTORCH</code> or <code>&apos;pt&apos;</code>: Return a batch of type <code>torch.Tensor</code>.</li>
<li><code>TensorType.NUMPY</code> or <code>&apos;np&apos;</code>: Return a batch of type <code>np.ndarray</code>.</li>
<li><code>TensorType.JAX</code> or <code>&apos;jax&apos;</code>: Return a batch of type <code>jax.numpy.ndarray</code>.</li>
</ul>`,name:"return_tensors"},{anchor:"transformers.SamImageProcessor.preprocess.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>, defaults to <code>ChannelDimension.FIRST</code>) &#x2014;
The channel dimension format for the output image. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
<li>Unset: Use the channel dimension format of the input image.</li>
</ul>`,name:"data_format"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/sam/image_processing_sam.py#L245"}}),wo=new x({props:{name:"rescale",anchor:"transformers.SamImageProcessor.rescale",parameters:[{name:"image",val:": ndarray"},{name:"scale",val:": typing.Union[int, float]"},{name:"data_format",val:": typing.Union[str, transformers.image_utils.ChannelDimension, NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamImageProcessor.rescale.image",description:`<strong>image</strong> (<code>np.ndarray</code>) &#x2014;
Image to rescale.`,name:"image"},{anchor:"transformers.SamImageProcessor.rescale.scale",description:`<strong>scale</strong> (<code>int</code> or <code>float</code>) &#x2014;
Scale to apply to the image.`,name:"scale"},{anchor:"transformers.SamImageProcessor.rescale.data_format",description:`<strong>data_format</strong> (<code>str</code> or <code>ChannelDimension</code>, <em>optional</em>) &#x2014;
The channel dimension format of the image. If not provided, it will be the same as the input image.`,name:"data_format"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/sam/image_processing_sam.py#L202"}}),ko=new x({props:{name:"resize",anchor:"transformers.SamImageProcessor.resize",parameters:[{name:"image",val:": ndarray"},{name:"size",val:": typing.Dict[str, int]"},{name:"resample",val:": Resampling = <Resampling.BICUBIC: 3>"},{name:"data_format",val:": typing.Union[str, transformers.image_utils.ChannelDimension, NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamImageProcessor.resize.image",description:`<strong>image</strong> (<code>np.ndarray</code>) &#x2014;
Image to resize.`,name:"image"},{anchor:"transformers.SamImageProcessor.resize.size",description:`<strong>size</strong> (<code>Dict[str, int]</code>) &#x2014;
Dictionary in the format <code>{&quot;longest_edge&quot;: int}</code> specifying the size of the output image. The longest
edge of the image will be resized to the specified size, while the other edge will be resized to
maintain the aspect ratio.
resample &#x2014;
<code>PILImageResampling</code> filter to use when resizing the image e.g. <code>PILImageResampling.BILINEAR</code>.`,name:"size"},{anchor:"transformers.SamImageProcessor.resize.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>) &#x2014;
The channel dimension format for the output image. If unset, the channel dimension format of the input
image is used. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
</ul>`,name:"data_format"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/sam/image_processing_sam.py#L167",returnDescription:`
<p>The resized image.</p>
`,returnType:`
<p><code>np.ndarray</code></p>
`}}),xo=new se({}),Po=new x({props:{name:"class transformers.SamModel",anchor:"transformers.SamModel",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.SamModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.29.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.29.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.29.0/src/transformers/models/sam/modeling_sam.py#L1166"}}),Io=new x({props:{name:"forward",anchor:"transformers.SamModel.forward",parameters:[{name:"pixel_values",val:": typing.Optional[torch.FloatTensor] = None"},{name:"input_points",val:": typing.Optional[torch.FloatTensor] = None"},{name:"input_labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"input_boxes",val:": typing.Optional[torch.FloatTensor] = None"},{name:"input_masks",val:": typing.Optional[torch.LongTensor] = None"},{name:"image_embeddings",val:": typing.Optional[torch.FloatTensor] = None"},{name:"multimask_output",val:": bool = True"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamModel.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/v4.29.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.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.29.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.29.0/src/transformers/models/sam/modeling_sam.py#L1259"}}),Ce=new ud({props:{$$slots:{default:[bd]},$$scope:{ctx:Ao}}}),{c(){S=r("meta"),E=d(),k=r("h1"),$=r("a"),C=r("span"),f(b.$$.fragment),P=d(),ie=r("span"),ia=s("SAM"),sr=d(),W=r("h2"),me=r("a"),St=r("span"),f(De.$$.fragment),ma=d(),wt=r("span"),da=s("Overview"),ir=d(),de=r("p"),ca=s("SAM (Segment Anything Model) was proposed in "),Ae=r("a"),la=s("Segment Anything"),pa=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."),mr=d(),No=r("p"),fa=s("The model can be used to predict segmentation masks of any object of interest given an input image."),dr=d(),Lo=r("p"),jo=r("img"),cr=d(),Ro=r("p"),ha=s("The abstract from the paper is the following:"),lr=d(),qo=r("p"),Ne=r("em"),ga=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 "),Le=r("a"),ua=s("https://segment-anything.com"),_a=s(" to foster research into foundation models for computer vision."),pr=d(),Vo=r("p"),va=s("Tips:"),fr=d(),T=r("ul"),kt=r("li"),ba=s("The model predicts binary masks that states the presence or not of the object of interest given an image."),ya=d(),$t=r("li"),Sa=s("The model predicts much better results if input 2D points and/or input bounding boxes are provided"),wa=d(),xt=r("li"),ka=s("You can prompt multiple points for the same image, and predict a single mask."),$a=d(),Pt=r("li"),xa=s("Fine-tuning the model is not supported yet"),Pa=d(),je=r("li"),za=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 "),Re=r("a"),Ca=s("the official repository"),Ta=s("."),hr=d(),M=r("p"),Ia=s("This model was contributed by "),qe=r("a"),Ea=s("ybelkada"),Ma=s(" and "),Ve=r("a"),Da=s("ArthurZ"),Aa=s(`.
The original code can be found `),Ue=r("a"),Na=s("here"),La=s("."),gr=d(),Uo=r("p"),ja=s("Below is an example on how to run mask generation given an image and a 2D point:"),ur=d(),f(Oe.$$.fragment),_r=d(),Oo=r("p"),Ra=s("Resources:"),vr=d(),D=r("ul"),Fo=r("li"),Fe=r("a"),qa=s("Demo notebook"),Va=s(" for using the model."),Ua=d(),Wo=r("li"),We=r("a"),Oa=s("Demo notebook"),Fa=s(" for using the automatic mask generation pipeline."),Wa=d(),Bo=r("li"),Be=r("a"),Ba=s("Demo notebook"),Ga=s(" for inference with MedSAM, a fine-tuned version of SAM on the medical domain."),Ha=d(),Go=r("li"),Ge=r("a"),Ya=s("Demo notebook"),Xa=s(" for fine-tuning the model on custom data."),br=d(),B=r("h2"),ce=r("a"),zt=r("span"),f(He.$$.fragment),Za=d(),Ct=r("span"),Ja=s("SamConfig"),yr=d(),z=r("div"),f(Ye.$$.fragment),Ka=d(),q=r("p"),Ho=r("a"),Qa=s("SamConfig"),en=s(" is the configuration class to store the configuration of a "),Yo=r("a"),on=s("SamModel"),tn=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 `),Xe=r("a"),rn=s("facebook/sam-vit-huge"),an=s(" architecture."),nn=d(),G=r("p"),sn=s("Configuration objects inherit from "),Xo=r("a"),mn=s("PretrainedConfig"),dn=s(` and can be used to control the model outputs. Read the
documentation from `),Zo=r("a"),cn=s("PretrainedConfig"),ln=s(" for more information."),pn=d(),f(le.$$.fragment),fn=d(),pe=r("div"),f(Ze.$$.fragment),hn=d(),Je=r("p"),gn=s("Serializes this instance to a Python dictionary. Override the default "),Jo=r("a"),un=s("to_dict()"),_n=s("."),Sr=d(),H=r("h2"),fe=r("a"),Tt=r("span"),f(Ke.$$.fragment),vn=d(),It=r("span"),bn=s("SamVisionConfig"),wr=d(),A=r("div"),f(Qe.$$.fragment),yn=d(),Y=r("p"),Sn=s("This is the configuration class to store the configuration of a "),Et=r("code"),wn=s("SamVisionModel"),kn=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
`),eo=r("a"),$n=s("facebook/sam-vit-huge"),xn=s(" architecture."),Pn=d(),X=r("p"),zn=s("Configuration objects inherit from "),Ko=r("a"),Cn=s("PretrainedConfig"),Tn=s(` and can be used to control the model outputs. Read the
documentation from `),Qo=r("a"),In=s("PretrainedConfig"),En=s(" for more information."),kr=d(),Z=r("h2"),he=r("a"),Mt=r("span"),f(oo.$$.fragment),Mn=d(),Dt=r("span"),Dn=s("SamMaskDecoderConfig"),$r=d(),N=r("div"),f(to.$$.fragment),An=d(),J=r("p"),Nn=s("This is the configuration class to store the configuration of a "),At=r("code"),Ln=s("SamMaskDecoder"),jn=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
`),ro=r("a"),Rn=s("facebook/sam-vit-huge"),qn=s(" architecture."),Vn=d(),K=r("p"),Un=s("Configuration objects inherit from "),et=r("a"),On=s("PretrainedConfig"),Fn=s(` and can be used to control the model outputs. Read the
documentation from `),ot=r("a"),Wn=s("PretrainedConfig"),Bn=s(" for more information."),xr=d(),Q=r("h2"),ge=r("a"),Nt=r("span"),f(ao.$$.fragment),Gn=d(),Lt=r("span"),Hn=s("SamPromptEncoderConfig"),Pr=d(),L=r("div"),f(no.$$.fragment),Yn=d(),j=r("p"),Xn=s("This is the configuration class to store the configuration of a "),jt=r("code"),Zn=s("SamPromptEncoder"),Jn=s(". The "),Rt=r("code"),Kn=s("SamPromptEncoder"),Qn=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
`),so=r("a"),es=s("facebook/sam-vit-huge"),os=s(" architecture."),ts=d(),ee=r("p"),rs=s("Configuration objects inherit from "),tt=r("a"),as=s("PretrainedConfig"),ns=s(` and can be used to control the model outputs. Read the
documentation from `),rt=r("a"),ss=s("PretrainedConfig"),is=s(" for more information."),zr=d(),oe=r("h2"),ue=r("a"),qt=r("span"),f(io.$$.fragment),ms=d(),Vt=r("span"),ds=s("SamProcessor"),Cr=d(),R=r("div"),f(mo.$$.fragment),cs=d(),Ut=r("p"),ls=s(`Constructs a SAM processor which wraps a SAM image processor and an 2D points & Bounding boxes processor into a
single processor.`),ps=d(),V=r("p"),at=r("a"),fs=s("SamProcessor"),hs=s(" offers all the functionalities of "),nt=r("a"),gs=s("SamImageProcessor"),us=s(`. See the docstring of
`),co=r("a"),Ot=r("strong"),_s=s("call"),vs=s("()"),bs=s(" for more information."),Tr=d(),te=r("h2"),_e=r("a"),Ft=r("span"),f(lo.$$.fragment),ys=d(),Wt=r("span"),Ss=s("SamImageProcessor"),Ir=d(),y=r("div"),f(po.$$.fragment),ws=d(),Bt=r("p"),ks=s("Constructs a SAM image processor."),$s=d(),ve=r("div"),f(fo.$$.fragment),xs=d(),re=r("p"),Ps=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 `),Gt=r("code"),zs=s("pred_iou_thresh"),Cs=s(`. The second criterion is that the stability
score needs to be greater than `),Ht=r("code"),Ts=s("stability_score_thresh"),Is=s(`. The method also converts the predicted masks to
bounding boxes and pad the predicted masks if necessary.`),Es=d(),be=r("div"),f(ho.$$.fragment),Ms=d(),go=r("p"),Ds=s("Generates a list of crop boxes of different sizes. Each layer has (2"),Yt=r("strong"),As=s("i)"),Ns=s("2 boxes for the ith layer."),Ls=d(),ye=r("div"),f(uo.$$.fragment),js=d(),Xt=r("p"),Rs=s("Normalize an image. image = (image - image_mean) / image_std."),qs=d(),Se=r("div"),f(_o.$$.fragment),Vs=d(),vo=r("p"),Us=s("Pad an image to "),Zt=r("code"),Os=s('(pad_size["height"], pad_size["width"])'),Fs=s(" with zeros to the right and bottom."),Ws=d(),we=r("div"),f(bo.$$.fragment),Bs=d(),Jt=r("p"),Gs=s("Post processes mask that are generated by calling the Non Maximum Suppression algorithm on the predicted masks."),Hs=d(),ke=r("div"),f(yo.$$.fragment),Ys=d(),Kt=r("p"),Xs=s("Remove padding and upscale masks to the original image size."),Zs=d(),$e=r("div"),f(So.$$.fragment),Js=d(),Qt=r("p"),Ks=s("Preprocess an image or batch of images."),Qs=d(),xe=r("div"),f(wo.$$.fragment),ei=d(),er=r("p"),oi=s("Rescale an image by a scale factor. image = image * scale."),ti=d(),Pe=r("div"),f(ko.$$.fragment),ri=d(),$o=r("p"),ai=s("Resize an image to "),or=r("code"),ni=s('(size["height"], size["width"])'),si=s("."),Er=d(),ae=r("h2"),ze=r("a"),tr=r("span"),f(xo.$$.fragment),ii=d(),rr=r("span"),mi=s("SamModel"),Mr=d(),I=r("div"),f(Po.$$.fragment),di=d(),zo=r("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 `),st=r("a"),li=s("PreTrainedModel"),pi=s(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),fi=d(),Co=r("p"),hi=s("This model is also a PyTorch "),To=r("a"),gi=s("torch.nn.Module"),ui=s(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),_i=d(),U=r("div"),f(Io.$$.fragment),vi=d(),ne=r("p"),bi=s("The "),it=r("a"),yi=s("SamModel"),Si=s(" forward method, overrides the "),ar=r("code"),wi=s("__call__"),ki=s(" special method."),$i=d(),f(Ce.$$.fragment),this.h()},l(o){const l=pd('[data-svelte="svelte-1phssyn"]',document.head);S=a(l,"META",{name:!0,content:!0}),l.forEach(t),E=c(o),k=a(o,"H1",{class:!0});var Eo=n(k);$=a(Eo,"A",{id:!0,class:!0,href:!0});var nr=n($);C=a(nr,"SPAN",{});var Ei=n(C);h(b.$$.fragment,Ei),Ei.forEach(t),nr.forEach(t),P=c(Eo),ie=a(Eo,"SPAN",{});var Mi=n(ie);ia=i(Mi,"SAM"),Mi.forEach(t),Eo.forEach(t),sr=c(o),W=a(o,"H2",{class:!0});var Ar=n(W);me=a(Ar,"A",{id:!0,class:!0,href:!0});var Di=n(me);St=a(Di,"SPAN",{});var Ai=n(St);h(De.$$.fragment,Ai),Ai.forEach(t),Di.forEach(t),ma=c(Ar),wt=a(Ar,"SPAN",{});var Ni=n(wt);da=i(Ni,"Overview"),Ni.forEach(t),Ar.forEach(t),ir=c(o),de=a(o,"P",{});var Nr=n(de);ca=i(Nr,"SAM (Segment Anything Model) was proposed in "),Ae=a(Nr,"A",{href:!0,rel:!0});var Li=n(Ae);la=i(Li,"Segment Anything"),Li.forEach(t),pa=i(Nr," 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."),Nr.forEach(t),mr=c(o),No=a(o,"P",{});var ji=n(No);fa=i(ji,"The model can be used to predict segmentation masks of any object of interest given an input image."),ji.forEach(t),dr=c(o),Lo=a(o,"P",{});var Ri=n(Lo);jo=a(Ri,"IMG",{src:!0,alt:!0}),Ri.forEach(t),cr=c(o),Ro=a(o,"P",{});var qi=n(Ro);ha=i(qi,"The abstract from the paper is the following:"),qi.forEach(t),lr=c(o),qo=a(o,"P",{});var Vi=n(qo);Ne=a(Vi,"EM",{});var Lr=n(Ne);ga=i(Lr,"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 "),Le=a(Lr,"A",{href:!0,rel:!0});var Ui=n(Le);ua=i(Ui,"https://segment-anything.com"),Ui.forEach(t),_a=i(Lr," to foster research into foundation models for computer vision."),Lr.forEach(t),Vi.forEach(t),pr=c(o),Vo=a(o,"P",{});var Oi=n(Vo);va=i(Oi,"Tips:"),Oi.forEach(t),fr=c(o),T=a(o,"UL",{});var O=n(T);kt=a(O,"LI",{});var Fi=n(kt);ba=i(Fi,"The model predicts binary masks that states the presence or not of the object of interest given an image."),Fi.forEach(t),ya=c(O),$t=a(O,"LI",{});var Wi=n($t);Sa=i(Wi,"The model predicts much better results if input 2D points and/or input bounding boxes are provided"),Wi.forEach(t),wa=c(O),xt=a(O,"LI",{});var Bi=n(xt);ka=i(Bi,"You can prompt multiple points for the same image, and predict a single mask."),Bi.forEach(t),$a=c(O),Pt=a(O,"LI",{});var Gi=n(Pt);xa=i(Gi,"Fine-tuning the model is not supported yet"),Gi.forEach(t),Pa=c(O),je=a(O,"LI",{});var jr=n(je);za=i(jr,"According to the paper, textual input should be also supported. However, at this time of writing this seems to be not supported according to "),Re=a(jr,"A",{href:!0,rel:!0});var Hi=n(Re);Ca=i(Hi,"the official repository"),Hi.forEach(t),Ta=i(jr,"."),jr.forEach(t),O.forEach(t),hr=c(o),M=a(o,"P",{});var Te=n(M);Ia=i(Te,"This model was contributed by "),qe=a(Te,"A",{href:!0,rel:!0});var Yi=n(qe);Ea=i(Yi,"ybelkada"),Yi.forEach(t),Ma=i(Te," and "),Ve=a(Te,"A",{href:!0,rel:!0});var Xi=n(Ve);Da=i(Xi,"ArthurZ"),Xi.forEach(t),Aa=i(Te,`.
The original code can be found `),Ue=a(Te,"A",{href:!0,rel:!0});var Zi=n(Ue);Na=i(Zi,"here"),Zi.forEach(t),La=i(Te,"."),Te.forEach(t),gr=c(o),Uo=a(o,"P",{});var Ji=n(Uo);ja=i(Ji,"Below is an example on how to run mask generation given an image and a 2D point:"),Ji.forEach(t),ur=c(o),h(Oe.$$.fragment,o),_r=c(o),Oo=a(o,"P",{});var Ki=n(Oo);Ra=i(Ki,"Resources:"),Ki.forEach(t),vr=c(o),D=a(o,"UL",{});var Ie=n(D);Fo=a(Ie,"LI",{});var xi=n(Fo);Fe=a(xi,"A",{href:!0,rel:!0});var Qi=n(Fe);qa=i(Qi,"Demo notebook"),Qi.forEach(t),Va=i(xi," for using the model."),xi.forEach(t),Ua=c(Ie),Wo=a(Ie,"LI",{});var Pi=n(Wo);We=a(Pi,"A",{href:!0,rel:!0});var em=n(We);Oa=i(em,"Demo notebook"),em.forEach(t),Fa=i(Pi," for using the automatic mask generation pipeline."),Pi.forEach(t),Wa=c(Ie),Bo=a(Ie,"LI",{});var zi=n(Bo);Be=a(zi,"A",{href:!0,rel:!0});var om=n(Be);Ba=i(om,"Demo notebook"),om.forEach(t),Ga=i(zi," for inference with MedSAM, a fine-tuned version of SAM on the medical domain."),zi.forEach(t),Ha=c(Ie),Go=a(Ie,"LI",{});var Ci=n(Go);Ge=a(Ci,"A",{href:!0,rel:!0});var tm=n(Ge);Ya=i(tm,"Demo notebook"),tm.forEach(t),Xa=i(Ci," for fine-tuning the model on custom data."),Ci.forEach(t),Ie.forEach(t),br=c(o),B=a(o,"H2",{class:!0});var Rr=n(B);ce=a(Rr,"A",{id:!0,class:!0,href:!0});var rm=n(ce);zt=a(rm,"SPAN",{});var am=n(zt);h(He.$$.fragment,am),am.forEach(t),rm.forEach(t),Za=c(Rr),Ct=a(Rr,"SPAN",{});var nm=n(Ct);Ja=i(nm,"SamConfig"),nm.forEach(t),Rr.forEach(t),yr=c(o),z=a(o,"DIV",{class:!0});var F=n(z);h(Ye.$$.fragment,F),Ka=c(F),q=a(F,"P",{});var Mo=n(q);Ho=a(Mo,"A",{href:!0});var sm=n(Ho);Qa=i(sm,"SamConfig"),sm.forEach(t),en=i(Mo," is the configuration class to store the configuration of a "),Yo=a(Mo,"A",{href:!0});var im=n(Yo);on=i(im,"SamModel"),im.forEach(t),tn=i(Mo,`. 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 `),Xe=a(Mo,"A",{href:!0,rel:!0});var mm=n(Xe);rn=i(mm,"facebook/sam-vit-huge"),mm.forEach(t),an=i(Mo," architecture."),Mo.forEach(t),nn=c(F),G=a(F,"P",{});var mt=n(G);sn=i(mt,"Configuration objects inherit from "),Xo=a(mt,"A",{href:!0});var dm=n(Xo);mn=i(dm,"PretrainedConfig"),dm.forEach(t),dn=i(mt,` and can be used to control the model outputs. Read the
documentation from `),Zo=a(mt,"A",{href:!0});var cm=n(Zo);cn=i(cm,"PretrainedConfig"),cm.forEach(t),ln=i(mt," for more information."),mt.forEach(t),pn=c(F),h(le.$$.fragment,F),fn=c(F),pe=a(F,"DIV",{class:!0});var qr=n(pe);h(Ze.$$.fragment,qr),hn=c(qr),Je=a(qr,"P",{});var Vr=n(Je);gn=i(Vr,"Serializes this instance to a Python dictionary. Override the default "),Jo=a(Vr,"A",{href:!0});var lm=n(Jo);un=i(lm,"to_dict()"),lm.forEach(t),_n=i(Vr,"."),Vr.forEach(t),qr.forEach(t),F.forEach(t),Sr=c(o),H=a(o,"H2",{class:!0});var Ur=n(H);fe=a(Ur,"A",{id:!0,class:!0,href:!0});var pm=n(fe);Tt=a(pm,"SPAN",{});var fm=n(Tt);h(Ke.$$.fragment,fm),fm.forEach(t),pm.forEach(t),vn=c(Ur),It=a(Ur,"SPAN",{});var hm=n(It);bn=i(hm,"SamVisionConfig"),hm.forEach(t),Ur.forEach(t),wr=c(o),A=a(o,"DIV",{class:!0});var dt=n(A);h(Qe.$$.fragment,dt),yn=c(dt),Y=a(dt,"P",{});var ct=n(Y);Sn=i(ct,"This is the configuration class to store the configuration of a "),Et=a(ct,"CODE",{});var gm=n(Et);wn=i(gm,"SamVisionModel"),gm.forEach(t),kn=i(ct,`. 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
`),eo=a(ct,"A",{href:!0,rel:!0});var um=n(eo);$n=i(um,"facebook/sam-vit-huge"),um.forEach(t),xn=i(ct," architecture."),ct.forEach(t),Pn=c(dt),X=a(dt,"P",{});var lt=n(X);zn=i(lt,"Configuration objects inherit from "),Ko=a(lt,"A",{href:!0});var _m=n(Ko);Cn=i(_m,"PretrainedConfig"),_m.forEach(t),Tn=i(lt,` and can be used to control the model outputs. Read the
documentation from `),Qo=a(lt,"A",{href:!0});var vm=n(Qo);In=i(vm,"PretrainedConfig"),vm.forEach(t),En=i(lt," for more information."),lt.forEach(t),dt.forEach(t),kr=c(o),Z=a(o,"H2",{class:!0});var Or=n(Z);he=a(Or,"A",{id:!0,class:!0,href:!0});var bm=n(he);Mt=a(bm,"SPAN",{});var ym=n(Mt);h(oo.$$.fragment,ym),ym.forEach(t),bm.forEach(t),Mn=c(Or),Dt=a(Or,"SPAN",{});var Sm=n(Dt);Dn=i(Sm,"SamMaskDecoderConfig"),Sm.forEach(t),Or.forEach(t),$r=c(o),N=a(o,"DIV",{class:!0});var pt=n(N);h(to.$$.fragment,pt),An=c(pt),J=a(pt,"P",{});var ft=n(J);Nn=i(ft,"This is the configuration class to store the configuration of a "),At=a(ft,"CODE",{});var wm=n(At);Ln=i(wm,"SamMaskDecoder"),wm.forEach(t),jn=i(ft,`. 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
`),ro=a(ft,"A",{href:!0,rel:!0});var km=n(ro);Rn=i(km,"facebook/sam-vit-huge"),km.forEach(t),qn=i(ft," architecture."),ft.forEach(t),Vn=c(pt),K=a(pt,"P",{});var ht=n(K);Un=i(ht,"Configuration objects inherit from "),et=a(ht,"A",{href:!0});var $m=n(et);On=i($m,"PretrainedConfig"),$m.forEach(t),Fn=i(ht,` and can be used to control the model outputs. Read the
documentation from `),ot=a(ht,"A",{href:!0});var xm=n(ot);Wn=i(xm,"PretrainedConfig"),xm.forEach(t),Bn=i(ht," for more information."),ht.forEach(t),pt.forEach(t),xr=c(o),Q=a(o,"H2",{class:!0});var Fr=n(Q);ge=a(Fr,"A",{id:!0,class:!0,href:!0});var Pm=n(ge);Nt=a(Pm,"SPAN",{});var zm=n(Nt);h(ao.$$.fragment,zm),zm.forEach(t),Pm.forEach(t),Gn=c(Fr),Lt=a(Fr,"SPAN",{});var Cm=n(Lt);Hn=i(Cm,"SamPromptEncoderConfig"),Cm.forEach(t),Fr.forEach(t),Pr=c(o),L=a(o,"DIV",{class:!0});var gt=n(L);h(no.$$.fragment,gt),Yn=c(gt),j=a(gt,"P",{});var Ee=n(j);Xn=i(Ee,"This is the configuration class to store the configuration of a "),jt=a(Ee,"CODE",{});var Tm=n(jt);Zn=i(Tm,"SamPromptEncoder"),Tm.forEach(t),Jn=i(Ee,". The "),Rt=a(Ee,"CODE",{});var Im=n(Rt);Kn=i(Im,"SamPromptEncoder"),Im.forEach(t),Qn=i(Ee,`
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
`),so=a(Ee,"A",{href:!0,rel:!0});var Em=n(so);es=i(Em,"facebook/sam-vit-huge"),Em.forEach(t),os=i(Ee," architecture."),Ee.forEach(t),ts=c(gt),ee=a(gt,"P",{});var ut=n(ee);rs=i(ut,"Configuration objects inherit from "),tt=a(ut,"A",{href:!0});var Mm=n(tt);as=i(Mm,"PretrainedConfig"),Mm.forEach(t),ns=i(ut,` and can be used to control the model outputs. Read the
documentation from `),rt=a(ut,"A",{href:!0});var Dm=n(rt);ss=i(Dm,"PretrainedConfig"),Dm.forEach(t),is=i(ut," for more information."),ut.forEach(t),gt.forEach(t),zr=c(o),oe=a(o,"H2",{class:!0});var Wr=n(oe);ue=a(Wr,"A",{id:!0,class:!0,href:!0});var Am=n(ue);qt=a(Am,"SPAN",{});var Nm=n(qt);h(io.$$.fragment,Nm),Nm.forEach(t),Am.forEach(t),ms=c(Wr),Vt=a(Wr,"SPAN",{});var Lm=n(Vt);ds=i(Lm,"SamProcessor"),Lm.forEach(t),Wr.forEach(t),Cr=c(o),R=a(o,"DIV",{class:!0});var _t=n(R);h(mo.$$.fragment,_t),cs=c(_t),Ut=a(_t,"P",{});var jm=n(Ut);ls=i(jm,`Constructs a SAM processor which wraps a SAM image processor and an 2D points & Bounding boxes processor into a
single processor.`),jm.forEach(t),ps=c(_t),V=a(_t,"P",{});var Do=n(V);at=a(Do,"A",{href:!0});var Rm=n(at);fs=i(Rm,"SamProcessor"),Rm.forEach(t),hs=i(Do," offers all the functionalities of "),nt=a(Do,"A",{href:!0});var qm=n(nt);gs=i(qm,"SamImageProcessor"),qm.forEach(t),us=i(Do,`. See the docstring of
`),co=a(Do,"A",{href:!0});var Ti=n(co);Ot=a(Ti,"STRONG",{});var Vm=n(Ot);_s=i(Vm,"call"),Vm.forEach(t),vs=i(Ti,"()"),Ti.forEach(t),bs=i(Do," for more information."),Do.forEach(t),_t.forEach(t),Tr=c(o),te=a(o,"H2",{class:!0});var Br=n(te);_e=a(Br,"A",{id:!0,class:!0,href:!0});var Um=n(_e);Ft=a(Um,"SPAN",{});var Om=n(Ft);h(lo.$$.fragment,Om),Om.forEach(t),Um.forEach(t),ys=c(Br),Wt=a(Br,"SPAN",{});var Fm=n(Wt);Ss=i(Fm,"SamImageProcessor"),Fm.forEach(t),Br.forEach(t),Ir=c(o),y=a(o,"DIV",{class:!0});var w=n(y);h(po.$$.fragment,w),ws=c(w),Bt=a(w,"P",{});var Wm=n(Bt);ks=i(Wm,"Constructs a SAM image processor."),Wm.forEach(t),$s=c(w),ve=a(w,"DIV",{class:!0});var Gr=n(ve);h(fo.$$.fragment,Gr),xs=c(Gr),re=a(Gr,"P",{});var vt=n(re);Ps=i(vt,`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 `),Gt=a(vt,"CODE",{});var Bm=n(Gt);zs=i(Bm,"pred_iou_thresh"),Bm.forEach(t),Cs=i(vt,`. The second criterion is that the stability
score needs to be greater than `),Ht=a(vt,"CODE",{});var Gm=n(Ht);Ts=i(Gm,"stability_score_thresh"),Gm.forEach(t),Is=i(vt,`. The method also converts the predicted masks to
bounding boxes and pad the predicted masks if necessary.`),vt.forEach(t),Gr.forEach(t),Es=c(w),be=a(w,"DIV",{class:!0});var Hr=n(be);h(ho.$$.fragment,Hr),Ms=c(Hr),go=a(Hr,"P",{});var Yr=n(go);Ds=i(Yr,"Generates a list of crop boxes of different sizes. Each layer has (2"),Yt=a(Yr,"STRONG",{});var Hm=n(Yt);As=i(Hm,"i)"),Hm.forEach(t),Ns=i(Yr,"2 boxes for the ith layer."),Yr.forEach(t),Hr.forEach(t),Ls=c(w),ye=a(w,"DIV",{class:!0});var Xr=n(ye);h(uo.$$.fragment,Xr),js=c(Xr),Xt=a(Xr,"P",{});var Ym=n(Xt);Rs=i(Ym,"Normalize an image. image = (image - image_mean) / image_std."),Ym.forEach(t),Xr.forEach(t),qs=c(w),Se=a(w,"DIV",{class:!0});var Zr=n(Se);h(_o.$$.fragment,Zr),Vs=c(Zr),vo=a(Zr,"P",{});var Jr=n(vo);Us=i(Jr,"Pad an image to "),Zt=a(Jr,"CODE",{});var Xm=n(Zt);Os=i(Xm,'(pad_size["height"], pad_size["width"])'),Xm.forEach(t),Fs=i(Jr," with zeros to the right and bottom."),Jr.forEach(t),Zr.forEach(t),Ws=c(w),we=a(w,"DIV",{class:!0});var Kr=n(we);h(bo.$$.fragment,Kr),Bs=c(Kr),Jt=a(Kr,"P",{});var Zm=n(Jt);Gs=i(Zm,"Post processes mask that are generated by calling the Non Maximum Suppression algorithm on the predicted masks."),Zm.forEach(t),Kr.forEach(t),Hs=c(w),ke=a(w,"DIV",{class:!0});var Qr=n(ke);h(yo.$$.fragment,Qr),Ys=c(Qr),Kt=a(Qr,"P",{});var Jm=n(Kt);Xs=i(Jm,"Remove padding and upscale masks to the original image size."),Jm.forEach(t),Qr.forEach(t),Zs=c(w),$e=a(w,"DIV",{class:!0});var ea=n($e);h(So.$$.fragment,ea),Js=c(ea),Qt=a(ea,"P",{});var Km=n(Qt);Ks=i(Km,"Preprocess an image or batch of images."),Km.forEach(t),ea.forEach(t),Qs=c(w),xe=a(w,"DIV",{class:!0});var oa=n(xe);h(wo.$$.fragment,oa),ei=c(oa),er=a(oa,"P",{});var Qm=n(er);oi=i(Qm,"Rescale an image by a scale factor. image = image * scale."),Qm.forEach(t),oa.forEach(t),ti=c(w),Pe=a(w,"DIV",{class:!0});var ta=n(Pe);h(ko.$$.fragment,ta),ri=c(ta),$o=a(ta,"P",{});var ra=n($o);ai=i(ra,"Resize an image to "),or=a(ra,"CODE",{});var ed=n(or);ni=i(ed,'(size["height"], size["width"])'),ed.forEach(t),si=i(ra,"."),ra.forEach(t),ta.forEach(t),w.forEach(t),Er=c(o),ae=a(o,"H2",{class:!0});var aa=n(ae);ze=a(aa,"A",{id:!0,class:!0,href:!0});var od=n(ze);tr=a(od,"SPAN",{});var td=n(tr);h(xo.$$.fragment,td),td.forEach(t),od.forEach(t),ii=c(aa),rr=a(aa,"SPAN",{});var rd=n(rr);mi=i(rd,"SamModel"),rd.forEach(t),aa.forEach(t),Mr=c(o),I=a(o,"DIV",{class:!0});var Me=n(I);h(Po.$$.fragment,Me),di=c(Me),zo=a(Me,"P",{});var na=n(zo);ci=i(na,`Segment Anything Model (SAM) for generating segmentation masks, given an input image and  optional 2D location and bounding boxes.
This model inherits from `),st=a(na,"A",{href:!0});var ad=n(st);li=i(ad,"PreTrainedModel"),ad.forEach(t),pi=i(na,`. 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.)`),na.forEach(t),fi=c(Me),Co=a(Me,"P",{});var sa=n(Co);hi=i(sa,"This model is also a PyTorch "),To=a(sa,"A",{href:!0,rel:!0});var nd=n(To);gi=i(nd,"torch.nn.Module"),nd.forEach(t),ui=i(sa,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),sa.forEach(t),_i=c(Me),U=a(Me,"DIV",{class:!0});var bt=n(U);h(Io.$$.fragment,bt),vi=c(bt),ne=a(bt,"P",{});var yt=n(ne);bi=i(yt,"The "),it=a(yt,"A",{href:!0});var sd=n(it);yi=i(sd,"SamModel"),sd.forEach(t),Si=i(yt," forward method, overrides the "),ar=a(yt,"CODE",{});var id=n(ar);wi=i(id,"__call__"),id.forEach(t),ki=i(yt," special method."),yt.forEach(t),$i=c(bt),h(Ce.$$.fragment,bt),bt.forEach(t),Me.forEach(t),this.h()},h(){m(S,"name","hf:doc:metadata"),m(S,"content",JSON.stringify(Sd)),m($,"id","sam"),m($,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m($,"href","#sam"),m(k,"class","relative group"),m(me,"id","overview"),m(me,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(me,"href","#overview"),m(W,"class","relative group"),m(Ae,"href","https://arxiv.org/pdf/2304.02643v1.pdf"),m(Ae,"rel","nofollow"),fd(jo.src,Ii="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/sam-output.png")||m(jo,"src",Ii),m(jo,"alt","example image"),m(Le,"href","https://segment-anything.com"),m(Le,"rel","nofollow"),m(Re,"href","https://github.com/facebookresearch/segment-anything/issues/4#issuecomment-1497626844"),m(Re,"rel","nofollow"),m(qe,"href","https://huggingface.co/ybelkada"),m(qe,"rel","nofollow"),m(Ve,"href","https://huggingface.co/ArthurZ"),m(Ve,"rel","nofollow"),m(Ue,"href","https://github.com/facebookresearch/segment-anything"),m(Ue,"rel","nofollow"),m(Fe,"href","https://github.com/huggingface/notebooks/blob/main/examples/segment_anything.ipynb"),m(Fe,"rel","nofollow"),m(We,"href","https://github.com/huggingface/notebooks/blob/main/examples/automatic_mask_generation.ipynb"),m(We,"rel","nofollow"),m(Be,"href","https://github.com/NielsRogge/Transformers-Tutorials/blob/master/SAM/Run_inference_with_MedSAM_using_HuggingFace_Transformers.ipynb"),m(Be,"rel","nofollow"),m(Ge,"href","https://github.com/NielsRogge/Transformers-Tutorials/blob/master/SAM/Fine_tune_SAM_(segment_anything)_on_a_custom_dataset.ipynb"),m(Ge,"rel","nofollow"),m(ce,"id","transformers.SamConfig"),m(ce,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(ce,"href","#transformers.SamConfig"),m(B,"class","relative group"),m(Ho,"href","/docs/transformers/v4.29.0/en/model_doc/sam#transformers.SamConfig"),m(Yo,"href","/docs/transformers/v4.29.0/en/model_doc/sam#transformers.SamModel"),m(Xe,"href","https://huggingface.co/facebook/sam-vit-huge"),m(Xe,"rel","nofollow"),m(Xo,"href","/docs/transformers/v4.29.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(Zo,"href","/docs/transformers/v4.29.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(Jo,"href","/docs/transformers/v4.29.0/en/main_classes/configuration#transformers.PretrainedConfig.to_dict"),m(pe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(fe,"id","transformers.SamVisionConfig"),m(fe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(fe,"href","#transformers.SamVisionConfig"),m(H,"class","relative group"),m(eo,"href","https://huggingface.co/facebook/sam-vit-huge"),m(eo,"rel","nofollow"),m(Ko,"href","/docs/transformers/v4.29.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(Qo,"href","/docs/transformers/v4.29.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(he,"id","transformers.SamMaskDecoderConfig"),m(he,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(he,"href","#transformers.SamMaskDecoderConfig"),m(Z,"class","relative group"),m(ro,"href","https://huggingface.co/facebook/sam-vit-huge"),m(ro,"rel","nofollow"),m(et,"href","/docs/transformers/v4.29.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(ot,"href","/docs/transformers/v4.29.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ge,"id","transformers.SamPromptEncoderConfig"),m(ge,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(ge,"href","#transformers.SamPromptEncoderConfig"),m(Q,"class","relative group"),m(so,"href","https://huggingface.co/facebook/sam-vit-huge"),m(so,"rel","nofollow"),m(tt,"href","/docs/transformers/v4.29.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(rt,"href","/docs/transformers/v4.29.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ue,"id","transformers.SamProcessor"),m(ue,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(ue,"href","#transformers.SamProcessor"),m(oe,"class","relative group"),m(at,"href","/docs/transformers/v4.29.0/en/model_doc/sam#transformers.SamProcessor"),m(nt,"href","/docs/transformers/v4.29.0/en/model_doc/sam#transformers.SamImageProcessor"),m(co,"href","/docs/transformers/v4.29.0/en/model_doc/dpt#transformers.DPTFeatureExtractor.__call__"),m(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(_e,"id","transformers.SamImageProcessor"),m(_e,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(_e,"href","#transformers.SamImageProcessor"),m(te,"class","relative group"),m(ve,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(be,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ye,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Se,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(we,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ke,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m($e,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(xe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Pe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ze,"id","transformers.SamModel"),m(ze,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(ze,"href","#transformers.SamModel"),m(ae,"class","relative group"),m(st,"href","/docs/transformers/v4.29.0/en/main_classes/model#transformers.PreTrainedModel"),m(To,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(To,"rel","nofollow"),m(it,"href","/docs/transformers/v4.29.0/en/model_doc/sam#transformers.SamModel"),m(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(o,l){e(document.head,S),p(o,E,l),p(o,k,l),e(k,$),e($,C),g(b,C,null),e(k,P),e(k,ie),e(ie,ia),p(o,sr,l),p(o,W,l),e(W,me),e(me,St),g(De,St,null),e(W,ma),e(W,wt),e(wt,da),p(o,ir,l),p(o,de,l),e(de,ca),e(de,Ae),e(Ae,la),e(de,pa),p(o,mr,l),p(o,No,l),e(No,fa),p(o,dr,l),p(o,Lo,l),e(Lo,jo),p(o,cr,l),p(o,Ro,l),e(Ro,ha),p(o,lr,l),p(o,qo,l),e(qo,Ne),e(Ne,ga),e(Ne,Le),e(Le,ua),e(Ne,_a),p(o,pr,l),p(o,Vo,l),e(Vo,va),p(o,fr,l),p(o,T,l),e(T,kt),e(kt,ba),e(T,ya),e(T,$t),e($t,Sa),e(T,wa),e(T,xt),e(xt,ka),e(T,$a),e(T,Pt),e(Pt,xa),e(T,Pa),e(T,je),e(je,za),e(je,Re),e(Re,Ca),e(je,Ta),p(o,hr,l),p(o,M,l),e(M,Ia),e(M,qe),e(qe,Ea),e(M,Ma),e(M,Ve),e(Ve,Da),e(M,Aa),e(M,Ue),e(Ue,Na),e(M,La),p(o,gr,l),p(o,Uo,l),e(Uo,ja),p(o,ur,l),g(Oe,o,l),p(o,_r,l),p(o,Oo,l),e(Oo,Ra),p(o,vr,l),p(o,D,l),e(D,Fo),e(Fo,Fe),e(Fe,qa),e(Fo,Va),e(D,Ua),e(D,Wo),e(Wo,We),e(We,Oa),e(Wo,Fa),e(D,Wa),e(D,Bo),e(Bo,Be),e(Be,Ba),e(Bo,Ga),e(D,Ha),e(D,Go),e(Go,Ge),e(Ge,Ya),e(Go,Xa),p(o,br,l),p(o,B,l),e(B,ce),e(ce,zt),g(He,zt,null),e(B,Za),e(B,Ct),e(Ct,Ja),p(o,yr,l),p(o,z,l),g(Ye,z,null),e(z,Ka),e(z,q),e(q,Ho),e(Ho,Qa),e(q,en),e(q,Yo),e(Yo,on),e(q,tn),e(q,Xe),e(Xe,rn),e(q,an),e(z,nn),e(z,G),e(G,sn),e(G,Xo),e(Xo,mn),e(G,dn),e(G,Zo),e(Zo,cn),e(G,ln),e(z,pn),g(le,z,null),e(z,fn),e(z,pe),g(Ze,pe,null),e(pe,hn),e(pe,Je),e(Je,gn),e(Je,Jo),e(Jo,un),e(Je,_n),p(o,Sr,l),p(o,H,l),e(H,fe),e(fe,Tt),g(Ke,Tt,null),e(H,vn),e(H,It),e(It,bn),p(o,wr,l),p(o,A,l),g(Qe,A,null),e(A,yn),e(A,Y),e(Y,Sn),e(Y,Et),e(Et,wn),e(Y,kn),e(Y,eo),e(eo,$n),e(Y,xn),e(A,Pn),e(A,X),e(X,zn),e(X,Ko),e(Ko,Cn),e(X,Tn),e(X,Qo),e(Qo,In),e(X,En),p(o,kr,l),p(o,Z,l),e(Z,he),e(he,Mt),g(oo,Mt,null),e(Z,Mn),e(Z,Dt),e(Dt,Dn),p(o,$r,l),p(o,N,l),g(to,N,null),e(N,An),e(N,J),e(J,Nn),e(J,At),e(At,Ln),e(J,jn),e(J,ro),e(ro,Rn),e(J,qn),e(N,Vn),e(N,K),e(K,Un),e(K,et),e(et,On),e(K,Fn),e(K,ot),e(ot,Wn),e(K,Bn),p(o,xr,l),p(o,Q,l),e(Q,ge),e(ge,Nt),g(ao,Nt,null),e(Q,Gn),e(Q,Lt),e(Lt,Hn),p(o,Pr,l),p(o,L,l),g(no,L,null),e(L,Yn),e(L,j),e(j,Xn),e(j,jt),e(jt,Zn),e(j,Jn),e(j,Rt),e(Rt,Kn),e(j,Qn),e(j,so),e(so,es),e(j,os),e(L,ts),e(L,ee),e(ee,rs),e(ee,tt),e(tt,as),e(ee,ns),e(ee,rt),e(rt,ss),e(ee,is),p(o,zr,l),p(o,oe,l),e(oe,ue),e(ue,qt),g(io,qt,null),e(oe,ms),e(oe,Vt),e(Vt,ds),p(o,Cr,l),p(o,R,l),g(mo,R,null),e(R,cs),e(R,Ut),e(Ut,ls),e(R,ps),e(R,V),e(V,at),e(at,fs),e(V,hs),e(V,nt),e(nt,gs),e(V,us),e(V,co),e(co,Ot),e(Ot,_s),e(co,vs),e(V,bs),p(o,Tr,l),p(o,te,l),e(te,_e),e(_e,Ft),g(lo,Ft,null),e(te,ys),e(te,Wt),e(Wt,Ss),p(o,Ir,l),p(o,y,l),g(po,y,null),e(y,ws),e(y,Bt),e(Bt,ks),e(y,$s),e(y,ve),g(fo,ve,null),e(ve,xs),e(ve,re),e(re,Ps),e(re,Gt),e(Gt,zs),e(re,Cs),e(re,Ht),e(Ht,Ts),e(re,Is),e(y,Es),e(y,be),g(ho,be,null),e(be,Ms),e(be,go),e(go,Ds),e(go,Yt),e(Yt,As),e(go,Ns),e(y,Ls),e(y,ye),g(uo,ye,null),e(ye,js),e(ye,Xt),e(Xt,Rs),e(y,qs),e(y,Se),g(_o,Se,null),e(Se,Vs),e(Se,vo),e(vo,Us),e(vo,Zt),e(Zt,Os),e(vo,Fs),e(y,Ws),e(y,we),g(bo,we,null),e(we,Bs),e(we,Jt),e(Jt,Gs),e(y,Hs),e(y,ke),g(yo,ke,null),e(ke,Ys),e(ke,Kt),e(Kt,Xs),e(y,Zs),e(y,$e),g(So,$e,null),e($e,Js),e($e,Qt),e(Qt,Ks),e(y,Qs),e(y,xe),g(wo,xe,null),e(xe,ei),e(xe,er),e(er,oi),e(y,ti),e(y,Pe),g(ko,Pe,null),e(Pe,ri),e(Pe,$o),e($o,ai),e($o,or),e(or,ni),e($o,si),p(o,Er,l),p(o,ae,l),e(ae,ze),e(ze,tr),g(xo,tr,null),e(ae,ii),e(ae,rr),e(rr,mi),p(o,Mr,l),p(o,I,l),g(Po,I,null),e(I,di),e(I,zo),e(zo,ci),e(zo,st),e(st,li),e(zo,pi),e(I,fi),e(I,Co),e(Co,hi),e(Co,To),e(To,gi),e(Co,ui),e(I,_i),e(I,U),g(Io,U,null),e(U,vi),e(U,ne),e(ne,bi),e(ne,it),e(it,yi),e(ne,Si),e(ne,ar),e(ar,wi),e(ne,ki),e(U,$i),g(Ce,U,null),Dr=!0},p(o,[l]){const Eo={};l&2&&(Eo.$$scope={dirty:l,ctx:o}),le.$set(Eo);const nr={};l&2&&(nr.$$scope={dirty:l,ctx:o}),Ce.$set(nr)},i(o){Dr||(u(b.$$.fragment,o),u(De.$$.fragment,o),u(Oe.$$.fragment,o),u(He.$$.fragment,o),u(Ye.$$.fragment,o),u(le.$$.fragment,o),u(Ze.$$.fragment,o),u(Ke.$$.fragment,o),u(Qe.$$.fragment,o),u(oo.$$.fragment,o),u(to.$$.fragment,o),u(ao.$$.fragment,o),u(no.$$.fragment,o),u(io.$$.fragment,o),u(mo.$$.fragment,o),u(lo.$$.fragment,o),u(po.$$.fragment,o),u(fo.$$.fragment,o),u(ho.$$.fragment,o),u(uo.$$.fragment,o),u(_o.$$.fragment,o),u(bo.$$.fragment,o),u(yo.$$.fragment,o),u(So.$$.fragment,o),u(wo.$$.fragment,o),u(ko.$$.fragment,o),u(xo.$$.fragment,o),u(Po.$$.fragment,o),u(Io.$$.fragment,o),u(Ce.$$.fragment,o),Dr=!0)},o(o){_(b.$$.fragment,o),_(De.$$.fragment,o),_(Oe.$$.fragment,o),_(He.$$.fragment,o),_(Ye.$$.fragment,o),_(le.$$.fragment,o),_(Ze.$$.fragment,o),_(Ke.$$.fragment,o),_(Qe.$$.fragment,o),_(oo.$$.fragment,o),_(to.$$.fragment,o),_(ao.$$.fragment,o),_(no.$$.fragment,o),_(io.$$.fragment,o),_(mo.$$.fragment,o),_(lo.$$.fragment,o),_(po.$$.fragment,o),_(fo.$$.fragment,o),_(ho.$$.fragment,o),_(uo.$$.fragment,o),_(_o.$$.fragment,o),_(bo.$$.fragment,o),_(yo.$$.fragment,o),_(So.$$.fragment,o),_(wo.$$.fragment,o),_(ko.$$.fragment,o),_(xo.$$.fragment,o),_(Po.$$.fragment,o),_(Io.$$.fragment,o),_(Ce.$$.fragment,o),Dr=!1},d(o){t(S),o&&t(E),o&&t(k),v(b),o&&t(sr),o&&t(W),v(De),o&&t(ir),o&&t(de),o&&t(mr),o&&t(No),o&&t(dr),o&&t(Lo),o&&t(cr),o&&t(Ro),o&&t(lr),o&&t(qo),o&&t(pr),o&&t(Vo),o&&t(fr),o&&t(T),o&&t(hr),o&&t(M),o&&t(gr),o&&t(Uo),o&&t(ur),v(Oe,o),o&&t(_r),o&&t(Oo),o&&t(vr),o&&t(D),o&&t(br),o&&t(B),v(He),o&&t(yr),o&&t(z),v(Ye),v(le),v(Ze),o&&t(Sr),o&&t(H),v(Ke),o&&t(wr),o&&t(A),v(Qe),o&&t(kr),o&&t(Z),v(oo),o&&t($r),o&&t(N),v(to),o&&t(xr),o&&t(Q),v(ao),o&&t(Pr),o&&t(L),v(no),o&&t(zr),o&&t(oe),v(io),o&&t(Cr),o&&t(R),v(mo),o&&t(Tr),o&&t(te),v(lo),o&&t(Ir),o&&t(y),v(po),v(fo),v(ho),v(uo),v(_o),v(bo),v(yo),v(So),v(wo),v(ko),o&&t(Er),o&&t(ae),v(xo),o&&t(Mr),o&&t(I),v(Po),v(Io),v(Ce)}}}const Sd={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"}],title:"SAM"};function wd(Ao){return hd(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Td extends dd{constructor(S){super();cd(this,S,wd,yd,ld,{})}}export{Td as default,Sd as metadata};
