import{s as ie,o as le,n as de}from"../chunks/scheduler.53228c21.js";import{S as ce,i as me,e as h,s as i,c as b,h as fe,a as g,d as r,b as l,f as z,g as y,j as S,k as B,l as u,m as c,n as M,t as w,o as v,p as $}from"../chunks/index.100fac89.js";import{C as pe}from"../chunks/CopyLLMTxtMenu.494046bd.js";import{D as ne}from"../chunks/Docstring.9bbf7d33.js";import{C as se}from"../chunks/CodeBlock.d30a6509.js";import{E as re}from"../chunks/ExampleCodeBlock.a8b00edf.js";import{H as ae,E as ue}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.8999c127.js";function he(G){let t,_="Example:",m,a,d;return a=new se({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9Nb2RlbCUwQSUwQXVuZXQlMjAlM0QlMjBBdXRvTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnVuZXQlMjIp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoModel

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>)`,wrap:!1}}),{c(){t=h("p"),t.textContent=_,m=i(),b(a.$$.fragment)},l(o){t=g(o,"P",{"data-svelte-h":!0}),S(t)!=="svelte-11lpom8"&&(t.textContent=_),m=l(o),y(a.$$.fragment,o)},m(o,f){c(o,t,f),c(o,m,f),M(a,o,f),d=!0},p:de,i(o){d||(w(a.$$.fragment,o),d=!0)},o(o){v(a.$$.fragment,o),d=!1},d(o){o&&(r(t),r(m)),$(a,o)}}}function ge(G){let t,_="If you get the error message below, you need to finetune the weights for your downstream task:",m,a,d;return a=new se({props:{code:"U29tZSUyMHdlaWdodHMlMjBvZiUyMFVOZXQyRENvbmRpdGlvbk1vZGVsJTIwd2VyZSUyMG5vdCUyMGluaXRpYWxpemVkJTIwZnJvbSUyMHRoZSUyMG1vZGVsJTIwY2hlY2twb2ludCUyMGF0JTIwc3RhYmxlLWRpZmZ1c2lvbi12MS01JTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIwYW5kJTIwYXJlJTIwbmV3bHklMjBpbml0aWFsaXplZCUyMGJlY2F1c2UlMjB0aGUlMjBzaGFwZXMlMjBkaWQlMjBub3QlMjBtYXRjaCUzQSUwQS0lMjBjb252X2luLndlaWdodCUzQSUyMGZvdW5kJTIwc2hhcGUlMjB0b3JjaC5TaXplKCU1QjMyMCUyQyUyMDQlMkMlMjAzJTJDJTIwMyU1RCklMjBpbiUyMHRoZSUyMGNoZWNrcG9pbnQlMjBhbmQlMjB0b3JjaC5TaXplKCU1QjMyMCUyQyUyMDklMkMlMjAzJTJDJTIwMyU1RCklMjBpbiUyMHRoZSUyMG1vZGVsJTIwaW5zdGFudGlhdGVkJTBBWW91JTIwc2hvdWxkJTIwcHJvYmFibHklMjBUUkFJTiUyMHRoaXMlMjBtb2RlbCUyMG9uJTIwYSUyMGRvd24tc3RyZWFtJTIwdGFzayUyMHRvJTIwYmUlMjBhYmxlJTIwdG8lMjB1c2UlMjBpdCUyMGZvciUyMHByZWRpY3Rpb25zJTIwYW5kJTIwaW5mZXJlbmNlLg==",highlighted:`Some weights of UNet2DConditionModel were not initialized from the model checkpoint at stable-diffusion-v1-5/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=h("p"),t.textContent=_,m=i(),b(a.$$.fragment)},l(o){t=g(o,"P",{"data-svelte-h":!0}),S(t)!=="svelte-xueb0m"&&(t.textContent=_),m=l(o),y(a.$$.fragment,o)},m(o,f){c(o,t,f),c(o,m,f),M(a,o,f),d=!0},p:de,i(o){d||(w(a.$$.fragment,o),d=!0)},o(o){v(a.$$.fragment,o),d=!1},d(o){o&&(r(t),r(m)),$(a,o)}}}function _e(G){let t,_,m,a,d,o,f,H,U,K='<a href="/docs/diffusers/main/en/api/models/auto_model#diffusers.AutoModel">AutoModel</a> automatically retrieves the correct model class from the checkpoint <code>config.json</code> file.',F,A,L,x,C,N,s,j,X,W,ee="Instantiate a pretrained PyTorch model from a pretrained model configuration.",E,R,oe=`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>.`,V,J,te=`<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>`,D,k,O,T,q,Z,Q,P,Y;return d=new pe({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),f=new ae({props:{title:"AutoModel",local:"automodel",headingTag:"h1"}}),A=new ae({props:{title:"AutoModel",local:"diffusers.AutoModel",headingTag:"h2"}}),C=new ne({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"}}),j=new ne({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"}}),k=new re({props:{anchor:"diffusers.AutoModel.from_pretrained.example",$$slots:{default:[he]},$$scope:{ctx:G}}}),T=new re({props:{anchor:"diffusers.AutoModel.from_pretrained.example-2",$$slots:{default:[ge]},$$scope:{ctx:G}}}),Z=new ue({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/auto_model.md"}}),{c(){t=h("meta"),_=i(),m=h("p"),a=i(),b(d.$$.fragment),o=i(),b(f.$$.fragment),H=i(),U=h("p"),U.innerHTML=K,F=i(),b(A.$$.fragment),L=i(),x=h("div"),b(C.$$.fragment),N=i(),s=h("div"),b(j.$$.fragment),X=i(),W=h("p"),W.textContent=ee,E=i(),R=h("p"),R.innerHTML=oe,V=i(),J=h("blockquote"),J.innerHTML=te,D=i(),b(k.$$.fragment),O=i(),b(T.$$.fragment),q=i(),b(Z.$$.fragment),Q=i(),P=h("p"),this.h()},l(e){const n=fe("svelte-u9bgzb",document.head);t=g(n,"META",{name:!0,content:!0}),n.forEach(r),_=l(e),m=g(e,"P",{}),z(m).forEach(r),a=l(e),y(d.$$.fragment,e),o=l(e),y(f.$$.fragment,e),H=l(e),U=g(e,"P",{"data-svelte-h":!0}),S(U)!=="svelte-9ru7k9"&&(U.innerHTML=K),F=l(e),y(A.$$.fragment,e),L=l(e),x=g(e,"DIV",{class:!0});var I=z(x);y(C.$$.fragment,I),N=l(I),s=g(I,"DIV",{class:!0});var p=z(s);y(j.$$.fragment,p),X=l(p),W=g(p,"P",{"data-svelte-h":!0}),S(W)!=="svelte-1lisopl"&&(W.textContent=ee),E=l(p),R=g(p,"P",{"data-svelte-h":!0}),S(R)!=="svelte-1fnd9e6"&&(R.innerHTML=oe),V=l(p),J=g(p,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),S(J)!=="svelte-82moo4"&&(J.innerHTML=te),D=l(p),y(k.$$.fragment,p),O=l(p),y(T.$$.fragment,p),p.forEach(r),I.forEach(r),q=l(e),y(Z.$$.fragment,e),Q=l(e),P=g(e,"P",{}),z(P).forEach(r),this.h()},h(){B(t,"name","hf:doc:metadata"),B(t,"content",be),B(J,"class","tip"),B(s,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),B(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){u(document.head,t),c(e,_,n),c(e,m,n),c(e,a,n),M(d,e,n),c(e,o,n),M(f,e,n),c(e,H,n),c(e,U,n),c(e,F,n),M(A,e,n),c(e,L,n),c(e,x,n),M(C,x,null),u(x,N),u(x,s),M(j,s,null),u(s,X),u(s,W),u(s,E),u(s,R),u(s,V),u(s,J),u(s,D),M(k,s,null),u(s,O),M(T,s,null),c(e,q,n),M(Z,e,n),c(e,Q,n),c(e,P,n),Y=!0},p(e,[n]){const I={};n&2&&(I.$$scope={dirty:n,ctx:e}),k.$set(I);const p={};n&2&&(p.$$scope={dirty:n,ctx:e}),T.$set(p)},i(e){Y||(w(d.$$.fragment,e),w(f.$$.fragment,e),w(A.$$.fragment,e),w(C.$$.fragment,e),w(j.$$.fragment,e),w(k.$$.fragment,e),w(T.$$.fragment,e),w(Z.$$.fragment,e),Y=!0)},o(e){v(d.$$.fragment,e),v(f.$$.fragment,e),v(A.$$.fragment,e),v(C.$$.fragment,e),v(j.$$.fragment,e),v(k.$$.fragment,e),v(T.$$.fragment,e),v(Z.$$.fragment,e),Y=!1},d(e){e&&(r(_),r(m),r(a),r(o),r(H),r(U),r(F),r(L),r(x),r(q),r(Q),r(P)),r(t),$(d,e),$(f,e),$(A,e),$(C),$(j),$(k),$(T),$(Z,e)}}}const be='{"title":"AutoModel","local":"automodel","sections":[{"title":"AutoModel","local":"diffusers.AutoModel","sections":[],"depth":2}],"depth":1}';function ye(G){return le(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ue extends ce{constructor(t){super(),me(this,t,ye,_e,ie,{})}}export{Ue as component};
