import{s as Re,o as qe,n as Ae}from"../chunks/scheduler.56725da7.js";import{S as Se,i as Ye,e as c,s as a,c as d,h as Qe,a as m,d as n,b as s,f as ae,g as u,j as J,k as S,l as p,m as l,n as h,t as g,o as f,p as M}from"../chunks/index.18a26576.js";import{C as De}from"../chunks/CopyLLMTxtMenu.f4001e5e.js";import{D as Te}from"../chunks/Docstring.185d8bd7.js";import{C as Je}from"../chunks/CodeBlock.e59f1853.js";import{E as He}from"../chunks/ExampleCodeBlock.09e85aaa.js";import{H as Y}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.d7e7b6b3.js";function Ke(Q){let r,v="Example:",w,i,b;return i=new Je({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMEFmcm9tJTIwb3B0aW11bS5uZXVyb24lMjBpbXBvcnQlMjBOZXVyb25DTElQTW9kZWwlMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJvcHRpbXVtJTJGY2xpcC12aXQtYmFzZS1wYXRjaDMyLW5ldXJvbnglMjIpJTBBbW9kZWwlMjAlM0QlMjBOZXVyb25DTElQTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMm9wdGltdW0lMkZjbGlwLXZpdC1iYXNlLXBhdGNoMzItbmV1cm9ueCUyMiklMEElMEF1cmwlMjAlM0QlMjAlMjJodHRwJTNBJTJGJTJGaW1hZ2VzLmNvY29kYXRhc2V0Lm9yZyUyRnZhbDIwMTclMkYwMDAwMDAwMzk3NjkuanBnJTIyJTBBaW1hZ2UlMjAlM0QlMjBJbWFnZS5vcGVuKHJlcXVlc3RzLmdldCh1cmwlMkMlMjBzdHJlYW0lM0RUcnVlKS5yYXcpJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKHRleHQlM0QlNUIlMjJhJTIwcGhvdG8lMjBvZiUyMGElMjBjYXQlMjIlMkMlMjAlMjJhJTIwcGhvdG8lMjBvZiUyMGElMjBkb2clMjIlNUQlMkMlMjBpbWFnZXMlM0RpbWFnZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIlMkMlMjBwYWRkaW5nJTNEVHJ1ZSklMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpJTBBbG9naXRzX3Blcl9pbWFnZSUyMCUzRCUyMG91dHB1dHMubG9naXRzX3Blcl9pbWFnZSUyMCUyMCUyMyUyMHRoaXMlMjBpcyUyMHRoZSUyMGltYWdlLXRleHQlMjBzaW1pbGFyaXR5JTIwc2NvcmUlMEFwcm9icyUyMCUzRCUyMGxvZ2l0c19wZXJfaW1hZ2Uuc29mdG1heChkaW0lM0QxKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> optimum.neuron <span class="hljs-keyword">import</span> NeuronCLIPModel

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;optimum/clip-vit-base-patch32-neuronx&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = NeuronCLIPModel.from_pretrained(<span class="hljs-string">&quot;optimum/clip-vit-base-patch32-neuronx&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(text=[<span class="hljs-string">&quot;a photo of a cat&quot;</span>, <span class="hljs-string">&quot;a photo of a dog&quot;</span>], images=image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>, padding=<span class="hljs-literal">True</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits_per_image = outputs.logits_per_image  <span class="hljs-comment"># this is the image-text similarity score</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>probs = logits_per_image.softmax(dim=<span class="hljs-number">1</span>)`,wrap:!1}}),{c(){r=c("p"),r.textContent=v,w=a(),d(i.$$.fragment)},l(o){r=m(o,"P",{"data-svelte-h":!0}),J(r)!=="svelte-11lpom8"&&(r.textContent=v),w=s(o),u(i.$$.fragment,o)},m(o,j){l(o,r,j),l(o,w,j),h(i,o,j),b=!0},p:Ae,i(o){b||(g(i.$$.fragment,o),b=!0)},o(o){f(i.$$.fragment,o),b=!1},d(o){o&&(n(r),n(w)),M(i,o)}}}function Oe(Q){let r,v="Example:",w,i,b;return i=new Je({props:{code:"aW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFmcm9tJTIwb3B0aW11bS5uZXVyb24lMjBpbXBvcnQlMjBOZXVyb25DTElQRm9ySW1hZ2VDbGFzc2lmaWNhdGlvbiUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBBdXRvSW1hZ2VQcm9jZXNzb3IlMEElMEF1cmwlMjAlM0QlMjAlMjJodHRwJTNBJTJGJTJGaW1hZ2VzLmNvY29kYXRhc2V0Lm9yZyUyRnZhbDIwMTclMkYwMDAwMDAwMzk3NjkuanBnJTIyJTBBaW1hZ2UlMjAlM0QlMjBJbWFnZS5vcGVuKHJlcXVlc3RzLmdldCh1cmwlMkMlMjBzdHJlYW0lM0RUcnVlKS5yYXcpJTBBJTBBcHJlcHJvY2Vzc29yJTIwJTNEJTIwQXV0b0ltYWdlUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJvcHRpbXVtJTJGY2xpcC12aXQtYmFzZS1wYXRjaDMyLWltYWdlLWNsYXNzaWZpY2F0aW9uLW5ldXJvbnglMjIpJTBBbW9kZWwlMjAlM0QlMjBOZXVyb25DTElQRm9ySW1hZ2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIyb3B0aW11bSUyRmNsaXAtdml0LWJhc2UtcGF0Y2gzMi1pbWFnZS1jbGFzc2lmaWNhdGlvbi1uZXVyb254JTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMHByZXByb2Nlc3NvcihpbWFnZXMlM0RpbWFnZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQWxvZ2l0cyUyMCUzRCUyMG91dHB1dHMubG9naXRzJTBBcHJlZGljdGVkX2xhYmVsJTIwJTNEJTIwbG9naXRzLmFyZ21heCgtMSkuaXRlbSgp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> optimum.neuron <span class="hljs-keyword">import</span> NeuronCLIPForImageClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor

<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)

<span class="hljs-meta">&gt;&gt;&gt; </span>preprocessor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;optimum/clip-vit-base-patch32-image-classification-neuronx&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = NeuronCLIPForImageClassification.from_pretrained(<span class="hljs-string">&quot;optimum/clip-vit-base-patch32-image-classification-neuronx&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = preprocessor(images=image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_label = logits.argmax(-<span class="hljs-number">1</span>).item()`,wrap:!1}}),{c(){r=c("p"),r.textContent=v,w=a(),d(i.$$.fragment)},l(o){r=m(o,"P",{"data-svelte-h":!0}),J(r)!=="svelte-11lpom8"&&(r.textContent=v),w=s(o),u(i.$$.fragment,o)},m(o,j){l(o,r,j),l(o,w,j),h(i,o,j),b=!0},p:Ae,i(o){b||(g(i.$$.fragment,o),b=!0)},o(o){f(i.$$.fragment,o),b=!1},d(o){o&&(n(r),n(w)),M(i,o)}}}function et(Q){let r,v,w,i,b,o,j,le,B,re,X,Xe=`The CLIP model was proposed in <a href="https://arxiv.org/abs/2103.00020" rel="nofollow">Learning Transferable Visual Models From Natural Language Supervision</a> by Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh,
Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, Ilya Sutskever. CLIP
(Contrastive Language-Image Pre-Training) is a neural network trained on a variety of (image, text) pairs. It can be
instructed in natural language to predict the most relevant text snippet, given an image, without directly optimizing
for the task, similarly to the zero-shot capabilities of GPT-2 and 3.`,ie,W,pe,L,We='To deploy 🤗 <a href="https://huggingface.co/docs/transformers/index" rel="nofollow">Transformers</a> models on Neuron devices, you first need to compile the models and export them to a serialized format for inference. Below are two approaches to compile the model, you can choose the one that best suits your needs. Here we take the <code>feature-extraction</code> as an example:',ce,V,me,P,Le="You can export the model using the Optimum command-line interface as follows:",de,U,ue,N,Ve="<p>Execute <code>optimum-cli export neuron --help</code> to display all command line options and their description.</p>",he,G,ge,z,fe,E,Me,y,F,Ie,D,Pe="Bare CLIP Model without any specific head on top, used for the task “feature-extraction”.",ve,K,Ue=`This model inherits from <code>~neuron.modeling.NeuronTracedModel</code>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`,$e,$,H,_e,O,Ge="The <code>NeuronCLIPModel</code> forward method, overrides the <code>__call__</code> special method. Accepts only the inputs traced during the compilation step. Any additional inputs provided during inference will be ignored. To include extra inputs, recompile the model with those inputs specified.",Ce,x,be,A,we,T,R,Ne,ee,ze="CLIP vision encoder with an image classification head on top (a linear layer on top of the pooled final hidden states of the patch tokens) e.g. for ImageNet.",xe,te,Ee=`This model inherits from <code>~neuron.modeling.NeuronTracedModel</code>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`,ke,_,q,Ze,ne,Fe="The <code>NeuronCLIPForImageClassification</code> forward method, overrides the <code>__call__</code> special method. Accepts only the inputs traced during the compilation step. Any additional inputs provided during inference will be ignored. To include extra inputs, recompile the model with those inputs specified.",Be,k,je,se,ye;return b=new De({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),j=new Y({props:{title:"CLIP",local:"clip",headingTag:"h1"}}),B=new Y({props:{title:"Overview",local:"overview",headingTag:"h2"}}),W=new Y({props:{title:"Export to Neuron",local:"export-to-neuron",headingTag:"h2"}}),V=new Y({props:{title:"Option 1: CLI",local:"option-1-cli",headingTag:"h3"}}),U=new Je({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjBuZXVyb24lMjAtLW1vZGVsJTIwb3BlbmFpJTJGY2xpcC12aXQtYmFzZS1wYXRjaDMyJTIwLS10YXNrJTIwZmVhdHVyZS1leHRyYWN0aW9uJTIwLS10ZXh0X2JhdGNoX3NpemUlMjAyJTIwLS1zZXF1ZW5jZV9sZW5ndGglMjA3NyUyMC0taW1hZ2VfYmF0Y2hfc2l6ZSUyMDElMjAtLW51bV9jaGFubmVscyUyMDMlMjAtLXdpZHRoJTIwMjI0JTIwLS1oZWlnaHQlMjAyMjQlMjBjbGlwX2ZlYXR1cmVfZXh0cmFjdGlvbl9uZXVyb254JTJG",highlighted:'optimum-cli <span class="hljs-built_in">export</span> neuron --model openai/clip-vit-base-patch32 --task feature-extraction --text_batch_size 2 --sequence_length 77 --image_batch_size 1 --num_channels 3 --width 224 --height 224 clip_feature_extraction_neuronx/',wrap:!1}}),G=new Y({props:{title:"Option 2: Python API",local:"option-2-python-api",headingTag:"h3"}}),z=new Je({props:{code:"ZnJvbSUyMG9wdGltdW0ubmV1cm9uJTIwaW1wb3J0JTIwTmV1cm9uQ0xJUE1vZGVsJTBBJTBBaW5wdXRfc2hhcGVzJTIwJTNEJTIwJTdCJTIydGV4dF9iYXRjaF9zaXplJTIyJTNBJTIwMiUyQyUyMCUyMnNlcXVlbmNlX2xlbmd0aCUyMiUzQSUyMDc3JTJDJTIwJTIyaW1hZ2VfYmF0Y2hfc2l6ZSUyMiUzQSUyMDElMkMlMjAlMjJudW1fY2hhbm5lbHMlMjIlM0ElMjAzJTJDJTIwJTIyd2lkdGglMjIlM0ElMjAyMjQlMkMlMjAlMjJoZWlnaHQlMjIlM0ElMjAyMjQlN0QlMEFjb21waWxlcl9hcmdzJTIwJTNEJTIwJTdCJTIyYXV0b19jYXN0JTIyJTNBJTIwJTIybWF0bXVsJTIyJTJDJTIwJTIyYXV0b19jYXN0X3R5cGUlMjIlM0ElMjAlMjJiZjE2JTIyJTdEJTBBbmV1cm9uX21vZGVsJTIwJTNEJTIwTmV1cm9uQ0xJUE1vZGVsLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJvcGVuYWklMkZjbGlwLXZpdC1iYXNlLXBhdGNoMzIlMjIlMkMlMEElMjAlMjAlMjAlMjBleHBvcnQlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwKippbnB1dF9zaGFwZXMlMkMlMEElMjAlMjAlMjAlMjAqKmNvbXBpbGVyX2FyZ3MlMkMlMEEpJTBBJTIzJTIwU2F2ZSUyMGxvY2FsbHklMEFuZXVyb25fbW9kZWwuc2F2ZV9wcmV0cmFpbmVkKCUyMmNsaXBfZmVhdHVyZV9leHRyYWN0aW9uX25ldXJvbnglMkYlMjIpJTBBJTBBJTIzJTIwVXBsb2FkJTIwdG8lMjB0aGUlMjBIdWdnaW5nRmFjZSUyMEh1YiUwQW5ldXJvbl9tb2RlbC5wdXNoX3RvX2h1YiglMEElMjAlMjAlMjAlMjAlMjJjbGlwX2ZlYXR1cmVfZXh0cmFjdGlvbl9uZXVyb254JTJGJTIyJTJDJTIwcmVwb3NpdG9yeV9pZCUzRCUyMm9wdGltdW0lMkZjbGlwLXZpdC1iYXNlLXBhdGNoMzItbmV1cm9ueCUyMiUyMCUyMCUyMyUyMFJlcGxhY2UlMjB3aXRoJTIweW91ciUyMEhGJTIwSHViJTIwcmVwbyUyMGlkJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> optimum.neuron <span class="hljs-keyword">import</span> NeuronCLIPModel

input_shapes = {<span class="hljs-string">&quot;text_batch_size&quot;</span>: <span class="hljs-number">2</span>, <span class="hljs-string">&quot;sequence_length&quot;</span>: <span class="hljs-number">77</span>, <span class="hljs-string">&quot;image_batch_size&quot;</span>: <span class="hljs-number">1</span>, <span class="hljs-string">&quot;num_channels&quot;</span>: <span class="hljs-number">3</span>, <span class="hljs-string">&quot;width&quot;</span>: <span class="hljs-number">224</span>, <span class="hljs-string">&quot;height&quot;</span>: <span class="hljs-number">224</span>}
compiler_args = {<span class="hljs-string">&quot;auto_cast&quot;</span>: <span class="hljs-string">&quot;matmul&quot;</span>, <span class="hljs-string">&quot;auto_cast_type&quot;</span>: <span class="hljs-string">&quot;bf16&quot;</span>}
neuron_model = NeuronCLIPModel.from_pretrained(
    <span class="hljs-string">&quot;openai/clip-vit-base-patch32&quot;</span>,
    export=<span class="hljs-literal">True</span>,
    **input_shapes,
    **compiler_args,
)
<span class="hljs-comment"># Save locally</span>
neuron_model.save_pretrained(<span class="hljs-string">&quot;clip_feature_extraction_neuronx/&quot;</span>)

<span class="hljs-comment"># Upload to the HuggingFace Hub</span>
neuron_model.push_to_hub(
    <span class="hljs-string">&quot;clip_feature_extraction_neuronx/&quot;</span>, repository_id=<span class="hljs-string">&quot;optimum/clip-vit-base-patch32-neuronx&quot;</span>  <span class="hljs-comment"># Replace with your HF Hub repo id</span>
)`,wrap:!1}}),E=new Y({props:{title:"NeuronCLIPModel",local:"optimum.neuron.NeuronCLIPModel",headingTag:"h2"}}),F=new Te({props:{name:"class optimum.neuron.NeuronCLIPModel",anchor:"optimum.neuron.NeuronCLIPModel",parameters:[{name:"model",val:": ScriptModule"},{name:"config",val:": PretrainedConfig"},{name:"model_save_dir",val:": str | pathlib.Path | tempfile.TemporaryDirectory | None = None"},{name:"model_file_name",val:": str | None = None"},{name:"preprocessors",val:": list | None = None"},{name:"neuron_config",val:": NeuronDefaultConfig | None = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"optimum.neuron.NeuronCLIPModel.config",description:`<strong>config</strong> (<code>transformers.PretrainedConfig</code>) &#x2014; <a href="https://huggingface.co/docs/transformers/main_classes/configuration#transformers.PretrainedConfig" rel="nofollow">PretrainedConfig</a> is the 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 <code>optimum.neuron.modeling.NeuronTracedModel.from_pretrained</code> method to load the model weights.`,name:"config"},{anchor:"optimum.neuron.NeuronCLIPModel.model",description:'<strong>model</strong> (<code>torch.jit._script.ScriptModule</code>) &#x2014; <a href="https://pytorch.org/docs/stable/generated/torch.jit.ScriptModule.html" rel="nofollow">torch.jit._script.ScriptModule</a> is the TorchScript module with embedded NEFF(Neuron Executable File Format) compiled by neuron(x) compiler.',name:"model"}],source:"https://github.com/huggingface/optimum-neuron/blob/v0.4.1/optimum/neuron/models/inference/clip/modeling_clip.py#L50"}}),H=new Te({props:{name:"forward",anchor:"optimum.neuron.NeuronCLIPModel.forward",parameters:[{name:"input_ids",val:": Tensor"},{name:"pixel_values",val:": Tensor"},{name:"attention_mask",val:": Tensor"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"optimum.neuron.NeuronCLIPModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.
Indices can be obtained using <a href="https://huggingface.co/docs/transformers/autoclass_tutorial#autotokenizer" rel="nofollow"><code>AutoTokenizer</code></a>.
See <a href="https://huggingface.co/docs/transformers/main_classes/tokenizer#transformers.PreTrainedTokenizerBase.encode" rel="nofollow"><code>PreTrainedTokenizer.encode</code></a> and
<a href="https://huggingface.co/docs/transformers/main_classes/tokenizer#transformers.PreTrainedTokenizerBase.__call__" rel="nofollow"><code>PreTrainedTokenizer.__call__</code></a> for details.
<a href="https://huggingface.co/docs/transformers/glossary#input-ids" rel="nofollow">What are input IDs?</a>`,name:"input_ids"},{anchor:"optimum.neuron.NeuronCLIPModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor | None</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.
<a href="https://huggingface.co/docs/transformers/glossary#attention-mask" rel="nofollow">What are attention masks?</a></li>
</ul>`,name:"attention_mask"},{anchor:"optimum.neuron.NeuronCLIPModel.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.Tensor | None</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values corresponding to the images in the current batch.
Pixel values can be obtained from encoded images using <a href="https://huggingface.co/docs/transformers/en/model_doc/auto#transformers.AutoImageProcessor" rel="nofollow"><code>AutoImageProcessor</code></a>.`,name:"pixel_values"}],source:"https://github.com/huggingface/optimum-neuron/blob/v0.4.1/optimum/neuron/models/inference/clip/modeling_clip.py#L53"}}),x=new He({props:{anchor:"optimum.neuron.NeuronCLIPModel.forward.example",$$slots:{default:[Ke]},$$scope:{ctx:Q}}}),A=new Y({props:{title:"NeuronCLIPForImageClassification",local:"optimum.neuron.NeuronCLIPForImageClassification",headingTag:"h2"}}),R=new Te({props:{name:"class optimum.neuron.NeuronCLIPForImageClassification",anchor:"optimum.neuron.NeuronCLIPForImageClassification",parameters:[{name:"model",val:": ScriptModule"},{name:"config",val:": PretrainedConfig"},{name:"model_save_dir",val:": str | pathlib.Path | tempfile.TemporaryDirectory | None = None"},{name:"model_file_name",val:": str | None = None"},{name:"preprocessors",val:": list | None = None"},{name:"neuron_config",val:": NeuronDefaultConfig | None = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"optimum.neuron.NeuronCLIPForImageClassification.config",description:`<strong>config</strong> (<code>transformers.PretrainedConfig</code>) &#x2014; <a href="https://huggingface.co/docs/transformers/main_classes/configuration#transformers.PretrainedConfig" rel="nofollow">PretrainedConfig</a> is the 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 <code>optimum.neuron.modeling.NeuronTracedModel.from_pretrained</code> method to load the model weights.`,name:"config"},{anchor:"optimum.neuron.NeuronCLIPForImageClassification.model",description:'<strong>model</strong> (<code>torch.jit._script.ScriptModule</code>) &#x2014; <a href="https://pytorch.org/docs/stable/generated/torch.jit.ScriptModule.html" rel="nofollow">torch.jit._script.ScriptModule</a> is the TorchScript module with embedded NEFF(Neuron Executable File Format) compiled by neuron(x) compiler.',name:"model"}],source:"https://github.com/huggingface/optimum-neuron/blob/v0.4.1/optimum/neuron/models/inference/clip/modeling_clip.py#L102"}}),q=new Te({props:{name:"forward",anchor:"optimum.neuron.NeuronCLIPForImageClassification.forward",parameters:[{name:"pixel_values",val:": Tensor"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"optimum.neuron.NeuronCLIPForImageClassification.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.Tensor | None</code> of shape <code>(batch_size, num_channels, height, width)</code>, defaults to <code>None</code>) &#x2014;
Pixel values corresponding to the images in the current batch.
Pixel values can be obtained from encoded images using <a href="https://huggingface.co/docs/transformers/en/model_doc/auto#transformers.AutoImageProcessor" rel="nofollow"><code>AutoImageProcessor</code></a>.`,name:"pixel_values"}],source:"https://github.com/huggingface/optimum-neuron/blob/v0.4.1/optimum/neuron/models/inference/clip/modeling_clip.py#L112"}}),k=new He({props:{anchor:"optimum.neuron.NeuronCLIPForImageClassification.forward.example",$$slots:{default:[Oe]},$$scope:{ctx:Q}}}),{c(){r=c("meta"),v=a(),w=c("p"),i=a(),d(b.$$.fragment),o=a(),d(j.$$.fragment),le=a(),d(B.$$.fragment),re=a(),X=c("p"),X.innerHTML=Xe,ie=a(),d(W.$$.fragment),pe=a(),L=c("p"),L.innerHTML=We,ce=a(),d(V.$$.fragment),me=a(),P=c("p"),P.textContent=Le,de=a(),d(U.$$.fragment),ue=a(),N=c("blockquote"),N.innerHTML=Ve,he=a(),d(G.$$.fragment),ge=a(),d(z.$$.fragment),fe=a(),d(E.$$.fragment),Me=a(),y=c("div"),d(F.$$.fragment),Ie=a(),D=c("p"),D.textContent=Pe,ve=a(),K=c("p"),K.innerHTML=Ue,$e=a(),$=c("div"),d(H.$$.fragment),_e=a(),O=c("p"),O.innerHTML=Ge,Ce=a(),d(x.$$.fragment),be=a(),d(A.$$.fragment),we=a(),T=c("div"),d(R.$$.fragment),Ne=a(),ee=c("p"),ee.textContent=ze,xe=a(),te=c("p"),te.innerHTML=Ee,ke=a(),_=c("div"),d(q.$$.fragment),Ze=a(),ne=c("p"),ne.innerHTML=Fe,Be=a(),d(k.$$.fragment),je=a(),se=c("p"),this.h()},l(e){const t=Qe("svelte-u9bgzb",document.head);r=m(t,"META",{name:!0,content:!0}),t.forEach(n),v=s(e),w=m(e,"P",{}),ae(w).forEach(n),i=s(e),u(b.$$.fragment,e),o=s(e),u(j.$$.fragment,e),le=s(e),u(B.$$.fragment,e),re=s(e),X=m(e,"P",{"data-svelte-h":!0}),J(X)!=="svelte-1dawxo2"&&(X.innerHTML=Xe),ie=s(e),u(W.$$.fragment,e),pe=s(e),L=m(e,"P",{"data-svelte-h":!0}),J(L)!=="svelte-huz3tp"&&(L.innerHTML=We),ce=s(e),u(V.$$.fragment,e),me=s(e),P=m(e,"P",{"data-svelte-h":!0}),J(P)!=="svelte-87nkn2"&&(P.textContent=Le),de=s(e),u(U.$$.fragment,e),ue=s(e),N=m(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),J(N)!=="svelte-13x1ycp"&&(N.innerHTML=Ve),he=s(e),u(G.$$.fragment,e),ge=s(e),u(z.$$.fragment,e),fe=s(e),u(E.$$.fragment,e),Me=s(e),y=m(e,"DIV",{class:!0});var I=ae(y);u(F.$$.fragment,I),Ie=s(I),D=m(I,"P",{"data-svelte-h":!0}),J(D)!=="svelte-12hypg"&&(D.textContent=Pe),ve=s(I),K=m(I,"P",{"data-svelte-h":!0}),J(K)!=="svelte-t21i2g"&&(K.innerHTML=Ue),$e=s(I),$=m(I,"DIV",{class:!0});var C=ae($);u(H.$$.fragment,C),_e=s(C),O=m(C,"P",{"data-svelte-h":!0}),J(O)!=="svelte-d0734s"&&(O.innerHTML=Ge),Ce=s(C),u(x.$$.fragment,C),C.forEach(n),I.forEach(n),be=s(e),u(A.$$.fragment,e),we=s(e),T=m(e,"DIV",{class:!0});var Z=ae(T);u(R.$$.fragment,Z),Ne=s(Z),ee=m(Z,"P",{"data-svelte-h":!0}),J(ee)!=="svelte-80tjla"&&(ee.textContent=ze),xe=s(Z),te=m(Z,"P",{"data-svelte-h":!0}),J(te)!=="svelte-t21i2g"&&(te.innerHTML=Ee),ke=s(Z),_=m(Z,"DIV",{class:!0});var oe=ae(_);u(q.$$.fragment,oe),Ze=s(oe),ne=m(oe,"P",{"data-svelte-h":!0}),J(ne)!=="svelte-ifttel"&&(ne.innerHTML=Fe),Be=s(oe),u(k.$$.fragment,oe),oe.forEach(n),Z.forEach(n),je=s(e),se=m(e,"P",{}),ae(se).forEach(n),this.h()},h(){S(r,"name","hf:doc:metadata"),S(r,"content",tt),S(N,"class","tip"),S($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),S(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),S(_,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),S(T,"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,t){p(document.head,r),l(e,v,t),l(e,w,t),l(e,i,t),h(b,e,t),l(e,o,t),h(j,e,t),l(e,le,t),h(B,e,t),l(e,re,t),l(e,X,t),l(e,ie,t),h(W,e,t),l(e,pe,t),l(e,L,t),l(e,ce,t),h(V,e,t),l(e,me,t),l(e,P,t),l(e,de,t),h(U,e,t),l(e,ue,t),l(e,N,t),l(e,he,t),h(G,e,t),l(e,ge,t),h(z,e,t),l(e,fe,t),h(E,e,t),l(e,Me,t),l(e,y,t),h(F,y,null),p(y,Ie),p(y,D),p(y,ve),p(y,K),p(y,$e),p(y,$),h(H,$,null),p($,_e),p($,O),p($,Ce),h(x,$,null),l(e,be,t),h(A,e,t),l(e,we,t),l(e,T,t),h(R,T,null),p(T,Ne),p(T,ee),p(T,xe),p(T,te),p(T,ke),p(T,_),h(q,_,null),p(_,Ze),p(_,ne),p(_,Be),h(k,_,null),l(e,je,t),l(e,se,t),ye=!0},p(e,[t]){const I={};t&2&&(I.$$scope={dirty:t,ctx:e}),x.$set(I);const C={};t&2&&(C.$$scope={dirty:t,ctx:e}),k.$set(C)},i(e){ye||(g(b.$$.fragment,e),g(j.$$.fragment,e),g(B.$$.fragment,e),g(W.$$.fragment,e),g(V.$$.fragment,e),g(U.$$.fragment,e),g(G.$$.fragment,e),g(z.$$.fragment,e),g(E.$$.fragment,e),g(F.$$.fragment,e),g(H.$$.fragment,e),g(x.$$.fragment,e),g(A.$$.fragment,e),g(R.$$.fragment,e),g(q.$$.fragment,e),g(k.$$.fragment,e),ye=!0)},o(e){f(b.$$.fragment,e),f(j.$$.fragment,e),f(B.$$.fragment,e),f(W.$$.fragment,e),f(V.$$.fragment,e),f(U.$$.fragment,e),f(G.$$.fragment,e),f(z.$$.fragment,e),f(E.$$.fragment,e),f(F.$$.fragment,e),f(H.$$.fragment,e),f(x.$$.fragment,e),f(A.$$.fragment,e),f(R.$$.fragment,e),f(q.$$.fragment,e),f(k.$$.fragment,e),ye=!1},d(e){e&&(n(v),n(w),n(i),n(o),n(le),n(re),n(X),n(ie),n(pe),n(L),n(ce),n(me),n(P),n(de),n(ue),n(N),n(he),n(ge),n(fe),n(Me),n(y),n(be),n(we),n(T),n(je),n(se)),n(r),M(b,e),M(j,e),M(B,e),M(W,e),M(V,e),M(U,e),M(G,e),M(z,e),M(E,e),M(F),M(H),M(x),M(A,e),M(R),M(q),M(k)}}}const tt='{"title":"CLIP","local":"clip","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Export to Neuron","local":"export-to-neuron","sections":[{"title":"Option 1: CLI","local":"option-1-cli","sections":[],"depth":3},{"title":"Option 2: Python API","local":"option-2-python-api","sections":[],"depth":3}],"depth":2},{"title":"NeuronCLIPModel","local":"optimum.neuron.NeuronCLIPModel","sections":[],"depth":2},{"title":"NeuronCLIPForImageClassification","local":"optimum.neuron.NeuronCLIPForImageClassification","sections":[],"depth":2}],"depth":1}';function nt(Q){return qe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ct extends Se{constructor(r){super(),Ye(this,r,nt,et,Re,{})}}export{ct as component};
