import{s as ie,o as le,n as K}from"../chunks/scheduler.8c3d61f6.js";import{S as me,i as ce,g as w,s as m,r as h,A as fe,h as $,f as r,c,j as N,u as g,x as F,k as E,y as v,a as i,v as _,d as b,t as M,w as y}from"../chunks/index.da70eac4.js";import{T as ue}from"../chunks/Tip.6f698f24.js";import{D as ae}from"../chunks/Docstring.367be9ed.js";import{C as ee}from"../chunks/CodeBlock.a9c4becf.js";import{E as se}from"../chunks/ExampleCodeBlock.dd9ee828.js";import{H as de,E as pe}from"../chunks/getInferenceSnippets.cb466318.js";function he(T){let t,p=`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 auth login</code>. You can also activate the special
<a href="https://huggingface.co/diffusers/installation.html#offline-mode" rel="nofollow">“offline-mode”</a> to use this method in a
firewalled environment.`;return{c(){t=w("p"),t.innerHTML=p},l(s){t=$(s,"P",{"data-svelte-h":!0}),F(t)!=="svelte-kjkp1z"&&(t.innerHTML=p)},m(s,a){i(s,t,a)},p:K,d(s){s&&r(t)}}}function ge(T){let t,p="Example:",s,a,d;return a=new ee({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(){t=w("p"),t.textContent=p,s=m(),h(a.$$.fragment)},l(o){t=$(o,"P",{"data-svelte-h":!0}),F(t)!=="svelte-11lpom8"&&(t.textContent=p),s=c(o),g(a.$$.fragment,o)},m(o,f){i(o,t,f),i(o,s,f),_(a,o,f),d=!0},p:K,i(o){d||(b(a.$$.fragment,o),d=!0)},o(o){M(a.$$.fragment,o),d=!1},d(o){o&&(r(t),r(s)),y(a,o)}}}function _e(T){let t,p="If you get the error message below, you need to finetune the weights for your downstream task:",s,a,d;return a=new ee({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(){t=w("p"),t.textContent=p,s=m(),h(a.$$.fragment)},l(o){t=$(o,"P",{"data-svelte-h":!0}),F(t)!=="svelte-xueb0m"&&(t.textContent=p),s=c(o),g(a.$$.fragment,o)},m(o,f){i(o,t,f),i(o,s,f),_(a,o,f),d=!0},p:K,i(o){d||(b(a.$$.fragment,o),d=!0)},o(o){M(a.$$.fragment,o),d=!1},d(o){o&&(r(t),r(s)),y(a,o)}}}function be(T){let t,p,s,a,d,o,f,oe="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.",S,Z,z,J,P,x,A,R,l,I,Y,V,te="Instantiate a pretrained PyTorch model from a pretrained model configuration.",X,W,ne=`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>.`,Q,U,D,k,O,G,B,j,H,L,q;return d=new de({props:{title:"AutoModel",local:"automodel",headingTag:"h1"}}),Z=new ee({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}}),J=new de({props:{title:"AutoModel",local:"diffusers.AutoModel",headingTag:"h2"}}),A=new ae({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"}}),I=new ae({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"}}),U=new ue({props:{$$slots:{default:[he]},$$scope:{ctx:T}}}),k=new se({props:{anchor:"diffusers.AutoModel.from_pretrained.example",$$slots:{default:[ge]},$$scope:{ctx:T}}}),G=new se({props:{anchor:"diffusers.AutoModel.from_pretrained.example-2",$$slots:{default:[_e]},$$scope:{ctx:T}}}),j=new pe({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/auto_model.md"}}),{c(){t=w("meta"),p=m(),s=w("p"),a=m(),h(d.$$.fragment),o=m(),f=w("p"),f.innerHTML=oe,S=m(),h(Z.$$.fragment),z=m(),h(J.$$.fragment),P=m(),x=w("div"),h(A.$$.fragment),R=m(),l=w("div"),h(I.$$.fragment),Y=m(),V=w("p"),V.textContent=te,X=m(),W=w("p"),W.innerHTML=ne,Q=m(),h(U.$$.fragment),D=m(),h(k.$$.fragment),O=m(),h(G.$$.fragment),B=m(),h(j.$$.fragment),H=m(),L=w("p"),this.h()},l(e){const n=fe("svelte-u9bgzb",document.head);t=$(n,"META",{name:!0,content:!0}),n.forEach(r),p=c(e),s=$(e,"P",{}),N(s).forEach(r),a=c(e),g(d.$$.fragment,e),o=c(e),f=$(e,"P",{"data-svelte-h":!0}),F(f)!=="svelte-rk85u"&&(f.innerHTML=oe),S=c(e),g(Z.$$.fragment,e),z=c(e),g(J.$$.fragment,e),P=c(e),x=$(e,"DIV",{class:!0});var C=N(x);g(A.$$.fragment,C),R=c(C),l=$(C,"DIV",{class:!0});var u=N(l);g(I.$$.fragment,u),Y=c(u),V=$(u,"P",{"data-svelte-h":!0}),F(V)!=="svelte-1lisopl"&&(V.textContent=te),X=c(u),W=$(u,"P",{"data-svelte-h":!0}),F(W)!=="svelte-1fnd9e6"&&(W.innerHTML=ne),Q=c(u),g(U.$$.fragment,u),D=c(u),g(k.$$.fragment,u),O=c(u),g(G.$$.fragment,u),u.forEach(r),C.forEach(r),B=c(e),g(j.$$.fragment,e),H=c(e),L=$(e,"P",{}),N(L).forEach(r),this.h()},h(){E(t,"name","hf:doc:metadata"),E(t,"content",Me),E(l,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),E(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,n){v(document.head,t),i(e,p,n),i(e,s,n),i(e,a,n),_(d,e,n),i(e,o,n),i(e,f,n),i(e,S,n),_(Z,e,n),i(e,z,n),_(J,e,n),i(e,P,n),i(e,x,n),_(A,x,null),v(x,R),v(x,l),_(I,l,null),v(l,Y),v(l,V),v(l,X),v(l,W),v(l,Q),_(U,l,null),v(l,D),_(k,l,null),v(l,O),_(G,l,null),i(e,B,n),_(j,e,n),i(e,H,n),i(e,L,n),q=!0},p(e,[n]){const C={};n&2&&(C.$$scope={dirty:n,ctx:e}),U.$set(C);const u={};n&2&&(u.$$scope={dirty:n,ctx:e}),k.$set(u);const re={};n&2&&(re.$$scope={dirty:n,ctx:e}),G.$set(re)},i(e){q||(b(d.$$.fragment,e),b(Z.$$.fragment,e),b(J.$$.fragment,e),b(A.$$.fragment,e),b(I.$$.fragment,e),b(U.$$.fragment,e),b(k.$$.fragment,e),b(G.$$.fragment,e),b(j.$$.fragment,e),q=!0)},o(e){M(d.$$.fragment,e),M(Z.$$.fragment,e),M(J.$$.fragment,e),M(A.$$.fragment,e),M(I.$$.fragment,e),M(U.$$.fragment,e),M(k.$$.fragment,e),M(G.$$.fragment,e),M(j.$$.fragment,e),q=!1},d(e){e&&(r(p),r(s),r(a),r(o),r(f),r(S),r(z),r(P),r(x),r(B),r(H),r(L)),r(t),y(d,e),y(Z,e),y(J,e),y(A),y(I),y(U),y(k),y(G),y(j,e)}}}const Me='{"title":"AutoModel","local":"automodel","sections":[{"title":"AutoModel","local":"diffusers.AutoModel","sections":[],"depth":2}],"depth":1}';function ye(T){return le(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ge extends me{constructor(t){super(),ce(this,t,ye,be,ie,{})}}export{Ge as component};
