import{s as me,o as ce,n as le}from"../chunks/scheduler.53228c21.js";import{S as fe,i as ue,e as h,s,c as g,h as pe,a as _,d as r,b as i,f as Y,g as b,j as F,k as z,l as p,m as l,n as M,t as y,o as w,p as v}from"../chunks/index.100fac89.js";import{C as he}from"../chunks/CopyLLMTxtMenu.0ee1b69b.js";import{D as de}from"../chunks/Docstring.db856a1e.js";import{C as oe}from"../chunks/CodeBlock.d30a6509.js";import{E as se}from"../chunks/ExampleCodeBlock.3eb26ae1.js";import{H as ie,E as ge}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.136ef3fd.js";function _e(V){let n,$="Example:",c,a,d;return a=new oe({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9Nb2RlbCUwQSUwQXVuZXQlMjAlM0QlMjBBdXRvTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTJDJTIwc3ViZm9sZGVyJTNEJTIydW5ldCUyMik=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoModel

unet = AutoModel.from_pretrained(<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>, subfolder=<span class="hljs-string">&quot;unet&quot;</span>)`,wrap:!1}}),{c(){n=h("p"),n.textContent=$,c=s(),g(a.$$.fragment)},l(o){n=_(o,"P",{"data-svelte-h":!0}),F(n)!=="svelte-11lpom8"&&(n.textContent=$),c=i(o),b(a.$$.fragment,o)},m(o,f){l(o,n,f),l(o,c,f),M(a,o,f),d=!0},p:le,i(o){d||(y(a.$$.fragment,o),d=!0)},o(o){w(a.$$.fragment,o),d=!1},d(o){o&&(r(n),r(c)),v(a,o)}}}function be(V){let n,$="If you get the error message below, you need to finetune the weights for your downstream task:",c,a,d;return a=new oe({props:{code:"U29tZSUyMHdlaWdodHMlMjBvZiUyMFVOZXQyRENvbmRpdGlvbk1vZGVsJTIwd2VyZSUyMG5vdCUyMGluaXRpYWxpemVkJTIwZnJvbSUyMHRoZSUyMG1vZGVsJTIwY2hlY2twb2ludCUyMGF0JTIwcnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjBhbmQlMjBhcmUlMjBuZXdseSUyMGluaXRpYWxpemVkJTIwYmVjYXVzZSUyMHRoZSUyMHNoYXBlcyUyMGRpZCUyMG5vdCUyMG1hdGNoJTNBJTBBLSUyMGNvbnZfaW4ud2VpZ2h0JTNBJTIwZm91bmQlMjBzaGFwZSUyMHRvcmNoLlNpemUoJTVCMzIwJTJDJTIwNCUyQyUyMDMlMkMlMjAzJTVEKSUyMGluJTIwdGhlJTIwY2hlY2twb2ludCUyMGFuZCUyMHRvcmNoLlNpemUoJTVCMzIwJTJDJTIwOSUyQyUyMDMlMkMlMjAzJTVEKSUyMGluJTIwdGhlJTIwbW9kZWwlMjBpbnN0YW50aWF0ZWQlMEFZb3UlMjBzaG91bGQlMjBwcm9iYWJseSUyMFRSQUlOJTIwdGhpcyUyMG1vZGVsJTIwb24lMjBhJTIwZG93bi1zdHJlYW0lMjB0YXNrJTIwdG8lMjBiZSUyMGFibGUlMjB0byUyMHVzZSUyMGl0JTIwZm9yJTIwcHJlZGljdGlvbnMlMjBhbmQlMjBpbmZlcmVuY2Uu",highlighted:`Some weights of UNet2DConditionModel were not initialized from the model checkpoint at runwayml/stable-diffusion-v1-5 and are newly initialized because the shapes did not match:
- conv_in.weight: found shape torch.Size([320, 4, 3, 3]) <span class="hljs-keyword">in</span> the checkpoint and torch.Size([320, 9, 3, 3]) <span class="hljs-keyword">in</span> the model instantiated
You should probably TRAIN this model on a down-stream task to be able to use it <span class="hljs-keyword">for</span> predictions and inference.`,wrap:!1}}),{c(){n=h("p"),n.textContent=$,c=s(),g(a.$$.fragment)},l(o){n=_(o,"P",{"data-svelte-h":!0}),F(n)!=="svelte-xueb0m"&&(n.textContent=$),c=i(o),b(a.$$.fragment,o)},m(o,f){l(o,n,f),l(o,c,f),M(a,o,f),d=!0},p:le,i(o){d||(y(a.$$.fragment,o),d=!0)},o(o){w(a.$$.fragment,o),d=!1},d(o){o&&(r(n),r(c)),v(a,o)}}}function Me(V){let n,$,c,a,d,o,f,B,k,te="The <code>AutoModel</code> is designed to make it easy to load a checkpoint without needing to know the specific model class. <code>AutoModel</code> automatically retrieves the correct model class from the checkpoint <code>config.json</code> file.",P,G,q,Z,H,x,J,Q,m,A,X,W,ne="Instantiate a pretrained PyTorch model from a pretrained model configuration.",D,L,re=`The model is set in evaluation mode - <code>model.eval()</code> - by default, and dropout modules are deactivated. To
train the model, set it back in training mode with <code>model.train()</code>.`,O,C,ae=`<p>&gt; To use private or <a href="https://huggingface.co/docs/hub/models-gated#gated-models" rel="nofollow">gated models</a>, log-in
with <code>hf &gt; auth login</code>. You can also activate the special &gt;
<a href="https://huggingface.co/diffusers/installation.html#offline-mode" rel="nofollow">“offline-mode”</a> to use this method in a &gt;
firewalled environment.</p>`,K,T,ee,U,E,I,N,S,R;return d=new he({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),f=new ie({props:{title:"AutoModel",local:"automodel",headingTag:"h1"}}),G=new oe({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9Nb2RlbCUyQyUyMEF1dG9QaXBlbGluZUZvclRleHQySW1hZ2UlMEElMEF1bmV0JTIwJTNEJTIwQXV0b01vZGVsLmZyb21fcHJldHJhaW5lZCglMjJzdGFibGUtZGlmZnVzaW9uLXYxLTUlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMkMlMjBzdWJmb2xkZXIlM0QlMjJ1bmV0JTIyKSUwQXBpcGUlMjAlM0QlMjBBdXRvUGlwZWxpbmVGb3JUZXh0MkltYWdlLmZyb21fcHJldHJhaW5lZCglMjJzdGFibGUtZGlmZnVzaW9uLXYxLTUlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMkMlMjB1bmV0JTNEdW5ldCk=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoModel, AutoPipelineForText2Image

unet = AutoModel.from_pretrained(<span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>, subfolder=<span class="hljs-string">&quot;unet&quot;</span>)
pipe = AutoPipelineForText2Image.from_pretrained(<span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>, unet=unet)`,wrap:!1}}),Z=new ie({props:{title:"AutoModel",local:"diffusers.AutoModel",headingTag:"h2"}}),J=new de({props:{name:"class diffusers.AutoModel",anchor:"diffusers.AutoModel",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/auto_model.py#L28"}}),A=new de({props:{name:"from_pretrained",anchor:"diffusers.AutoModel.from_pretrained",parameters:[{name:"pretrained_model_or_path",val:": typing.Union[str, os.PathLike, NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.AutoModel.from_pretrained.pretrained_model_name_or_path",description:`<strong>pretrained_model_name_or_path</strong> (<code>str</code> or <code>os.PathLike</code>, <em>optional</em>) &#x2014;
Can be either:</p>
<ul>
<li>A string, the <em>model id</em> (for example <code>google/ddpm-celebahq-256</code>) of a pretrained model hosted on
the Hub.</li>
<li>A path to a <em>directory</em> (for example <code>./my_model_directory</code>) containing the model weights saved
with <a href="/docs/diffusers/main/en/api/models/overview#diffusers.ModelMixin.save_pretrained">save_pretrained()</a>.</li>
</ul>`,name:"pretrained_model_name_or_path"},{anchor:"diffusers.AutoModel.from_pretrained.cache_dir",description:`<strong>cache_dir</strong> (<code>Union[str, os.PathLike]</code>, <em>optional</em>) &#x2014;
Path to a directory where a downloaded pretrained model configuration is cached if the standard cache
is not used.`,name:"cache_dir"},{anchor:"diffusers.AutoModel.from_pretrained.torch_dtype",description:`<strong>torch_dtype</strong> (<code>torch.dtype</code>, <em>optional</em>) &#x2014;
Override the default <code>torch.dtype</code> and load the model with another dtype.`,name:"torch_dtype"},{anchor:"diffusers.AutoModel.from_pretrained.force_download",description:`<strong>force_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to force the (re-)download of the model weights and configuration files, overriding the
cached versions if they exist.`,name:"force_download"},{anchor:"diffusers.AutoModel.from_pretrained.proxies",description:`<strong>proxies</strong> (<code>Dict[str, str]</code>, <em>optional</em>) &#x2014;
A dictionary of proxy servers to use by protocol or endpoint, for example, <code>{&apos;http&apos;: &apos;foo.bar:3128&apos;, &apos;http://hostname&apos;: &apos;foo.bar:4012&apos;}</code>. The proxies are used on each request.`,name:"proxies"},{anchor:"diffusers.AutoModel.from_pretrained.output_loading_info",description:`<strong>output_loading_info</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to also return a dictionary containing missing keys, unexpected keys and error messages.`,name:"output_loading_info"},{anchor:"diffusers.AutoModel.from_pretrained.local_files_only(bool,",description:`<strong>local_files_only(<code>bool</code>,</strong> <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to only load local model weights and configuration files or not. If set to <code>True</code>, the model
won&#x2019;t be downloaded from the Hub.`,name:"local_files_only(bool,"},{anchor:"diffusers.AutoModel.from_pretrained.token",description:`<strong>token</strong> (<code>str</code> or <em>bool</em>, <em>optional</em>) &#x2014;
The token to use as HTTP bearer authorization for remote files. If <code>True</code>, the token generated from
<code>diffusers-cli login</code> (stored in <code>~/.huggingface</code>) is used.`,name:"token"},{anchor:"diffusers.AutoModel.from_pretrained.revision",description:`<strong>revision</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;main&quot;</code>) &#x2014;
The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier
allowed by Git.`,name:"revision"},{anchor:"diffusers.AutoModel.from_pretrained.from_flax",description:`<strong>from_flax</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Load the model weights from a Flax checkpoint save file.`,name:"from_flax"},{anchor:"diffusers.AutoModel.from_pretrained.subfolder",description:`<strong>subfolder</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&quot;</code>) &#x2014;
The subfolder location of a model file within a larger model repository on the Hub or locally.`,name:"subfolder"},{anchor:"diffusers.AutoModel.from_pretrained.mirror",description:`<strong>mirror</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Mirror source to resolve accessibility issues if you&#x2019;re downloading a model in China. We do not
guarantee the timeliness or safety of the source, and you should refer to the mirror site for more
information.`,name:"mirror"},{anchor:"diffusers.AutoModel.from_pretrained.device_map",description:`<strong>device_map</strong> (<code>str</code> or <code>Dict[str, Union[int, str, torch.device]]</code>, <em>optional</em>) &#x2014;
A map that specifies where each submodule should go. It doesn&#x2019;t need to be defined for each
parameter/buffer name; once a given module name is inside, every submodule of it will be sent to the
same device. Defaults to <code>None</code>, meaning that the model will be loaded on CPU.</p>
<p>Set <code>device_map=&quot;auto&quot;</code> to have &#x1F917; Accelerate automatically compute the most optimized <code>device_map</code>. For
more information about each option see <a href="https://hf.co/docs/accelerate/main/en/usage_guides/big_modeling#designing-a-device-map" rel="nofollow">designing a device
map</a>.`,name:"device_map"},{anchor:"diffusers.AutoModel.from_pretrained.max_memory",description:`<strong>max_memory</strong> (<code>Dict</code>, <em>optional</em>) &#x2014;
A dictionary device identifier for the maximum memory. Will default to the maximum memory available for
each GPU and the available CPU RAM if unset.`,name:"max_memory"},{anchor:"diffusers.AutoModel.from_pretrained.offload_folder",description:`<strong>offload_folder</strong> (<code>str</code> or <code>os.PathLike</code>, <em>optional</em>) &#x2014;
The path to offload weights if <code>device_map</code> contains the value <code>&quot;disk&quot;</code>.`,name:"offload_folder"},{anchor:"diffusers.AutoModel.from_pretrained.offload_state_dict",description:`<strong>offload_state_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If <code>True</code>, temporarily offloads the CPU state dict to the hard drive to avoid running out of CPU RAM if
the weight of the CPU state dict + the biggest shard of the checkpoint does not fit. Defaults to <code>True</code>
when there is some disk offload.`,name:"offload_state_dict"},{anchor:"diffusers.AutoModel.from_pretrained.low_cpu_mem_usage",description:`<strong>low_cpu_mem_usage</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code> if torch version &gt;= 1.9.0 else <code>False</code>) &#x2014;
Speed up model loading only loading the pretrained weights and not initializing the weights. This also
tries to not use more than 1x model size in CPU memory (including peak memory) while loading the model.
Only supported for PyTorch &gt;= 1.9.0. If you are using an older version of PyTorch, setting this
argument to <code>True</code> will raise an error.`,name:"low_cpu_mem_usage"},{anchor:"diffusers.AutoModel.from_pretrained.variant",description:`<strong>variant</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Load weights from a specified <code>variant</code> filename such as <code>&quot;fp16&quot;</code> or <code>&quot;ema&quot;</code>. This is ignored when
loading <code>from_flax</code>.`,name:"variant"},{anchor:"diffusers.AutoModel.from_pretrained.use_safetensors",description:`<strong>use_safetensors</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
If set to <code>None</code>, the <code>safetensors</code> weights are downloaded if they&#x2019;re available <strong>and</strong> if the
<code>safetensors</code> library is installed. If set to <code>True</code>, the model is forcibly loaded from <code>safetensors</code>
weights. If set to <code>False</code>, <code>safetensors</code> weights are not loaded.`,name:"use_safetensors"},{anchor:"diffusers.AutoModel.from_pretrained.disable_mmap",description:`<strong>disable_mmap</strong> (&#x2018;bool&#x2019;, <em>optional</em>, defaults to &#x2018;False&#x2019;) &#x2014;
Whether to disable mmap when loading a Safetensors model. This option can perform better when the model
is on a network mount or hard drive, which may not handle the seeky-ness of mmap very well.`,name:"disable_mmap"},{anchor:"diffusers.AutoModel.from_pretrained.trust_remote_cocde",description:`<strong>trust_remote_cocde</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to trust remote code`,name:"trust_remote_cocde"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/auto_model.py#L38"}}),T=new se({props:{anchor:"diffusers.AutoModel.from_pretrained.example",$$slots:{default:[_e]},$$scope:{ctx:V}}}),U=new se({props:{anchor:"diffusers.AutoModel.from_pretrained.example-2",$$slots:{default:[be]},$$scope:{ctx:V}}}),I=new ge({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/auto_model.md"}}),{c(){n=h("meta"),$=s(),c=h("p"),a=s(),g(d.$$.fragment),o=s(),g(f.$$.fragment),B=s(),k=h("p"),k.innerHTML=te,P=s(),g(G.$$.fragment),q=s(),g(Z.$$.fragment),H=s(),x=h("div"),g(J.$$.fragment),Q=s(),m=h("div"),g(A.$$.fragment),X=s(),W=h("p"),W.textContent=ne,D=s(),L=h("p"),L.innerHTML=re,O=s(),C=h("blockquote"),C.innerHTML=ae,K=s(),g(T.$$.fragment),ee=s(),g(U.$$.fragment),E=s(),g(I.$$.fragment),N=s(),S=h("p"),this.h()},l(e){const t=pe("svelte-u9bgzb",document.head);n=_(t,"META",{name:!0,content:!0}),t.forEach(r),$=i(e),c=_(e,"P",{}),Y(c).forEach(r),a=i(e),b(d.$$.fragment,e),o=i(e),b(f.$$.fragment,e),B=i(e),k=_(e,"P",{"data-svelte-h":!0}),F(k)!=="svelte-rk85u"&&(k.innerHTML=te),P=i(e),b(G.$$.fragment,e),q=i(e),b(Z.$$.fragment,e),H=i(e),x=_(e,"DIV",{class:!0});var j=Y(x);b(J.$$.fragment,j),Q=i(j),m=_(j,"DIV",{class:!0});var u=Y(m);b(A.$$.fragment,u),X=i(u),W=_(u,"P",{"data-svelte-h":!0}),F(W)!=="svelte-1lisopl"&&(W.textContent=ne),D=i(u),L=_(u,"P",{"data-svelte-h":!0}),F(L)!=="svelte-1fnd9e6"&&(L.innerHTML=re),O=i(u),C=_(u,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),F(C)!=="svelte-82moo4"&&(C.innerHTML=ae),K=i(u),b(T.$$.fragment,u),ee=i(u),b(U.$$.fragment,u),u.forEach(r),j.forEach(r),E=i(e),b(I.$$.fragment,e),N=i(e),S=_(e,"P",{}),Y(S).forEach(r),this.h()},h(){z(n,"name","hf:doc:metadata"),z(n,"content",ye),z(C,"class","tip"),z(m,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),z(x,"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,n),l(e,$,t),l(e,c,t),l(e,a,t),M(d,e,t),l(e,o,t),M(f,e,t),l(e,B,t),l(e,k,t),l(e,P,t),M(G,e,t),l(e,q,t),M(Z,e,t),l(e,H,t),l(e,x,t),M(J,x,null),p(x,Q),p(x,m),M(A,m,null),p(m,X),p(m,W),p(m,D),p(m,L),p(m,O),p(m,C),p(m,K),M(T,m,null),p(m,ee),M(U,m,null),l(e,E,t),M(I,e,t),l(e,N,t),l(e,S,t),R=!0},p(e,[t]){const j={};t&2&&(j.$$scope={dirty:t,ctx:e}),T.$set(j);const u={};t&2&&(u.$$scope={dirty:t,ctx:e}),U.$set(u)},i(e){R||(y(d.$$.fragment,e),y(f.$$.fragment,e),y(G.$$.fragment,e),y(Z.$$.fragment,e),y(J.$$.fragment,e),y(A.$$.fragment,e),y(T.$$.fragment,e),y(U.$$.fragment,e),y(I.$$.fragment,e),R=!0)},o(e){w(d.$$.fragment,e),w(f.$$.fragment,e),w(G.$$.fragment,e),w(Z.$$.fragment,e),w(J.$$.fragment,e),w(A.$$.fragment,e),w(T.$$.fragment,e),w(U.$$.fragment,e),w(I.$$.fragment,e),R=!1},d(e){e&&(r($),r(c),r(a),r(o),r(B),r(k),r(P),r(q),r(H),r(x),r(E),r(N),r(S)),r(n),v(d,e),v(f,e),v(G,e),v(Z,e),v(J),v(A),v(T),v(U),v(I,e)}}}const ye='{"title":"AutoModel","local":"automodel","sections":[{"title":"AutoModel","local":"diffusers.AutoModel","sections":[],"depth":2}],"depth":1}';function we(V){return ce(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ze extends fe{constructor(n){super(),ue(this,n,we,Me,me,{})}}export{Ze as component};
