import{s as me,o as ce,n as le}from"../chunks/scheduler.53228c21.js";import{S as fe,i as pe,e as h,s as d,c as g,h as ue,a as b,d as a,b as i,f as Y,g as _,j as F,k as S,l as u,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.fb2ec027.js";import{D as se}from"../chunks/Docstring.86a664ae.js";import{C as oe}from"../chunks/CodeBlock.d30a6509.js";import{E as de}from"../chunks/ExampleCodeBlock.15d6107c.js";import{H as ie,E as ge}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.09d4dba9.js";function be(W){let n,$="Example:",c,r,s;return r=new oe({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(){n=h("p"),n.textContent=$,c=d(),g(r.$$.fragment)},l(o){n=b(o,"P",{"data-svelte-h":!0}),F(n)!=="svelte-11lpom8"&&(n.textContent=$),c=i(o),_(r.$$.fragment,o)},m(o,f){l(o,n,f),l(o,c,f),M(r,o,f),s=!0},p:le,i(o){s||(y(r.$$.fragment,o),s=!0)},o(o){w(r.$$.fragment,o),s=!1},d(o){o&&(a(n),a(c)),v(r,o)}}}function _e(W){let n,$="If you get the error message below, you need to finetune the weights for your downstream task:",c,r,s;return r=new oe({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(){n=h("p"),n.textContent=$,c=d(),g(r.$$.fragment)},l(o){n=b(o,"P",{"data-svelte-h":!0}),F(n)!=="svelte-xueb0m"&&(n.textContent=$),c=i(o),_(r.$$.fragment,o)},m(o,f){l(o,n,f),l(o,c,f),M(r,o,f),s=!0},p:le,i(o){s||(y(r.$$.fragment,o),s=!0)},o(o){w(r.$$.fragment,o),s=!1},d(o){o&&(a(n),a(c)),v(r,o)}}}function Me(W){let n,$,c,r,s,o,f,H,T,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,Z,z,G,q,x,j,E,m,A,N,R,ne="Instantiate a pretrained PyTorch model from a pretrained model configuration.",D,B,ae=`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,J,re=`<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,U,ee,k,Q,C,V,L,X;return s=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"}}),Z=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}}),G=new ie({props:{title:"AutoModel",local:"diffusers.AutoModel",headingTag:"h2"}}),j=new se({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 se({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 de({props:{anchor:"diffusers.AutoModel.from_pretrained.example",$$slots:{default:[be]},$$scope:{ctx:W}}}),k=new de({props:{anchor:"diffusers.AutoModel.from_pretrained.example-2",$$slots:{default:[_e]},$$scope:{ctx:W}}}),C=new ge({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/auto_model.md"}}),{c(){n=h("meta"),$=d(),c=h("p"),r=d(),g(s.$$.fragment),o=d(),g(f.$$.fragment),H=d(),T=h("p"),T.innerHTML=te,P=d(),g(Z.$$.fragment),z=d(),g(G.$$.fragment),q=d(),x=h("div"),g(j.$$.fragment),E=d(),m=h("div"),g(A.$$.fragment),N=d(),R=h("p"),R.textContent=ne,D=d(),B=h("p"),B.innerHTML=ae,O=d(),J=h("blockquote"),J.innerHTML=re,K=d(),g(U.$$.fragment),ee=d(),g(k.$$.fragment),Q=d(),g(C.$$.fragment),V=d(),L=h("p"),this.h()},l(e){const t=ue("svelte-u9bgzb",document.head);n=b(t,"META",{name:!0,content:!0}),t.forEach(a),$=i(e),c=b(e,"P",{}),Y(c).forEach(a),r=i(e),_(s.$$.fragment,e),o=i(e),_(f.$$.fragment,e),H=i(e),T=b(e,"P",{"data-svelte-h":!0}),F(T)!=="svelte-rk85u"&&(T.innerHTML=te),P=i(e),_(Z.$$.fragment,e),z=i(e),_(G.$$.fragment,e),q=i(e),x=b(e,"DIV",{class:!0});var I=Y(x);_(j.$$.fragment,I),E=i(I),m=b(I,"DIV",{class:!0});var p=Y(m);_(A.$$.fragment,p),N=i(p),R=b(p,"P",{"data-svelte-h":!0}),F(R)!=="svelte-1lisopl"&&(R.textContent=ne),D=i(p),B=b(p,"P",{"data-svelte-h":!0}),F(B)!=="svelte-1fnd9e6"&&(B.innerHTML=ae),O=i(p),J=b(p,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),F(J)!=="svelte-82moo4"&&(J.innerHTML=re),K=i(p),_(U.$$.fragment,p),ee=i(p),_(k.$$.fragment,p),p.forEach(a),I.forEach(a),Q=i(e),_(C.$$.fragment,e),V=i(e),L=b(e,"P",{}),Y(L).forEach(a),this.h()},h(){S(n,"name","hf:doc:metadata"),S(n,"content",ye),S(J,"class","tip"),S(m,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),S(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){u(document.head,n),l(e,$,t),l(e,c,t),l(e,r,t),M(s,e,t),l(e,o,t),M(f,e,t),l(e,H,t),l(e,T,t),l(e,P,t),M(Z,e,t),l(e,z,t),M(G,e,t),l(e,q,t),l(e,x,t),M(j,x,null),u(x,E),u(x,m),M(A,m,null),u(m,N),u(m,R),u(m,D),u(m,B),u(m,O),u(m,J),u(m,K),M(U,m,null),u(m,ee),M(k,m,null),l(e,Q,t),M(C,e,t),l(e,V,t),l(e,L,t),X=!0},p(e,[t]){const I={};t&2&&(I.$$scope={dirty:t,ctx:e}),U.$set(I);const p={};t&2&&(p.$$scope={dirty:t,ctx:e}),k.$set(p)},i(e){X||(y(s.$$.fragment,e),y(f.$$.fragment,e),y(Z.$$.fragment,e),y(G.$$.fragment,e),y(j.$$.fragment,e),y(A.$$.fragment,e),y(U.$$.fragment,e),y(k.$$.fragment,e),y(C.$$.fragment,e),X=!0)},o(e){w(s.$$.fragment,e),w(f.$$.fragment,e),w(Z.$$.fragment,e),w(G.$$.fragment,e),w(j.$$.fragment,e),w(A.$$.fragment,e),w(U.$$.fragment,e),w(k.$$.fragment,e),w(C.$$.fragment,e),X=!1},d(e){e&&(a($),a(c),a(r),a(o),a(H),a(T),a(P),a(z),a(q),a(x),a(Q),a(V),a(L)),a(n),v(s,e),v(f,e),v(Z,e),v(G,e),v(j),v(A),v(U),v(k),v(C,e)}}}const ye='{"title":"AutoModel","local":"automodel","sections":[{"title":"AutoModel","local":"diffusers.AutoModel","sections":[],"depth":2}],"depth":1}';function we(W){return ce(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ge extends fe{constructor(n){super(),pe(this,n,we,Me,me,{})}}export{Ge as component};
