import{s as An,f as Fn,o as Hn,n as on}from"../chunks/scheduler.25b97de1.js";import{S as Gn,i as Xn,g as i,s as n,r as l,A as Yn,h as m,f as t,c as a,j as M,u as c,x as d,k as v,y as r,a as s,v as p,d as h,t as g,w as f}from"../chunks/index.d9030fc9.js";import{T as Vn}from"../chunks/Tip.baa67368.js";import{D as w}from"../chunks/Docstring.e257edda.js";import{C as en}from"../chunks/CodeBlock.e6cd0d95.js";import{E as Qn}from"../chunks/ExampleCodeBlock.20db4b6e.js";import{H as I,E as On}from"../chunks/EditOnGithub.91d95064.js";function Kn(R){let u,x="Example:",b,S,C;return S=new en({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMCglMEElMjAlMjAlMjAlMjBTYW1WaXNpb25Db25maWclMkMlMEElMjAlMjAlMjAlMjBTYW1Qcm9tcHRFbmNvZGVyQ29uZmlnJTJDJTBBJTIwJTIwJTIwJTIwU2FtTWFza0RlY29kZXJDb25maWclMkMlMEElMjAlMjAlMjAlMjBTYW1Nb2RlbCUyQyUwQSklMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwU2FtQ29uZmlnJTIwd2l0aCUyMCU2MCUyMmZhY2Vib29rJTJGc2FtLXZpdC1odWdlJTIyJTYwJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMFNhbUNvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMFNhbU1vZGVsJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUyMGZyb20lMjB0aGUlMjAlNjAlMjJmYWNlYm9vayUyRnNhbS12aXQtaHVnZSUyMiU2MCUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsJTIwJTNEJTIwU2FtTW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmlnJTBBJTBBJTIzJTIwV2UlMjBjYW4lMjBhbHNvJTIwaW5pdGlhbGl6ZSUyMGElMjBTYW1Db25maWclMjBmcm9tJTIwYSUyMFNhbVZpc2lvbkNvbmZpZyUyQyUyMFNhbVByb21wdEVuY29kZXJDb25maWclMkMlMjBhbmQlMjBTYW1NYXNrRGVjb2RlckNvbmZpZyUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMFNBTSUyMHZpc2lvbiUyQyUyMFNBTSUyMFEtRm9ybWVyJTIwYW5kJTIwbGFuZ3VhZ2UlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb25zJTBBdmlzaW9uX2NvbmZpZyUyMCUzRCUyMFNhbVZpc2lvbkNvbmZpZygpJTBBcHJvbXB0X2VuY29kZXJfY29uZmlnJTIwJTNEJTIwU2FtUHJvbXB0RW5jb2RlckNvbmZpZygpJTBBbWFza19kZWNvZGVyX2NvbmZpZyUyMCUzRCUyMFNhbU1hc2tEZWNvZGVyQ29uZmlnKCklMEElMEFjb25maWclMjAlM0QlMjBTYW1Db25maWcodmlzaW9uX2NvbmZpZyUyQyUyMHByb21wdF9lbmNvZGVyX2NvbmZpZyUyQyUyMG1hc2tfZGVjb2Rlcl9jb25maWcp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> (
<span class="hljs-meta">... </span>    SamVisionConfig,
<span class="hljs-meta">... </span>    SamPromptEncoderConfig,
<span class="hljs-meta">... </span>    SamMaskDecoderConfig,
<span class="hljs-meta">... </span>    SamModel,
<span class="hljs-meta">... </span>)

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

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

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># We can also initialize a SamConfig from a SamVisionConfig, SamPromptEncoderConfig, and SamMaskDecoderConfig</span>

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

<span class="hljs-meta">&gt;&gt;&gt; </span>config = SamConfig(vision_config, prompt_encoder_config, mask_decoder_config)`,wrap:!1}}),{c(){u=i("p"),u.textContent=x,b=n(),l(S.$$.fragment)},l(y){u=m(y,"P",{"data-svelte-h":!0}),d(u)!=="svelte-11lpom8"&&(u.textContent=x),b=a(y),c(S.$$.fragment,y)},m(y,j){s(y,u,j),s(y,b,j),p(S,y,j),C=!0},p:on,i(y){C||(h(S.$$.fragment,y),C=!0)},o(y){g(S.$$.fragment,y),C=!1},d(y){y&&(t(u),t(b)),f(S,y)}}}function ea(R){let u,x=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){u=i("p"),u.innerHTML=x},l(b){u=m(b,"P",{"data-svelte-h":!0}),d(u)!=="svelte-fincs2"&&(u.innerHTML=x)},m(b,S){s(b,u,S)},p:on,d(b){b&&t(u)}}}function oa(R){let u,x=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){u=i("p"),u.innerHTML=x},l(b){u=m(b,"P",{"data-svelte-h":!0}),d(u)!=="svelte-fincs2"&&(u.innerHTML=x)},m(b,S){s(b,u,S)},p:on,d(b){b&&t(u)}}}function ta(R){let u,x,b,S,C,y,j,So,oe,tn='SAM (Segment Anything Model) was proposed in <a href="https://arxiv.org/pdf/2304.02643v1.pdf" rel="nofollow">Segment Anything</a> 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.',xo,te,nn="The model can be used to predict segmentation masks of any object of interest given an input image.",ko,ne,an='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/sam-output.png" alt="example image"/>',zo,ae,sn="The abstract from the paper is the following:",$o,se,rn='<em>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 — 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 <a href="https://segment-anything.com" rel="nofollow">https://segment-anything.com</a> to foster research into foundation models for computer vision.</em>',Io,re,mn="Tips:",Co,ie,dn='<li>The model predicts binary masks that states the presence or not of the object of interest given an image.</li> <li>The model predicts much better results if input 2D points and/or input bounding boxes are provided</li> <li>You can prompt multiple points for the same image, and predict a single mask.</li> <li>Fine-tuning the model is not supported yet</li> <li>According to the paper, textual input should be also supported. However, at this time of writing this seems to be not supported according to <a href="https://github.com/facebookresearch/segment-anything/issues/4#issuecomment-1497626844" rel="nofollow">the official repository</a>.</li>',jo,me,ln=`This model was contributed by <a href="https://huggingface.co/ybelkada" rel="nofollow">ybelkada</a> and <a href="https://huggingface.co/ArthurZ" rel="nofollow">ArthurZ</a>.
The original code can be found <a href="https://github.com/facebookresearch/segment-anything" rel="nofollow">here</a>.`,Po,de,cn="Below is an example on how to run mask generation given an image and a 2D point:",Jo,le,No,ce,pn="You can also process your own masks alongside the input images in the processor to be passed to the model.",Uo,pe,Wo,he,Zo,ge,hn="A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with SAM.",Lo,fe,gn='<li><a href="https://github.com/huggingface/notebooks/blob/main/examples/segment_anything.ipynb" rel="nofollow">Demo notebook</a> for using the model.</li> <li><a href="https://github.com/huggingface/notebooks/blob/main/examples/automatic_mask_generation.ipynb" rel="nofollow">Demo notebook</a> for using the automatic mask generation pipeline.</li> <li><a href="https://github.com/NielsRogge/Transformers-Tutorials/blob/master/SAM/Run_inference_with_MedSAM_using_HuggingFace_Transformers.ipynb" rel="nofollow">Demo notebook</a> for inference with MedSAM, a fine-tuned version of SAM on the medical domain. 🌎</li> <li><a href="https://github.com/NielsRogge/Transformers-Tutorials/blob/master/SAM/Fine_tune_SAM_(segment_anything)_on_a_custom_dataset.ipynb" rel="nofollow">Demo notebook</a> for fine-tuning the model on custom data. 🌎</li>',Do,ue,Bo,_e,fn='SlimSAM, a pruned version of SAM, was proposed in <a href="https://arxiv.org/abs/2312.05284" rel="nofollow">0.1% Data Makes Segment Anything Slim</a> by Zigeng Chen et al. SlimSAM reduces the size of the SAM models considerably while maintaining the same performance.',Ro,be,un='Checkpoints can be found on the <a href="https://huggingface.co/models?other=slimsam" rel="nofollow">hub</a>, and they can be used as a drop-in replacement of SAM.',Eo,ve,qo,ye,_n='One can combine <a href="grounding-dino">Grounding DINO</a> with SAM for text-based mask generation as introduced in <a href="https://arxiv.org/abs/2401.14159" rel="nofollow">Grounded SAM: Assembling Open-World Models for Diverse Visual Tasks</a>. You can refer to this <a href="https://github.com/NielsRogge/Transformers-Tutorials/blob/master/Grounding%20DINO/GroundingDINO_with_Segment_Anything.ipynb" rel="nofollow">demo notebook</a> 🌍 for details.',Vo,E,bn,Ao,Me,vn='Grounded SAM overview. Taken from the <a href="https://github.com/IDEA-Research/Grounded-Segment-Anything">original repository</a>.',Fo,Te,Ho,k,we,bt,Ge,yn=`<a href="/docs/transformers/main/en/model_doc/sam#transformers.SamConfig">SamConfig</a> is the configuration class to store the configuration of a <a href="/docs/transformers/main/en/model_doc/sam#transformers.SamModel">SamModel</a>. 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 <a href="https://huggingface.co/facebook/sam-vit-huge" rel="nofollow">facebook/sam-vit-huge</a> architecture.`,vt,Xe,Mn=`Configuration objects inherit from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> and can be used to control the model outputs. Read the
documentation from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,yt,q,Go,Se,Xo,P,xe,Mt,Ye,Tn=`This is the configuration class to store the configuration of a <code>SamVisionModel</code>. 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
<a href="https://huggingface.co/facebook/sam-vit-huge" rel="nofollow">facebook/sam-vit-huge</a> architecture.`,Tt,Qe,wn=`Configuration objects inherit from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> and can be used to control the model outputs. Read the
documentation from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,Yo,ke,Qo,J,ze,wt,Oe,Sn=`This is the configuration class to store the configuration of a <code>SamMaskDecoder</code>. 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
<a href="https://huggingface.co/facebook/sam-vit-huge" rel="nofollow">facebook/sam-vit-huge</a> architecture.`,St,Ke,xn=`Configuration objects inherit from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> and can be used to control the model outputs. Read the
documentation from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,Oo,$e,Ko,N,Ie,xt,eo,kn=`This is the configuration class to store the configuration of a <code>SamPromptEncoder</code>. The <code>SamPromptEncoder</code>
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
<a href="https://huggingface.co/facebook/sam-vit-huge" rel="nofollow">facebook/sam-vit-huge</a> architecture.`,kt,oo,zn=`Configuration objects inherit from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> and can be used to control the model outputs. Read the
documentation from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,et,Ce,ot,U,je,zt,to,$n=`Constructs a SAM processor which wraps a SAM image processor and an 2D points & Bounding boxes processor into a
single processor.`,$t,no,In=`<a href="/docs/transformers/main/en/model_doc/sam#transformers.SamProcessor">SamProcessor</a> offers all the functionalities of <a href="/docs/transformers/main/en/model_doc/sam#transformers.SamImageProcessor">SamImageProcessor</a>. See the docstring of
<a href="/docs/transformers/main/en/model_doc/layoutlmv3#transformers.LayoutLMv3FeatureExtractor.__call__"><strong>call</strong>()</a> for more information.`,tt,Pe,nt,_,Je,It,ao,Cn="Constructs a SAM image processor.",Ct,V,Ne,jt,so,jn=`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 <code>pred_iou_thresh</code>. The second criterion is that the stability
score needs to be greater than <code>stability_score_thresh</code>. The method also converts the predicted masks to
bounding boxes and pad the predicted masks if necessary.`,Pt,A,Ue,Jt,ro,Pn="Generates a list of crop boxes of different sizes. Each layer has (2<strong>i)</strong>2 boxes for the ith layer.",Nt,F,We,Ut,io,Jn="Pad an image to <code>(pad_size[&quot;height&quot;], pad_size[&quot;width&quot;])</code> with zeros to the right and bottom.",Wt,H,Ze,Zt,mo,Nn="Post processes mask that are generated by calling the Non Maximum Suppression algorithm on the predicted masks.",Lt,G,Le,Dt,lo,Un="Remove padding and upscale masks to the original image size.",Bt,X,De,Rt,co,Wn="Preprocess an image or batch of images.",Et,Y,Be,qt,po,Zn="Resize an image to <code>(size[&quot;height&quot;], size[&quot;width&quot;])</code>.",at,Re,st,z,Ee,Vt,ho,Ln=`Segment Anything Model (SAM) for generating segmentation masks, given an input image and  optional 2D location and bounding boxes.
This model inherits from <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. 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.)`,At,go,Dn=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`,Ft,Z,qe,Ht,fo,Bn='The <a href="/docs/transformers/main/en/model_doc/sam#transformers.SamModel">SamModel</a> forward method, overrides the <code>__call__</code> special method.',Gt,Q,rt,Ve,it,$,Ae,Xt,uo,Rn=`Segment Anything Model (SAM) for generating segmentation masks, given an input image and  optional 2D location and bounding boxes.
This model inherits from <a href="/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel">TFPreTrainedModel</a>. 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.)`,Yt,_o,En=`This model is also a TensorFlow <a href="https://www.tensorflow.org/api_docs/python/tf/keras/Model" rel="nofollow">keras.Model</a>
subclass. Use it as a regular TensorFlow Model and refer to the TensorFlow documentation for all matter related to
general usage and behavior.`,Qt,L,Fe,Ot,bo,qn='The <a href="/docs/transformers/main/en/model_doc/sam#transformers.TFSamModel">TFSamModel</a> forward method, overrides the <code>__call__</code> special method.',Kt,O,mt,He,dt,wo,lt;return C=new I({props:{title:"SAM",local:"sam",headingTag:"h1"}}),j=new I({props:{title:"Overview",local:"overview",headingTag:"h2"}}),le=new en({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFpbXBvcnQlMjByZXF1ZXN0cyUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBTYW1Nb2RlbCUyQyUyMFNhbVByb2Nlc3NvciUwQSUwQWRldmljZSUyMCUzRCUyMCUyMmN1ZGElMjIlMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwJTIyY3B1JTIyJTBBbW9kZWwlMjAlM0QlMjBTYW1Nb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZzYW0tdml0LWh1Z2UlMjIpLnRvKGRldmljZSklMEFwcm9jZXNzb3IlMjAlM0QlMjBTYW1Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGc2FtLXZpdC1odWdlJTIyKSUwQSUwQWltZ191cmwlMjAlM0QlMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGeWJlbGthZGElMkZzZWdtZW50LWFueXRoaW5nJTJGcmVzb2x2ZSUyRm1haW4lMkZhc3NldHMlMkZjYXIucG5nJTIyJTBBcmF3X2ltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQoaW1nX3VybCUyQyUyMHN0cmVhbSUzRFRydWUpLnJhdykuY29udmVydCglMjJSR0IlMjIpJTBBaW5wdXRfcG9pbnRzJTIwJTNEJTIwJTVCJTVCJTVCNDUwJTJDJTIwNjAwJTVEJTVEJTVEJTIwJTIwJTIzJTIwMkQlMjBsb2NhdGlvbiUyMG9mJTIwYSUyMHdpbmRvdyUyMGluJTIwdGhlJTIwaW1hZ2UlMEElMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IocmF3X2ltYWdlJTJDJTIwaW5wdXRfcG9pbnRzJTNEaW5wdXRfcG9pbnRzJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikudG8oZGV2aWNlKSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpJTBBJTBBbWFza3MlMjAlM0QlMjBwcm9jZXNzb3IuaW1hZ2VfcHJvY2Vzc29yLnBvc3RfcHJvY2Vzc19tYXNrcyglMEElMjAlMjAlMjAlMjBvdXRwdXRzLnByZWRfbWFza3MuY3B1KCklMkMlMjBpbnB1dHMlNUIlMjJvcmlnaW5hbF9zaXplcyUyMiU1RC5jcHUoKSUyQyUyMGlucHV0cyU1QiUyMnJlc2hhcGVkX2lucHV0X3NpemVzJTIyJTVELmNwdSgpJTBBKSUwQXNjb3JlcyUyMCUzRCUyMG91dHB1dHMuaW91X3Njb3Jlcw==",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)
<span class="hljs-keyword">with</span> torch.no_grad():
    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`,wrap:!1}}),pe=new en({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFpbXBvcnQlMjByZXF1ZXN0cyUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBTYW1Nb2RlbCUyQyUyMFNhbVByb2Nlc3NvciUwQSUwQWRldmljZSUyMCUzRCUyMCUyMmN1ZGElMjIlMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwJTIyY3B1JTIyJTBBbW9kZWwlMjAlM0QlMjBTYW1Nb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZzYW0tdml0LWh1Z2UlMjIpLnRvKGRldmljZSklMEFwcm9jZXNzb3IlMjAlM0QlMjBTYW1Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGc2FtLXZpdC1odWdlJTIyKSUwQSUwQWltZ191cmwlMjAlM0QlMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGeWJlbGthZGElMkZzZWdtZW50LWFueXRoaW5nJTJGcmVzb2x2ZSUyRm1haW4lMkZhc3NldHMlMkZjYXIucG5nJTIyJTBBcmF3X2ltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQoaW1nX3VybCUyQyUyMHN0cmVhbSUzRFRydWUpLnJhdykuY29udmVydCglMjJSR0IlMjIpJTBBbWFza191cmwlMjAlM0QlMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGeWJlbGthZGElMkZzZWdtZW50LWFueXRoaW5nJTJGcmVzb2x2ZSUyRm1haW4lMkZhc3NldHMlMkZjYXIucG5nJTIyJTBBc2VnbWVudGF0aW9uX21hcCUyMCUzRCUyMEltYWdlLm9wZW4ocmVxdWVzdHMuZ2V0KG1hc2tfdXJsJTJDJTIwc3RyZWFtJTNEVHJ1ZSkucmF3KS5jb252ZXJ0KCUyMjElMjIpJTBBaW5wdXRfcG9pbnRzJTIwJTNEJTIwJTVCJTVCJTVCNDUwJTJDJTIwNjAwJTVEJTVEJTVEJTIwJTIwJTIzJTIwMkQlMjBsb2NhdGlvbiUyMG9mJTIwYSUyMHdpbmRvdyUyMGluJTIwdGhlJTIwaW1hZ2UlMEElMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IocmF3X2ltYWdlJTJDJTIwaW5wdXRfcG9pbnRzJTNEaW5wdXRfcG9pbnRzJTJDJTIwc2VnbWVudGF0aW9uX21hcHMlM0RzZWdtZW50YXRpb25fbWFwJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikudG8oZGV2aWNlKSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpJTBBJTBBbWFza3MlMjAlM0QlMjBwcm9jZXNzb3IuaW1hZ2VfcHJvY2Vzc29yLnBvc3RfcHJvY2Vzc19tYXNrcyglMEElMjAlMjAlMjAlMjBvdXRwdXRzLnByZWRfbWFza3MuY3B1KCklMkMlMjBpbnB1dHMlNUIlMjJvcmlnaW5hbF9zaXplcyUyMiU1RC5jcHUoKSUyQyUyMGlucHV0cyU1QiUyMnJlc2hhcGVkX2lucHV0X3NpemVzJTIyJTVELmNwdSgpJTBBKSUwQXNjb3JlcyUyMCUzRCUyMG91dHB1dHMuaW91X3Njb3Jlcw==",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>)
mask_url = <span class="hljs-string">&quot;https://huggingface.co/ybelkada/segment-anything/resolve/main/assets/car.png&quot;</span>
segmentation_map = Image.<span class="hljs-built_in">open</span>(requests.get(mask_url, stream=<span class="hljs-literal">True</span>).raw).convert(<span class="hljs-string">&quot;1&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, segmentation_maps=segmentation_map, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).to(device)
<span class="hljs-keyword">with</span> torch.no_grad():
    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`,wrap:!1}}),he=new I({props:{title:"Resources",local:"resources",headingTag:"h2"}}),ue=new I({props:{title:"SlimSAM",local:"slimsam",headingTag:"h2"}}),ve=new I({props:{title:"Grounded SAM",local:"grounded-sam",headingTag:"h2"}}),Te=new I({props:{title:"SamConfig",local:"transformers.SamConfig",headingTag:"h2"}}),we=new w({props:{name:"class transformers.SamConfig",anchor:"transformers.SamConfig",parameters:[{name:"vision_config",val:" = None"},{name:"prompt_encoder_config",val:" = None"},{name:"mask_decoder_config",val:" = None"},{name:"initializer_range",val:" = 0.02"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamConfig.vision_config",description:`<strong>vision_config</strong> (Union[<code>dict</code>, <code>SamVisionConfig</code>], <em>optional</em>) &#x2014;
Dictionary of configuration options used to initialize <a href="/docs/transformers/main/en/model_doc/sam#transformers.SamVisionConfig">SamVisionConfig</a>.`,name:"vision_config"},{anchor:"transformers.SamConfig.prompt_encoder_config",description:`<strong>prompt_encoder_config</strong> (Union[<code>dict</code>, <code>SamPromptEncoderConfig</code>], <em>optional</em>) &#x2014;
Dictionary of configuration options used to initialize <a href="/docs/transformers/main/en/model_doc/sam#transformers.SamPromptEncoderConfig">SamPromptEncoderConfig</a>.`,name:"prompt_encoder_config"},{anchor:"transformers.SamConfig.mask_decoder_config",description:`<strong>mask_decoder_config</strong> (Union[<code>dict</code>, <code>SamMaskDecoderConfig</code>], <em>optional</em>) &#x2014;
Dictionary of configuration options used to initialize <a href="/docs/transformers/main/en/model_doc/sam#transformers.SamMaskDecoderConfig">SamMaskDecoderConfig</a>.`,name:"mask_decoder_config"},{anchor:"transformers.SamConfig.kwargs",description:`<strong>kwargs</strong> (<em>optional</em>) &#x2014;
Dictionary of keyword arguments.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/configuration_sam.py#L230"}}),q=new Qn({props:{anchor:"transformers.SamConfig.example",$$slots:{default:[Kn]},$$scope:{ctx:R}}}),Se=new I({props:{title:"SamVisionConfig",local:"transformers.SamVisionConfig",headingTag:"h2"}}),xe=new w({props:{name:"class transformers.SamVisionConfig",anchor:"transformers.SamVisionConfig",parameters:[{name:"hidden_size",val:" = 768"},{name:"output_channels",val:" = 256"},{name:"num_hidden_layers",val:" = 12"},{name:"num_attention_heads",val:" = 12"},{name:"num_channels",val:" = 3"},{name:"image_size",val:" = 1024"},{name:"patch_size",val:" = 16"},{name:"hidden_act",val:" = 'gelu'"},{name:"layer_norm_eps",val:" = 1e-06"},{name:"attention_dropout",val:" = 0.0"},{name:"initializer_range",val:" = 1e-10"},{name:"qkv_bias",val:" = True"},{name:"mlp_ratio",val:" = 4.0"},{name:"use_abs_pos",val:" = True"},{name:"use_rel_pos",val:" = True"},{name:"window_size",val:" = 14"},{name:"global_attn_indexes",val:" = [2, 5, 8, 11]"},{name:"num_pos_feats",val:" = 128"},{name:"mlp_dim",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamVisionConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 768) &#x2014;
Dimensionality of the encoder layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.SamVisionConfig.output_channels",description:`<strong>output_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 256) &#x2014;
Dimensionality of the output channels in the Patch Encoder.`,name:"output_channels"},{anchor:"transformers.SamVisionConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"num_hidden_layers"},{anchor:"transformers.SamVisionConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_attention_heads"},{anchor:"transformers.SamVisionConfig.num_channels",description:`<strong>num_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 3) &#x2014;
Number of channels in the input image.`,name:"num_channels"},{anchor:"transformers.SamVisionConfig.image_size",description:`<strong>image_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
Expected resolution. Target size of the resized input image.`,name:"image_size"},{anchor:"transformers.SamVisionConfig.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
Size of the patches to be extracted from the input image.`,name:"patch_size"},{anchor:"transformers.SamVisionConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string)`,name:"hidden_act"},{anchor:"transformers.SamVisionConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-06) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.SamVisionConfig.attention_dropout",description:`<strong>attention_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout ratio for the attention probabilities.`,name:"attention_dropout"},{anchor:"transformers.SamVisionConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-10) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.SamVisionConfig.qkv_bias",description:`<strong>qkv_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to add a bias to query, key, value projections.`,name:"qkv_bias"},{anchor:"transformers.SamVisionConfig.mlp_ratio",description:`<strong>mlp_ratio</strong> (<code>float</code>, <em>optional</em>, defaults to 4.0) &#x2014;
Ratio of mlp hidden dim to embedding dim.`,name:"mlp_ratio"},{anchor:"transformers.SamVisionConfig.use_abs_pos",description:`<strong>use_abs_pos</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#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 <code>True</code>) &#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>) &#x2014;
The dimensionality of the MLP layer in the Transformer encoder. If <code>None</code>, defaults to <code>mlp_ratio * hidden_size</code>.`,name:"mlp_dim"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/configuration_sam.py#L132"}}),ke=new I({props:{title:"SamMaskDecoderConfig",local:"transformers.SamMaskDecoderConfig",headingTag:"h2"}}),ze=new w({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-06) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/configuration_sam.py#L71"}}),$e=new I({props:{title:"SamPromptEncoderConfig",local:"transformers.SamPromptEncoderConfig",headingTag:"h2"}}),Ie=new w({props:{name:"class transformers.SamPromptEncoderConfig",anchor:"transformers.SamPromptEncoderConfig",parameters:[{name:"hidden_size",val:" = 256"},{name:"image_size",val:" = 1024"},{name:"patch_size",val:" = 16"},{name:"mask_input_channels",val:" = 16"},{name:"num_point_embeddings",val:" = 4"},{name:"hidden_act",val:" = 'gelu'"},{name:"layer_norm_eps",val:" = 1e-06"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamPromptEncoderConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 256) &#x2014;
Dimensionality of the hidden states.`,name:"hidden_size"},{anchor:"transformers.SamPromptEncoderConfig.image_size",description:`<strong>image_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
The expected output resolution of the image.`,name:"image_size"},{anchor:"transformers.SamPromptEncoderConfig.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
The size (resolution) of each patch.`,name:"patch_size"},{anchor:"transformers.SamPromptEncoderConfig.mask_input_channels",description:`<strong>mask_input_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
The number of channels to be fed to the <code>MaskDecoder</code> module.`,name:"mask_input_channels"},{anchor:"transformers.SamPromptEncoderConfig.num_point_embeddings",description:`<strong>num_point_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014;
The number of point embeddings to be used.`,name:"num_point_embeddings"},{anchor:"transformers.SamPromptEncoderConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function in the encoder and pooler.`,name:"hidden_act"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/configuration_sam.py#L24"}}),Ce=new I({props:{title:"SamProcessor",local:"transformers.SamProcessor",headingTag:"h2"}}),je=new w({props:{name:"class transformers.SamProcessor",anchor:"transformers.SamProcessor",parameters:[{name:"image_processor",val:""}],parametersDescription:[{anchor:"transformers.SamProcessor.image_processor",description:`<strong>image_processor</strong> (<code>SamImageProcessor</code>) &#x2014;
An instance of <a href="/docs/transformers/main/en/model_doc/sam#transformers.SamImageProcessor">SamImageProcessor</a>. The image processor is a required input.`,name:"image_processor"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/processing_sam.py#L36"}}),Pe=new I({props:{title:"SamImageProcessor",local:"transformers.SamImageProcessor",headingTag:"h2"}}),Je=new w({props:{name:"class transformers.SamImageProcessor",anchor:"transformers.SamImageProcessor",parameters:[{name:"do_resize",val:": bool = True"},{name:"size",val:": Dict = None"},{name:"mask_size",val:": Dict = None"},{name:"resample",val:": Resampling = <Resampling.BILINEAR: 2>"},{name:"do_rescale",val:": bool = True"},{name:"rescale_factor",val:": Union = 0.00392156862745098"},{name:"do_normalize",val:": bool = True"},{name:"image_mean",val:": Union = None"},{name:"image_std",val:": Union = None"},{name:"do_pad",val:": bool = True"},{name:"pad_size",val:": int = None"},{name:"mask_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.mask_size",description:`<strong>mask_size</strong> (<code>dict</code>, <em>optional</em>, defaults to <code>{&quot;longest_edge&quot; -- 256}</code>):
Size of the output segmentation map 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>mask_size</code> parameter
in the <code>preprocess</code> method.`,name:"mask_size"},{anchor:"transformers.SamImageProcessor.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code>, <em>optional</em>, defaults to <code>Resampling.BILINEAR</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.mask_pad_size",description:`<strong>mask_pad_size</strong> (<code>dict</code>, <em>optional</em>, defaults to <code>{&quot;height&quot; -- 256, &quot;width&quot;: 256}</code>):
Size of the output segmentation map after padding. Can be overridden by the <code>mask_pad_size</code> parameter in
the <code>preprocess</code> method.`,name:"mask_pad_size"},{anchor:"transformers.SamImageProcessor.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to convert the image to RGB.`,name:"do_convert_rgb"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/image_processing_sam.py#L67"}}),Ne=new w({props:{name:"filter_masks",anchor:"transformers.SamImageProcessor.filter_masks",parameters:[{name:"masks",val:""},{name:"iou_scores",val:""},{name:"original_size",val:""},{name:"cropped_box_image",val:""},{name:"pred_iou_thresh",val:" = 0.88"},{name:"stability_score_thresh",val:" = 0.95"},{name:"mask_threshold",val:" = 0"},{name:"stability_score_offset",val:" = 1"},{name:"return_tensors",val:" = 'pt'"}],parametersDescription:[{anchor:"transformers.SamImageProcessor.filter_masks.masks",description:`<strong>masks</strong> (<code>Union[torch.Tensor, tf.Tensor]</code>) &#x2014;
Input masks.`,name:"masks"},{anchor:"transformers.SamImageProcessor.filter_masks.iou_scores",description:`<strong>iou_scores</strong> (<code>Union[torch.Tensor, tf.Tensor]</code>) &#x2014;
List of IoU scores.`,name:"iou_scores"},{anchor:"transformers.SamImageProcessor.filter_masks.original_size",description:`<strong>original_size</strong> (<code>Tuple[int,int]</code>) &#x2014;
Size of the orginal image.`,name:"original_size"},{anchor:"transformers.SamImageProcessor.filter_masks.cropped_box_image",description:`<strong>cropped_box_image</strong> (<code>np.array</code>) &#x2014;
The cropped image.`,name:"cropped_box_image"},{anchor:"transformers.SamImageProcessor.filter_masks.pred_iou_thresh",description:`<strong>pred_iou_thresh</strong> (<code>float</code>, <em>optional</em>, defaults to 0.88) &#x2014;
The threshold for the iou scores.`,name:"pred_iou_thresh"},{anchor:"transformers.SamImageProcessor.filter_masks.stability_score_thresh",description:`<strong>stability_score_thresh</strong> (<code>float</code>, <em>optional</em>, defaults to 0.95) &#x2014;
The threshold for the stability score.`,name:"stability_score_thresh"},{anchor:"transformers.SamImageProcessor.filter_masks.mask_threshold",description:`<strong>mask_threshold</strong> (<code>float</code>, <em>optional</em>, defaults to 0) &#x2014;
The threshold for the predicted masks.`,name:"mask_threshold"},{anchor:"transformers.SamImageProcessor.filter_masks.stability_score_offset",description:`<strong>stability_score_offset</strong> (<code>float</code>, <em>optional</em>, defaults to 1) &#x2014;
The offset for the stability score used in the <code>_compute_stability_score</code> method.`,name:"stability_score_offset"},{anchor:"transformers.SamImageProcessor.filter_masks.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code>, <em>optional</em>, defaults to <code>pt</code>) &#x2014;
If <code>pt</code>, returns <code>torch.Tensor</code>. If <code>tf</code>, returns <code>tf.Tensor</code>.`,name:"return_tensors"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/image_processing_sam.py#L830"}}),Ue=new w({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:": Optional = 32"},{name:"crop_n_points_downscale_factor",val:": Optional = 1"},{name:"device",val:": Optional = None"},{name:"input_data_format",val:": Union = None"},{name:"return_tensors",val:": str = 'pt'"}],parametersDescription:[{anchor:"transformers.SamImageProcessor.generate_crop_boxes.image",description:`<strong>image</strong> (<code>np.array</code>) &#x2014;
Input original image`,name:"image"},{anchor:"transformers.SamImageProcessor.generate_crop_boxes.target_size",description:`<strong>target_size</strong> (<code>int</code>) &#x2014;
Target size of the resized image`,name:"target_size"},{anchor:"transformers.SamImageProcessor.generate_crop_boxes.crop_n_layers",description:`<strong>crop_n_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
If &gt;0, mask prediction will be run again on crops of the image. Sets the number of layers to run, where
each layer has 2**i_layer number of image crops.`,name:"crop_n_layers"},{anchor:"transformers.SamImageProcessor.generate_crop_boxes.overlap_ratio",description:`<strong>overlap_ratio</strong> (<code>float</code>, <em>optional</em>, defaults to 512/1500) &#x2014;
Sets the degree to which crops overlap. In the first crop layer, crops will overlap by this fraction of
the image length. Later layers with more crops scale down this overlap.`,name:"overlap_ratio"},{anchor:"transformers.SamImageProcessor.generate_crop_boxes.points_per_crop",description:`<strong>points_per_crop</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
Number of points to sample from each crop.`,name:"points_per_crop"},{anchor:"transformers.SamImageProcessor.generate_crop_boxes.crop_n_points_downscale_factor",description:`<strong>crop_n_points_downscale_factor</strong> (<code>List[int]</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of points-per-side sampled in layer n is scaled down by crop_n_points_downscale_factor**n.`,name:"crop_n_points_downscale_factor"},{anchor:"transformers.SamImageProcessor.generate_crop_boxes.device",description:`<strong>device</strong> (<code>torch.device</code>, <em>optional</em>, defaults to None) &#x2014;
Device to use for the computation. If None, cpu will be used.`,name:"device"},{anchor:"transformers.SamImageProcessor.generate_crop_boxes.input_data_format",description:`<strong>input_data_format</strong> (<code>str</code> or <code>ChannelDimension</code>, <em>optional</em>) &#x2014;
The channel dimension format of the input image. If not provided, it will be inferred.`,name:"input_data_format"},{anchor:"transformers.SamImageProcessor.generate_crop_boxes.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code>, <em>optional</em>, defaults to <code>pt</code>) &#x2014;
If <code>pt</code>, returns <code>torch.Tensor</code>. If <code>tf</code>, returns <code>tf.Tensor</code>.`,name:"return_tensors"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/image_processing_sam.py#L765"}}),We=new w({props:{name:"pad_image",anchor:"transformers.SamImageProcessor.pad_image",parameters:[{name:"image",val:": ndarray"},{name:"pad_size",val:": Dict"},{name:"data_format",val:": Union = None"},{name:"input_data_format",val:": Union = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamImageProcessor.pad_image.image",description:`<strong>image</strong> (<code>np.ndarray</code>) &#x2014;
Image to pad.`,name:"image"},{anchor:"transformers.SamImageProcessor.pad_image.pad_size",description:`<strong>pad_size</strong> (<code>Dict[str, int]</code>) &#x2014;
Size of the output image after padding.`,name:"pad_size"},{anchor:"transformers.SamImageProcessor.pad_image.data_format",description:`<strong>data_format</strong> (<code>str</code> or <code>ChannelDimension</code>, <em>optional</em>) &#x2014;
The data format of the image. Can be either &#x201C;channels_first&#x201D; or &#x201C;channels_last&#x201D;. If <code>None</code>, the
<code>data_format</code> of the <code>image</code> will be used.`,name:"data_format"},{anchor:"transformers.SamImageProcessor.pad_image.input_data_format",description:`<strong>input_data_format</strong> (<code>str</code> or <code>ChannelDimension</code>, <em>optional</em>) &#x2014;
The channel dimension format of the input image. If not provided, it will be inferred.`,name:"input_data_format"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/image_processing_sam.py#L186"}}),Ze=new w({props:{name:"post_process_for_mask_generation",anchor:"transformers.SamImageProcessor.post_process_for_mask_generation",parameters:[{name:"all_masks",val:""},{name:"all_scores",val:""},{name:"all_boxes",val:""},{name:"crops_nms_thresh",val:""},{name:"return_tensors",val:" = 'pt'"}],parametersDescription:[{anchor:"transformers.SamImageProcessor.post_process_for_mask_generation.all_masks",description:`<strong>all_masks</strong> (<code>Union[List[torch.Tensor], List[tf.Tensor]]</code>) &#x2014;
List of all predicted segmentation masks`,name:"all_masks"},{anchor:"transformers.SamImageProcessor.post_process_for_mask_generation.all_scores",description:`<strong>all_scores</strong> (<code>Union[List[torch.Tensor], List[tf.Tensor]]</code>) &#x2014;
List of all predicted iou scores`,name:"all_scores"},{anchor:"transformers.SamImageProcessor.post_process_for_mask_generation.all_boxes",description:`<strong>all_boxes</strong> (<code>Union[List[torch.Tensor], List[tf.Tensor]]</code>) &#x2014;
List of all bounding boxes of the predicted masks`,name:"all_boxes"},{anchor:"transformers.SamImageProcessor.post_process_for_mask_generation.crops_nms_thresh",description:`<strong>crops_nms_thresh</strong> (<code>float</code>) &#x2014;
Threshold for NMS (Non Maximum Suppression) algorithm.`,name:"crops_nms_thresh"},{anchor:"transformers.SamImageProcessor.post_process_for_mask_generation.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code>, <em>optional</em>, defaults to <code>pt</code>) &#x2014;
If <code>pt</code>, returns <code>torch.Tensor</code>. If <code>tf</code>, returns <code>tf.Tensor</code>.`,name:"return_tensors"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/image_processing_sam.py#L742"}}),Le=new w({props:{name:"post_process_masks",anchor:"transformers.SamImageProcessor.post_process_masks",parameters:[{name:"masks",val:""},{name:"original_sizes",val:""},{name:"reshaped_input_sizes",val:""},{name:"mask_threshold",val:" = 0.0"},{name:"binarize",val:" = True"},{name:"pad_size",val:" = None"},{name:"return_tensors",val:" = 'pt'"}],parametersDescription:[{anchor:"transformers.SamImageProcessor.post_process_masks.masks",description:`<strong>masks</strong> (<code>Union[List[torch.Tensor], List[np.ndarray], List[tf.Tensor]]</code>) &#x2014;
Batched masks from the mask_decoder in (batch_size, num_channels, height, width) format.`,name:"masks"},{anchor:"transformers.SamImageProcessor.post_process_masks.original_sizes",description:`<strong>original_sizes</strong> (<code>Union[torch.Tensor, tf.Tensor, List[Tuple[int,int]]]</code>) &#x2014;
The original sizes of each image before it was resized to the model&#x2019;s expected input shape, in (height,
width) format.`,name:"original_sizes"},{anchor:"transformers.SamImageProcessor.post_process_masks.reshaped_input_sizes",description:`<strong>reshaped_input_sizes</strong> (<code>Union[torch.Tensor, tf.Tensor, List[Tuple[int,int]]]</code>) &#x2014;
The size of each image as it is fed to the model, in (height, width) format. Used to remove padding.`,name:"reshaped_input_sizes"},{anchor:"transformers.SamImageProcessor.post_process_masks.mask_threshold",description:`<strong>mask_threshold</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The threshold to use for binarizing the masks.`,name:"mask_threshold"},{anchor:"transformers.SamImageProcessor.post_process_masks.binarize",description:`<strong>binarize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to binarize the masks.`,name:"binarize"},{anchor:"transformers.SamImageProcessor.post_process_masks.pad_size",description:`<strong>pad_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.pad_size</code>) &#x2014;
The target size the images were padded to before being passed to the model. If None, the target size is
assumed to be the processor&#x2019;s <code>pad_size</code>.`,name:"pad_size"},{anchor:"transformers.SamImageProcessor.post_process_masks.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pt&quot;</code>) &#x2014;
If <code>&quot;pt&quot;</code>, return PyTorch tensors. If <code>&quot;tf&quot;</code>, return TensorFlow tensors.`,name:"return_tensors"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/image_processing_sam.py#L598",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>Batched masks in batch_size, num_channels, height, width) format, where
(height, width) is given by original_size.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p>(<code>Union[torch.Tensor, tf.Tensor]</code>)</p>
`}}),De=new w({props:{name:"preprocess",anchor:"transformers.SamImageProcessor.preprocess",parameters:[{name:"images",val:": Union"},{name:"segmentation_maps",val:": Union = None"},{name:"do_resize",val:": Optional = None"},{name:"size",val:": Optional = None"},{name:"mask_size",val:": Optional = None"},{name:"resample",val:": Optional = None"},{name:"do_rescale",val:": Optional = None"},{name:"rescale_factor",val:": Union = None"},{name:"do_normalize",val:": Optional = None"},{name:"image_mean",val:": Union = None"},{name:"image_std",val:": Union = None"},{name:"do_pad",val:": Optional = None"},{name:"pad_size",val:": Optional = None"},{name:"mask_pad_size",val:": Optional = None"},{name:"do_convert_rgb",val:": Optional = None"},{name:"return_tensors",val:": Union = None"},{name:"data_format",val:": ChannelDimension = <ChannelDimension.FIRST: 'channels_first'>"},{name:"input_data_format",val:": Union = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamImageProcessor.preprocess.images",description:`<strong>images</strong> (<code>ImageInput</code>) &#x2014;
Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If
passing in images with pixel values between 0 and 1, set <code>do_rescale=False</code>.`,name:"images"},{anchor:"transformers.SamImageProcessor.preprocess.segmentation_maps",description:`<strong>segmentation_maps</strong> (<code>ImageInput</code>, <em>optional</em>) &#x2014;
Segmentation map to preprocess.`,name:"segmentation_maps"},{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.mask_size",description:`<strong>mask_size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>self.mask_size</code>) &#x2014;
Controls the size of the segmentation map 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:"mask_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.mask_pad_size",description:`<strong>mask_pad_size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>self.mask_pad_size</code>) &#x2014;
Controls the size of the padding applied to the segmentation map. The image is padded to
<code>mask_pad_size[&quot;height&quot;]</code> and <code>mask_pad_size[&quot;width&quot;]</code> if <code>do_pad</code> is set to <code>True</code>.`,name:"mask_pad_size"},{anchor:"transformers.SamImageProcessor.preprocess.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_convert_rgb</code>) &#x2014;
Whether to convert the image to RGB.`,name:"do_convert_rgb"},{anchor:"transformers.SamImageProcessor.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <code>TensorType</code>, <em>optional</em>) &#x2014;
The type of tensors to return. Can be one of:<ul>
<li>Unset: Return a list of <code>np.ndarray</code>.</li>
<li><code>TensorType.TENSORFLOW</code> or <code>&apos;tf&apos;</code>: Return a batch of type <code>tf.Tensor</code>.</li>
<li><code>TensorType.PYTORCH</code> or <code>&apos;pt&apos;</code>: Return a batch of type <code>torch.Tensor</code>.</li>
<li><code>TensorType.NUMPY</code> or <code>&apos;np&apos;</code>: Return a batch of type <code>np.ndarray</code>.</li>
<li><code>TensorType.JAX</code> or <code>&apos;jax&apos;</code>: Return a batch of type <code>jax.numpy.ndarray</code>.</li>
</ul>`,name:"return_tensors"},{anchor:"transformers.SamImageProcessor.preprocess.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>, defaults to <code>ChannelDimension.FIRST</code>) &#x2014;
The channel dimension format for the output image. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
<li>Unset: Use the channel dimension format of the input image.</li>
</ul>`,name:"data_format"},{anchor:"transformers.SamImageProcessor.preprocess.input_data_format",description:`<strong>input_data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>) &#x2014;
The channel dimension format for the input image. If unset, the channel dimension format is inferred
from the input image. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
<li><code>&quot;none&quot;</code> or <code>ChannelDimension.NONE</code>: image in (height, width) format.</li>
</ul>`,name:"input_data_format"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/image_processing_sam.py#L412"}}),Be=new w({props:{name:"resize",anchor:"transformers.SamImageProcessor.resize",parameters:[{name:"image",val:": ndarray"},{name:"size",val:": Dict"},{name:"resample",val:": Resampling = <Resampling.BICUBIC: 3>"},{name:"data_format",val:": Union = None"},{name:"input_data_format",val:": Union = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamImageProcessor.resize.image",description:`<strong>image</strong> (<code>np.ndarray</code>) &#x2014;
Image to resize.`,name:"image"},{anchor:"transformers.SamImageProcessor.resize.size",description:`<strong>size</strong> (<code>Dict[str, int]</code>) &#x2014;
Dictionary in the format <code>{&quot;longest_edge&quot;: int}</code> specifying the size of the output image. The longest
edge of the image will be resized to the specified size, while the other edge will be resized to
maintain the aspect ratio.
resample &#x2014;
<code>PILImageResampling</code> filter to use when resizing the image e.g. <code>PILImageResampling.BILINEAR</code>.`,name:"size"},{anchor:"transformers.SamImageProcessor.resize.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>) &#x2014;
The channel dimension format for the output image. If unset, the channel dimension format of the input
image is used. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
</ul>`,name:"data_format"},{anchor:"transformers.SamImageProcessor.resize.input_data_format",description:`<strong>input_data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>) &#x2014;
The channel dimension format for the input image. If unset, the channel dimension format is inferred
from the input image. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
</ul>`,name:"input_data_format"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/image_processing_sam.py#L234",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The resized image.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>np.ndarray</code></p>
`}}),Re=new I({props:{title:"SamModel",local:"transformers.SamModel",headingTag:"h2"}}),Ee=new w({props:{name:"class transformers.SamModel",anchor:"transformers.SamModel",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.SamModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/sam#transformers.SamConfig">SamConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/modeling_sam.py#L1173"}}),qe=new w({props:{name:"forward",anchor:"transformers.SamModel.forward",parameters:[{name:"pixel_values",val:": Optional = None"},{name:"input_points",val:": Optional = None"},{name:"input_labels",val:": Optional = None"},{name:"input_boxes",val:": Optional = None"},{name:"input_masks",val:": Optional = None"},{name:"image_embeddings",val:": Optional = None"},{name:"multimask_output",val:": bool = True"},{name:"attention_similarity",val:": Optional = None"},{name:"target_embedding",val:": Optional = None"},{name:"output_attentions",val:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"return_dict",val:": Optional = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SamModel.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/sam#transformers.SamProcessor">SamProcessor</a>. See <code>SamProcessor.__call__()</code> for
details.`,name:"pixel_values"},{anchor:"transformers.SamModel.forward.input_points",description:`<strong>input_points</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_points, 2)</code>) &#x2014;
Input 2D spatial points, this is used by the prompt encoder to encode the prompt. Generally yields to much
better results. The points can be obtained by passing a list of list of list to the processor that will
create corresponding <code>torch</code> tensors of dimension 4. The first dimension is the image batch size, the
second dimension is the point batch size (i.e. how many segmentation masks do we want the model to predict
per input point), the third dimension is the number of points per segmentation mask (it is possible to pass
multiple points for a single mask), and the last dimension is the x (vertical) and y (horizontal)
coordinates of the point. If a different number of points is passed either for each image, or for each
mask, the processor will create &#x201C;PAD&#x201D; points that will correspond to the (0, 0) coordinate, and the
computation of the embedding will be skipped for these points using the labels.`,name:"input_points"},{anchor:"transformers.SamModel.forward.input_labels",description:`<strong>input_labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, point_batch_size, num_points)</code>) &#x2014;
Input labels for the points, this is used by the prompt encoder to encode the prompt. According to the
official implementation, there are 3 types of labels</p>
<ul>
<li><code>1</code>: the point is a point that contains the object of interest</li>
<li><code>0</code>: the point is a point that does not contain the object of interest</li>
<li><code>-1</code>: the point corresponds to the background</li>
</ul>
<p>We added the label:</p>
<ul>
<li><code>-10</code>: the point is a padding point, thus should be ignored by the prompt encoder</li>
</ul>
<p>The padding labels should be automatically done by the processor.`,name:"input_labels"},{anchor:"transformers.SamModel.forward.input_boxes",description:`<strong>input_boxes</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_boxes, 4)</code>) &#x2014;
Input boxes for the points, this is used by the prompt encoder to encode the prompt. Generally yields to
much better generated masks. The boxes can be obtained by passing a list of list of list to the processor,
that will generate a <code>torch</code> tensor, with each dimension corresponding respectively to the image batch
size, the number of boxes per image and the coordinates of the top left and botton right point of the box.
In the order (<code>x1</code>, <code>y1</code>, <code>x2</code>, <code>y2</code>):</p>
<ul>
<li><code>x1</code>: the x coordinate of the top left point of the input box</li>
<li><code>y1</code>: the y coordinate of the top left point of the input box</li>
<li><code>x2</code>: the x coordinate of the bottom right point of the input box</li>
<li><code>y2</code>: the y coordinate of the bottom right point of the input box</li>
</ul>`,name:"input_boxes"},{anchor:"transformers.SamModel.forward.input_masks",description:`<strong>input_masks</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, image_size, image_size)</code>) &#x2014;
SAM model also accepts segmentation masks as input. The mask will be embedded by the prompt encoder to
generate a corresponding embedding, that will be fed later on to the mask decoder. These masks needs to be
manually fed by the user, and they need to be of shape (<code>batch_size</code>, <code>image_size</code>, <code>image_size</code>).`,name:"input_masks"},{anchor:"transformers.SamModel.forward.image_embeddings",description:`<strong>image_embeddings</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, output_channels, window_size, window_size)</code>) &#x2014;
Image embeddings, this is used by the mask decder to generate masks and iou scores. For more memory
efficient computation, users can first retrieve the image embeddings using the <code>get_image_embeddings</code>
method, and then feed them to the <code>forward</code> method instead of feeding the <code>pixel_values</code>.`,name:"image_embeddings"},{anchor:"transformers.SamModel.forward.multimask_output",description:`<strong>multimask_output</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
In the original implementation and paper, the model always outputs 3 masks per image (or per point / per
bounding box if relevant). However, it is possible to just output a single mask, that corresponds to the
&#x201C;best&#x201D; mask, by specifying <code>multimask_output=False</code>.`,name:"multimask_output"},{anchor:"transformers.SamModel.forward.attention_similarity",description:`<strong>attention_similarity</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Attention similarity tensor, to be provided to the mask decoder for target-guided attention in case the
model is used for personalization as introduced in <a href="https://arxiv.org/abs/2305.03048" rel="nofollow">PerSAM</a>.`,name:"attention_similarity"},{anchor:"transformers.SamModel.forward.target_embedding",description:`<strong>target_embedding</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Embedding of the target concept, to be provided to the mask decoder for target-semantic prompting in case
the model is used for personalization as introduced in <a href="https://arxiv.org/abs/2305.03048" rel="nofollow">PerSAM</a>.`,name:"target_embedding"},{anchor:"transformers.SamModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.SamModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.SamModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.</p>
<p>Example &#x2014;`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/modeling_sam.py#L1271"}}),Q=new Vn({props:{$$slots:{default:[ea]},$$scope:{ctx:R}}}),Ve=new I({props:{title:"TFSamModel",local:"transformers.TFSamModel",headingTag:"h2"}}),Ae=new w({props:{name:"class transformers.TFSamModel",anchor:"transformers.TFSamModel",parameters:[{name:"config",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFSamModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/sam#transformers.SamConfig">SamConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/modeling_tf_sam.py#L1402"}}),Fe=new w({props:{name:"call",anchor:"transformers.TFSamModel.call",parameters:[{name:"pixel_values",val:": TFModelInputType | None = None"},{name:"input_points",val:": tf.Tensor | None = None"},{name:"input_labels",val:": tf.Tensor | None = None"},{name:"input_boxes",val:": tf.Tensor | None = None"},{name:"input_masks",val:": tf.Tensor | None = None"},{name:"image_embeddings",val:": tf.Tensor | None = None"},{name:"multimask_output",val:": bool = True"},{name:"output_attentions",val:": bool | None = None"},{name:"output_hidden_states",val:": bool | None = None"},{name:"return_dict",val:": bool | None = None"},{name:"training",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFSamModel.call.pixel_values",description:`<strong>pixel_values</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/sam#transformers.SamProcessor">SamProcessor</a>. See <code>SamProcessor.__call__()</code> for
details.`,name:"pixel_values"},{anchor:"transformers.TFSamModel.call.input_points",description:`<strong>input_points</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, num_points, 2)</code>) &#x2014;
Input 2D spatial points, this is used by the prompt encoder to encode the prompt. Generally yields to much
better results. The points can be obtained by passing a list of list of list to the processor that will
create corresponding <code>tf</code> tensors of dimension 4. The first dimension is the image batch size, the second
dimension is the point batch size (i.e. how many segmentation masks do we want the model to predict per
input point), the third dimension is the number of points per segmentation mask (it is possible to pass
multiple points for a single mask), and the last dimension is the x (vertical) and y (horizontal)
coordinates of the point. If a different number of points is passed either for each image, or for each
mask, the processor will create &#x201C;PAD&#x201D; points that will correspond to the (0, 0) coordinate, and the
computation of the embedding will be skipped for these points using the labels.`,name:"input_points"},{anchor:"transformers.TFSamModel.call.input_labels",description:`<strong>input_labels</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, point_batch_size, num_points)</code>) &#x2014;
Input labels for the points, this is used by the prompt encoder to encode the prompt. According to the
official implementation, there are 3 types of labels</p>
<ul>
<li><code>1</code>: the point is a point that contains the object of interest</li>
<li><code>0</code>: the point is a point that does not contain the object of interest</li>
<li><code>-1</code>: the point corresponds to the background</li>
</ul>
<p>We added the label:</p>
<ul>
<li><code>-10</code>: the point is a padding point, thus should be ignored by the prompt encoder</li>
</ul>
<p>The padding labels should be automatically done by the processor.`,name:"input_labels"},{anchor:"transformers.TFSamModel.call.input_boxes",description:`<strong>input_boxes</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, num_boxes, 4)</code>) &#x2014;
Input boxes for the points, this is used by the prompt encoder to encode the prompt. Generally yields to
much better generated masks. The boxes can be obtained by passing a list of list of list to the processor,
that will generate a <code>tf</code> tensor, with each dimension corresponding respectively to the image batch size,
the number of boxes per image and the coordinates of the top left and botton right point of the box. In the
order (<code>x1</code>, <code>y1</code>, <code>x2</code>, <code>y2</code>):</p>
<ul>
<li><code>x1</code>: the x coordinate of the top left point of the input box</li>
<li><code>y1</code>: the y coordinate of the top left point of the input box</li>
<li><code>x2</code>: the x coordinate of the bottom right point of the input box</li>
<li><code>y2</code>: the y coordinate of the bottom right point of the input box</li>
</ul>`,name:"input_boxes"},{anchor:"transformers.TFSamModel.call.input_masks",description:`<strong>input_masks</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, image_size, image_size)</code>) &#x2014;
SAM model also accepts segmentation masks as input. The mask will be embedded by the prompt encoder to
generate a corresponding embedding, that will be fed later on to the mask decoder. These masks needs to be
manually fed by the user, and they need to be of shape (<code>batch_size</code>, <code>image_size</code>, <code>image_size</code>).`,name:"input_masks"},{anchor:"transformers.TFSamModel.call.image_embeddings",description:`<strong>image_embeddings</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, output_channels, window_size, window_size)</code>) &#x2014;
Image embeddings, this is used by the mask decder to generate masks and iou scores. For more memory
efficient computation, users can first retrieve the image embeddings using the <code>get_image_embeddings</code>
method, and then feed them to the <code>call</code> method instead of feeding the <code>pixel_values</code>.`,name:"image_embeddings"},{anchor:"transformers.TFSamModel.call.multimask_output",description:`<strong>multimask_output</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
In the original implementation and paper, the model always outputs 3 masks per image (or per point / per
bounding box if relevant). However, it is possible to just output a single mask, that corresponds to the
&#x201C;best&#x201D; mask, by specifying <code>multimask_output=False</code>.`,name:"multimask_output"},{anchor:"transformers.TFSamModel.call.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.TFSamModel.call.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.TFSamModel.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/sam/modeling_tf_sam.py#L1497"}}),O=new Vn({props:{$$slots:{default:[oa]},$$scope:{ctx:R}}}),He=new On({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/sam.md"}}),{c(){u=i("meta"),x=n(),b=i("p"),S=n(),l(C.$$.fragment),y=n(),l(j.$$.fragment),So=n(),oe=i("p"),oe.innerHTML=tn,xo=n(),te=i("p"),te.textContent=nn,ko=n(),ne=i("p"),ne.innerHTML=an,zo=n(),ae=i("p"),ae.textContent=sn,$o=n(),se=i("p"),se.innerHTML=rn,Io=n(),re=i("p"),re.textContent=mn,Co=n(),ie=i("ul"),ie.innerHTML=dn,jo=n(),me=i("p"),me.innerHTML=ln,Po=n(),de=i("p"),de.textContent=cn,Jo=n(),l(le.$$.fragment),No=n(),ce=i("p"),ce.textContent=pn,Uo=n(),l(pe.$$.fragment),Wo=n(),l(he.$$.fragment),Zo=n(),ge=i("p"),ge.textContent=hn,Lo=n(),fe=i("ul"),fe.innerHTML=gn,Do=n(),l(ue.$$.fragment),Bo=n(),_e=i("p"),_e.innerHTML=fn,Ro=n(),be=i("p"),be.innerHTML=un,Eo=n(),l(ve.$$.fragment),qo=n(),ye=i("p"),ye.innerHTML=_n,Vo=n(),E=i("img"),Ao=n(),Me=i("small"),Me.innerHTML=vn,Fo=n(),l(Te.$$.fragment),Ho=n(),k=i("div"),l(we.$$.fragment),bt=n(),Ge=i("p"),Ge.innerHTML=yn,vt=n(),Xe=i("p"),Xe.innerHTML=Mn,yt=n(),l(q.$$.fragment),Go=n(),l(Se.$$.fragment),Xo=n(),P=i("div"),l(xe.$$.fragment),Mt=n(),Ye=i("p"),Ye.innerHTML=Tn,Tt=n(),Qe=i("p"),Qe.innerHTML=wn,Yo=n(),l(ke.$$.fragment),Qo=n(),J=i("div"),l(ze.$$.fragment),wt=n(),Oe=i("p"),Oe.innerHTML=Sn,St=n(),Ke=i("p"),Ke.innerHTML=xn,Oo=n(),l($e.$$.fragment),Ko=n(),N=i("div"),l(Ie.$$.fragment),xt=n(),eo=i("p"),eo.innerHTML=kn,kt=n(),oo=i("p"),oo.innerHTML=zn,et=n(),l(Ce.$$.fragment),ot=n(),U=i("div"),l(je.$$.fragment),zt=n(),to=i("p"),to.textContent=$n,$t=n(),no=i("p"),no.innerHTML=In,tt=n(),l(Pe.$$.fragment),nt=n(),_=i("div"),l(Je.$$.fragment),It=n(),ao=i("p"),ao.textContent=Cn,Ct=n(),V=i("div"),l(Ne.$$.fragment),jt=n(),so=i("p"),so.innerHTML=jn,Pt=n(),A=i("div"),l(Ue.$$.fragment),Jt=n(),ro=i("p"),ro.innerHTML=Pn,Nt=n(),F=i("div"),l(We.$$.fragment),Ut=n(),io=i("p"),io.innerHTML=Jn,Wt=n(),H=i("div"),l(Ze.$$.fragment),Zt=n(),mo=i("p"),mo.textContent=Nn,Lt=n(),G=i("div"),l(Le.$$.fragment),Dt=n(),lo=i("p"),lo.textContent=Un,Bt=n(),X=i("div"),l(De.$$.fragment),Rt=n(),co=i("p"),co.textContent=Wn,Et=n(),Y=i("div"),l(Be.$$.fragment),qt=n(),po=i("p"),po.innerHTML=Zn,at=n(),l(Re.$$.fragment),st=n(),z=i("div"),l(Ee.$$.fragment),Vt=n(),ho=i("p"),ho.innerHTML=Ln,At=n(),go=i("p"),go.innerHTML=Dn,Ft=n(),Z=i("div"),l(qe.$$.fragment),Ht=n(),fo=i("p"),fo.innerHTML=Bn,Gt=n(),l(Q.$$.fragment),rt=n(),l(Ve.$$.fragment),it=n(),$=i("div"),l(Ae.$$.fragment),Xt=n(),uo=i("p"),uo.innerHTML=Rn,Yt=n(),_o=i("p"),_o.innerHTML=En,Qt=n(),L=i("div"),l(Fe.$$.fragment),Ot=n(),bo=i("p"),bo.innerHTML=qn,Kt=n(),l(O.$$.fragment),mt=n(),l(He.$$.fragment),dt=n(),wo=i("p"),this.h()},l(e){const o=Yn("svelte-u9bgzb",document.head);u=m(o,"META",{name:!0,content:!0}),o.forEach(t),x=a(e),b=m(e,"P",{}),M(b).forEach(t),S=a(e),c(C.$$.fragment,e),y=a(e),c(j.$$.fragment,e),So=a(e),oe=m(e,"P",{"data-svelte-h":!0}),d(oe)!=="svelte-gruntp"&&(oe.innerHTML=tn),xo=a(e),te=m(e,"P",{"data-svelte-h":!0}),d(te)!=="svelte-lkoryj"&&(te.textContent=nn),ko=a(e),ne=m(e,"P",{"data-svelte-h":!0}),d(ne)!=="svelte-8e5g7x"&&(ne.innerHTML=an),zo=a(e),ae=m(e,"P",{"data-svelte-h":!0}),d(ae)!=="svelte-vfdo9a"&&(ae.textContent=sn),$o=a(e),se=m(e,"P",{"data-svelte-h":!0}),d(se)!=="svelte-1o5y69o"&&(se.innerHTML=rn),Io=a(e),re=m(e,"P",{"data-svelte-h":!0}),d(re)!=="svelte-axv494"&&(re.textContent=mn),Co=a(e),ie=m(e,"UL",{"data-svelte-h":!0}),d(ie)!=="svelte-2bykq2"&&(ie.innerHTML=dn),jo=a(e),me=m(e,"P",{"data-svelte-h":!0}),d(me)!=="svelte-3s0ihy"&&(me.innerHTML=ln),Po=a(e),de=m(e,"P",{"data-svelte-h":!0}),d(de)!=="svelte-j41zpc"&&(de.textContent=cn),Jo=a(e),c(le.$$.fragment,e),No=a(e),ce=m(e,"P",{"data-svelte-h":!0}),d(ce)!=="svelte-eylhz1"&&(ce.textContent=pn),Uo=a(e),c(pe.$$.fragment,e),Wo=a(e),c(he.$$.fragment,e),Zo=a(e),ge=m(e,"P",{"data-svelte-h":!0}),d(ge)!=="svelte-r7mpci"&&(ge.textContent=hn),Lo=a(e),fe=m(e,"UL",{"data-svelte-h":!0}),d(fe)!=="svelte-su2mt3"&&(fe.innerHTML=gn),Do=a(e),c(ue.$$.fragment,e),Bo=a(e),_e=m(e,"P",{"data-svelte-h":!0}),d(_e)!=="svelte-a4zcm8"&&(_e.innerHTML=fn),Ro=a(e),be=m(e,"P",{"data-svelte-h":!0}),d(be)!=="svelte-1kuacy9"&&(be.innerHTML=un),Eo=a(e),c(ve.$$.fragment,e),qo=a(e),ye=m(e,"P",{"data-svelte-h":!0}),d(ye)!=="svelte-iwaemq"&&(ye.innerHTML=_n),Vo=a(e),E=m(e,"IMG",{src:!0,alt:!0,width:!0}),Ao=a(e),Me=m(e,"SMALL",{"data-svelte-h":!0}),d(Me)!=="svelte-16zie7b"&&(Me.innerHTML=vn),Fo=a(e),c(Te.$$.fragment,e),Ho=a(e),k=m(e,"DIV",{class:!0});var W=M(k);c(we.$$.fragment,W),bt=a(W),Ge=m(W,"P",{"data-svelte-h":!0}),d(Ge)!=="svelte-1biooea"&&(Ge.innerHTML=yn),vt=a(W),Xe=m(W,"P",{"data-svelte-h":!0}),d(Xe)!=="svelte-o55m63"&&(Xe.innerHTML=Mn),yt=a(W),c(q.$$.fragment,W),W.forEach(t),Go=a(e),c(Se.$$.fragment,e),Xo=a(e),P=m(e,"DIV",{class:!0});var D=M(P);c(xe.$$.fragment,D),Mt=a(D),Ye=m(D,"P",{"data-svelte-h":!0}),d(Ye)!=="svelte-1f0ysan"&&(Ye.innerHTML=Tn),Tt=a(D),Qe=m(D,"P",{"data-svelte-h":!0}),d(Qe)!=="svelte-o55m63"&&(Qe.innerHTML=wn),D.forEach(t),Yo=a(e),c(ke.$$.fragment,e),Qo=a(e),J=m(e,"DIV",{class:!0});var B=M(J);c(ze.$$.fragment,B),wt=a(B),Oe=m(B,"P",{"data-svelte-h":!0}),d(Oe)!=="svelte-c8g7g5"&&(Oe.innerHTML=Sn),St=a(B),Ke=m(B,"P",{"data-svelte-h":!0}),d(Ke)!=="svelte-o55m63"&&(Ke.innerHTML=xn),B.forEach(t),Oo=a(e),c($e.$$.fragment,e),Ko=a(e),N=m(e,"DIV",{class:!0});var vo=M(N);c(Ie.$$.fragment,vo),xt=a(vo),eo=m(vo,"P",{"data-svelte-h":!0}),d(eo)!=="svelte-y6v7jy"&&(eo.innerHTML=kn),kt=a(vo),oo=m(vo,"P",{"data-svelte-h":!0}),d(oo)!=="svelte-o55m63"&&(oo.innerHTML=zn),vo.forEach(t),et=a(e),c(Ce.$$.fragment,e),ot=a(e),U=m(e,"DIV",{class:!0});var yo=M(U);c(je.$$.fragment,yo),zt=a(yo),to=m(yo,"P",{"data-svelte-h":!0}),d(to)!=="svelte-i07qcs"&&(to.textContent=$n),$t=a(yo),no=m(yo,"P",{"data-svelte-h":!0}),d(no)!=="svelte-1klukek"&&(no.innerHTML=In),yo.forEach(t),tt=a(e),c(Pe.$$.fragment,e),nt=a(e),_=m(e,"DIV",{class:!0});var T=M(_);c(Je.$$.fragment,T),It=a(T),ao=m(T,"P",{"data-svelte-h":!0}),d(ao)!=="svelte-iyanpn"&&(ao.textContent=Cn),Ct=a(T),V=m(T,"DIV",{class:!0});var ct=M(V);c(Ne.$$.fragment,ct),jt=a(ct),so=m(ct,"P",{"data-svelte-h":!0}),d(so)!=="svelte-jpa0fq"&&(so.innerHTML=jn),ct.forEach(t),Pt=a(T),A=m(T,"DIV",{class:!0});var pt=M(A);c(Ue.$$.fragment,pt),Jt=a(pt),ro=m(pt,"P",{"data-svelte-h":!0}),d(ro)!=="svelte-1j7xts3"&&(ro.innerHTML=Pn),pt.forEach(t),Nt=a(T),F=m(T,"DIV",{class:!0});var ht=M(F);c(We.$$.fragment,ht),Ut=a(ht),io=m(ht,"P",{"data-svelte-h":!0}),d(io)!=="svelte-1g2f7kg"&&(io.innerHTML=Jn),ht.forEach(t),Wt=a(T),H=m(T,"DIV",{class:!0});var gt=M(H);c(Ze.$$.fragment,gt),Zt=a(gt),mo=m(gt,"P",{"data-svelte-h":!0}),d(mo)!=="svelte-wwrho9"&&(mo.textContent=Nn),gt.forEach(t),Lt=a(T),G=m(T,"DIV",{class:!0});var ft=M(G);c(Le.$$.fragment,ft),Dt=a(ft),lo=m(ft,"P",{"data-svelte-h":!0}),d(lo)!=="svelte-juomob"&&(lo.textContent=Un),ft.forEach(t),Bt=a(T),X=m(T,"DIV",{class:!0});var ut=M(X);c(De.$$.fragment,ut),Rt=a(ut),co=m(ut,"P",{"data-svelte-h":!0}),d(co)!=="svelte-1x3yxsa"&&(co.textContent=Wn),ut.forEach(t),Et=a(T),Y=m(T,"DIV",{class:!0});var _t=M(Y);c(Be.$$.fragment,_t),qt=a(_t),po=m(_t,"P",{"data-svelte-h":!0}),d(po)!=="svelte-1oee9wu"&&(po.innerHTML=Zn),_t.forEach(t),T.forEach(t),at=a(e),c(Re.$$.fragment,e),st=a(e),z=m(e,"DIV",{class:!0});var K=M(z);c(Ee.$$.fragment,K),Vt=a(K),ho=m(K,"P",{"data-svelte-h":!0}),d(ho)!=="svelte-13sbmu3"&&(ho.innerHTML=Ln),At=a(K),go=m(K,"P",{"data-svelte-h":!0}),d(go)!=="svelte-hswkmf"&&(go.innerHTML=Dn),Ft=a(K),Z=m(K,"DIV",{class:!0});var Mo=M(Z);c(qe.$$.fragment,Mo),Ht=a(Mo),fo=m(Mo,"P",{"data-svelte-h":!0}),d(fo)!=="svelte-1wwqxlg"&&(fo.innerHTML=Bn),Gt=a(Mo),c(Q.$$.fragment,Mo),Mo.forEach(t),K.forEach(t),rt=a(e),c(Ve.$$.fragment,e),it=a(e),$=m(e,"DIV",{class:!0});var ee=M($);c(Ae.$$.fragment,ee),Xt=a(ee),uo=m(ee,"P",{"data-svelte-h":!0}),d(uo)!=="svelte-1qudda3"&&(uo.innerHTML=Rn),Yt=a(ee),_o=m(ee,"P",{"data-svelte-h":!0}),d(_o)!=="svelte-224cht"&&(_o.innerHTML=En),Qt=a(ee),L=m(ee,"DIV",{class:!0});var To=M(L);c(Fe.$$.fragment,To),Ot=a(To),bo=m(To,"P",{"data-svelte-h":!0}),d(bo)!=="svelte-1dnqt04"&&(bo.innerHTML=qn),Kt=a(To),c(O.$$.fragment,To),To.forEach(t),ee.forEach(t),mt=a(e),c(He.$$.fragment,e),dt=a(e),wo=m(e,"P",{}),M(wo).forEach(t),this.h()},h(){v(u,"name","hf:doc:metadata"),v(u,"content",na),Fn(E.src,bn="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/grounded_sam.png")||v(E,"src",bn),v(E,"alt","drawing"),v(E,"width","900"),v(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(Y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(_,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v($,"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,o){r(document.head,u),s(e,x,o),s(e,b,o),s(e,S,o),p(C,e,o),s(e,y,o),p(j,e,o),s(e,So,o),s(e,oe,o),s(e,xo,o),s(e,te,o),s(e,ko,o),s(e,ne,o),s(e,zo,o),s(e,ae,o),s(e,$o,o),s(e,se,o),s(e,Io,o),s(e,re,o),s(e,Co,o),s(e,ie,o),s(e,jo,o),s(e,me,o),s(e,Po,o),s(e,de,o),s(e,Jo,o),p(le,e,o),s(e,No,o),s(e,ce,o),s(e,Uo,o),p(pe,e,o),s(e,Wo,o),p(he,e,o),s(e,Zo,o),s(e,ge,o),s(e,Lo,o),s(e,fe,o),s(e,Do,o),p(ue,e,o),s(e,Bo,o),s(e,_e,o),s(e,Ro,o),s(e,be,o),s(e,Eo,o),p(ve,e,o),s(e,qo,o),s(e,ye,o),s(e,Vo,o),s(e,E,o),s(e,Ao,o),s(e,Me,o),s(e,Fo,o),p(Te,e,o),s(e,Ho,o),s(e,k,o),p(we,k,null),r(k,bt),r(k,Ge),r(k,vt),r(k,Xe),r(k,yt),p(q,k,null),s(e,Go,o),p(Se,e,o),s(e,Xo,o),s(e,P,o),p(xe,P,null),r(P,Mt),r(P,Ye),r(P,Tt),r(P,Qe),s(e,Yo,o),p(ke,e,o),s(e,Qo,o),s(e,J,o),p(ze,J,null),r(J,wt),r(J,Oe),r(J,St),r(J,Ke),s(e,Oo,o),p($e,e,o),s(e,Ko,o),s(e,N,o),p(Ie,N,null),r(N,xt),r(N,eo),r(N,kt),r(N,oo),s(e,et,o),p(Ce,e,o),s(e,ot,o),s(e,U,o),p(je,U,null),r(U,zt),r(U,to),r(U,$t),r(U,no),s(e,tt,o),p(Pe,e,o),s(e,nt,o),s(e,_,o),p(Je,_,null),r(_,It),r(_,ao),r(_,Ct),r(_,V),p(Ne,V,null),r(V,jt),r(V,so),r(_,Pt),r(_,A),p(Ue,A,null),r(A,Jt),r(A,ro),r(_,Nt),r(_,F),p(We,F,null),r(F,Ut),r(F,io),r(_,Wt),r(_,H),p(Ze,H,null),r(H,Zt),r(H,mo),r(_,Lt),r(_,G),p(Le,G,null),r(G,Dt),r(G,lo),r(_,Bt),r(_,X),p(De,X,null),r(X,Rt),r(X,co),r(_,Et),r(_,Y),p(Be,Y,null),r(Y,qt),r(Y,po),s(e,at,o),p(Re,e,o),s(e,st,o),s(e,z,o),p(Ee,z,null),r(z,Vt),r(z,ho),r(z,At),r(z,go),r(z,Ft),r(z,Z),p(qe,Z,null),r(Z,Ht),r(Z,fo),r(Z,Gt),p(Q,Z,null),s(e,rt,o),p(Ve,e,o),s(e,it,o),s(e,$,o),p(Ae,$,null),r($,Xt),r($,uo),r($,Yt),r($,_o),r($,Qt),r($,L),p(Fe,L,null),r(L,Ot),r(L,bo),r(L,Kt),p(O,L,null),s(e,mt,o),p(He,e,o),s(e,dt,o),s(e,wo,o),lt=!0},p(e,[o]){const W={};o&2&&(W.$$scope={dirty:o,ctx:e}),q.$set(W);const D={};o&2&&(D.$$scope={dirty:o,ctx:e}),Q.$set(D);const B={};o&2&&(B.$$scope={dirty:o,ctx:e}),O.$set(B)},i(e){lt||(h(C.$$.fragment,e),h(j.$$.fragment,e),h(le.$$.fragment,e),h(pe.$$.fragment,e),h(he.$$.fragment,e),h(ue.$$.fragment,e),h(ve.$$.fragment,e),h(Te.$$.fragment,e),h(we.$$.fragment,e),h(q.$$.fragment,e),h(Se.$$.fragment,e),h(xe.$$.fragment,e),h(ke.$$.fragment,e),h(ze.$$.fragment,e),h($e.$$.fragment,e),h(Ie.$$.fragment,e),h(Ce.$$.fragment,e),h(je.$$.fragment,e),h(Pe.$$.fragment,e),h(Je.$$.fragment,e),h(Ne.$$.fragment,e),h(Ue.$$.fragment,e),h(We.$$.fragment,e),h(Ze.$$.fragment,e),h(Le.$$.fragment,e),h(De.$$.fragment,e),h(Be.$$.fragment,e),h(Re.$$.fragment,e),h(Ee.$$.fragment,e),h(qe.$$.fragment,e),h(Q.$$.fragment,e),h(Ve.$$.fragment,e),h(Ae.$$.fragment,e),h(Fe.$$.fragment,e),h(O.$$.fragment,e),h(He.$$.fragment,e),lt=!0)},o(e){g(C.$$.fragment,e),g(j.$$.fragment,e),g(le.$$.fragment,e),g(pe.$$.fragment,e),g(he.$$.fragment,e),g(ue.$$.fragment,e),g(ve.$$.fragment,e),g(Te.$$.fragment,e),g(we.$$.fragment,e),g(q.$$.fragment,e),g(Se.$$.fragment,e),g(xe.$$.fragment,e),g(ke.$$.fragment,e),g(ze.$$.fragment,e),g($e.$$.fragment,e),g(Ie.$$.fragment,e),g(Ce.$$.fragment,e),g(je.$$.fragment,e),g(Pe.$$.fragment,e),g(Je.$$.fragment,e),g(Ne.$$.fragment,e),g(Ue.$$.fragment,e),g(We.$$.fragment,e),g(Ze.$$.fragment,e),g(Le.$$.fragment,e),g(De.$$.fragment,e),g(Be.$$.fragment,e),g(Re.$$.fragment,e),g(Ee.$$.fragment,e),g(qe.$$.fragment,e),g(Q.$$.fragment,e),g(Ve.$$.fragment,e),g(Ae.$$.fragment,e),g(Fe.$$.fragment,e),g(O.$$.fragment,e),g(He.$$.fragment,e),lt=!1},d(e){e&&(t(x),t(b),t(S),t(y),t(So),t(oe),t(xo),t(te),t(ko),t(ne),t(zo),t(ae),t($o),t(se),t(Io),t(re),t(Co),t(ie),t(jo),t(me),t(Po),t(de),t(Jo),t(No),t(ce),t(Uo),t(Wo),t(Zo),t(ge),t(Lo),t(fe),t(Do),t(Bo),t(_e),t(Ro),t(be),t(Eo),t(qo),t(ye),t(Vo),t(E),t(Ao),t(Me),t(Fo),t(Ho),t(k),t(Go),t(Xo),t(P),t(Yo),t(Qo),t(J),t(Oo),t(Ko),t(N),t(et),t(ot),t(U),t(tt),t(nt),t(_),t(at),t(st),t(z),t(rt),t(it),t($),t(mt),t(dt),t(wo)),t(u),f(C,e),f(j,e),f(le,e),f(pe,e),f(he,e),f(ue,e),f(ve,e),f(Te,e),f(we),f(q),f(Se,e),f(xe),f(ke,e),f(ze),f($e,e),f(Ie),f(Ce,e),f(je),f(Pe,e),f(Je),f(Ne),f(Ue),f(We),f(Ze),f(Le),f(De),f(Be),f(Re,e),f(Ee),f(qe),f(Q),f(Ve,e),f(Ae),f(Fe),f(O),f(He,e)}}}const na='{"title":"SAM","local":"sam","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Resources","local":"resources","sections":[],"depth":2},{"title":"SlimSAM","local":"slimsam","sections":[],"depth":2},{"title":"Grounded SAM","local":"grounded-sam","sections":[],"depth":2},{"title":"SamConfig","local":"transformers.SamConfig","sections":[],"depth":2},{"title":"SamVisionConfig","local":"transformers.SamVisionConfig","sections":[],"depth":2},{"title":"SamMaskDecoderConfig","local":"transformers.SamMaskDecoderConfig","sections":[],"depth":2},{"title":"SamPromptEncoderConfig","local":"transformers.SamPromptEncoderConfig","sections":[],"depth":2},{"title":"SamProcessor","local":"transformers.SamProcessor","sections":[],"depth":2},{"title":"SamImageProcessor","local":"transformers.SamImageProcessor","sections":[],"depth":2},{"title":"SamModel","local":"transformers.SamModel","sections":[],"depth":2},{"title":"TFSamModel","local":"transformers.TFSamModel","sections":[],"depth":2}],"depth":1}';function aa(R){return Hn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class pa extends Gn{constructor(u){super(),Xn(this,u,aa,ta,An,{})}}export{pa as component};
