import{s as P,n as D,o as K}from"../chunks/scheduler.53228c21.js";import{S as O,i as ee,e as m,s as l,c as b,h as te,a as i,d as s,b as a,f as S,g,j as _,k as B,l as se,m as o,n as $,t as U,o as Z,p as v}from"../chunks/index.100fac89.js";import{C as oe}from"../chunks/CopyLLMTxtMenu.999d3d86.js";import{C as z}from"../chunks/CodeBlock.d30a6509.js";import{H as le,E as ae}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.d27ae4df.js";function ne(H){let n,j,T,k,d,I,f,C,u,A='The <a href="/docs/diffusers/main/en/api/models/auto_model#diffusers.AutoModel">AutoModel</a> class automatically detects and loads the correct model class (UNet, transformer, VAE) from a <code>config.json</code> file. You don’t need to know the specific model class name ahead of time. It supports data types and device placement, and works across model types and libraries.',V,p,G="The example below loads a transformer from Diffusers and a text encoder from Transformers. Use the <code>subfolder</code> parameter to specify where to load the <code>config.json</code> file from.",X,c,x,M,F='<a href="/docs/diffusers/main/en/api/models/auto_model#diffusers.AutoModel">AutoModel</a> also loads models from the <a href="https://huggingface.co/models" rel="nofollow">Hub</a> that aren’t included in Diffusers. Set <code>trust_remote_code=True</code> in <a href="/docs/diffusers/main/en/api/models/auto_model#diffusers.AutoModel.from_pretrained">AutoModel.from_pretrained()</a> to load custom models.',E,y,R,h,L='If the custom model inherits from the <a href="/docs/diffusers/main/en/api/models/overview#diffusers.ModelMixin">ModelMixin</a> class, it gets access to the same features as Diffusers model classes, like <a href="../optimization/fp16#regional-compilation">regional compilation</a> and <a href="../optimization/memory#group-offloading">group offloading</a>.',Q,r,N='<p>Learn more about implementing custom models in the <a href="../using-diffusers/custom_pipeline_overview#community-components">Community components</a> guide.</p>',q,w,W,J,Y;return d=new oe({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),f=new le({props:{title:"AutoModel",local:"automodel",headingTag:"h1"}}),c=new z({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b01vZGVsJTJDJTIwRGlmZnVzaW9uUGlwZWxpbmUlMEElMEF0cmFuc2Zvcm1lciUyMCUzRCUyMEF1dG9Nb2RlbC5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyUXdlbiUyRlF3ZW4tSW1hZ2UlMjIlMkMlMjBzdWJmb2xkZXIlM0QlMjJ0cmFuc2Zvcm1lciUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYlMkMlMjBkZXZpY2VfbWFwJTNEJTIyY3VkYSUyMiUwQSklMEElMEF0ZXh0X2VuY29kZXIlMjAlM0QlMjBBdXRvTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMlF3ZW4lMkZRd2VuLUltYWdlJTIyJTJDJTIwc3ViZm9sZGVyJTNEJTIydGV4dF9lbmNvZGVyJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5iZmxvYXQxNiUyQyUyMGRldmljZV9tYXAlM0QlMjJjdWRhJTIyJTBBKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoModel, DiffusionPipeline

transformer = AutoModel.from_pretrained(
    <span class="hljs-string">&quot;Qwen/Qwen-Image&quot;</span>, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.bfloat16, device_map=<span class="hljs-string">&quot;cuda&quot;</span>
)

text_encoder = AutoModel.from_pretrained(
    <span class="hljs-string">&quot;Qwen/Qwen-Image&quot;</span>, subfolder=<span class="hljs-string">&quot;text_encoder&quot;</span>, torch_dtype=torch.bfloat16, device_map=<span class="hljs-string">&quot;cuda&quot;</span>
)`,wrap:!1}}),y=new z({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b01vZGVsJTBBJTBBdHJhbnNmb3JtZXIlMjAlM0QlMjBBdXRvTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmN1c3RvbSUyRmN1c3RvbS10cmFuc2Zvcm1lci1tb2RlbCUyMiUyQyUyMHRydXN0X3JlbW90ZV9jb2RlJTNEVHJ1ZSUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYlMkMlMjBkZXZpY2VfbWFwJTNEJTIyY3VkYSUyMiUwQSk=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoModel

transformer = AutoModel.from_pretrained(
    <span class="hljs-string">&quot;custom/custom-transformer-model&quot;</span>, trust_remote_code=<span class="hljs-literal">True</span>, torch_dtype=torch.bfloat16, device_map=<span class="hljs-string">&quot;cuda&quot;</span>
)`,wrap:!1}}),w=new ae({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/using-diffusers/automodel.md"}}),{c(){n=m("meta"),j=l(),T=m("p"),k=l(),b(d.$$.fragment),I=l(),b(f.$$.fragment),C=l(),u=m("p"),u.innerHTML=A,V=l(),p=m("p"),p.innerHTML=G,X=l(),b(c.$$.fragment),x=l(),M=m("p"),M.innerHTML=F,E=l(),b(y.$$.fragment),R=l(),h=m("p"),h.innerHTML=L,Q=l(),r=m("blockquote"),r.innerHTML=N,q=l(),b(w.$$.fragment),W=l(),J=m("p"),this.h()},l(e){const t=te("svelte-u9bgzb",document.head);n=i(t,"META",{name:!0,content:!0}),t.forEach(s),j=a(e),T=i(e,"P",{}),S(T).forEach(s),k=a(e),g(d.$$.fragment,e),I=a(e),g(f.$$.fragment,e),C=a(e),u=i(e,"P",{"data-svelte-h":!0}),_(u)!=="svelte-u12va8"&&(u.innerHTML=A),V=a(e),p=i(e,"P",{"data-svelte-h":!0}),_(p)!=="svelte-1kv6wq5"&&(p.innerHTML=G),X=a(e),g(c.$$.fragment,e),x=a(e),M=i(e,"P",{"data-svelte-h":!0}),_(M)!=="svelte-7su1bo"&&(M.innerHTML=F),E=a(e),g(y.$$.fragment,e),R=a(e),h=i(e,"P",{"data-svelte-h":!0}),_(h)!=="svelte-qzjvm1"&&(h.innerHTML=L),Q=a(e),r=i(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),_(r)!=="svelte-nrlzhz"&&(r.innerHTML=N),q=a(e),g(w.$$.fragment,e),W=a(e),J=i(e,"P",{}),S(J).forEach(s),this.h()},h(){B(n,"name","hf:doc:metadata"),B(n,"content",re),B(r,"class","note")},m(e,t){se(document.head,n),o(e,j,t),o(e,T,t),o(e,k,t),$(d,e,t),o(e,I,t),$(f,e,t),o(e,C,t),o(e,u,t),o(e,V,t),o(e,p,t),o(e,X,t),$(c,e,t),o(e,x,t),o(e,M,t),o(e,E,t),$(y,e,t),o(e,R,t),o(e,h,t),o(e,Q,t),o(e,r,t),o(e,q,t),$(w,e,t),o(e,W,t),o(e,J,t),Y=!0},p:D,i(e){Y||(U(d.$$.fragment,e),U(f.$$.fragment,e),U(c.$$.fragment,e),U(y.$$.fragment,e),U(w.$$.fragment,e),Y=!0)},o(e){Z(d.$$.fragment,e),Z(f.$$.fragment,e),Z(c.$$.fragment,e),Z(y.$$.fragment,e),Z(w.$$.fragment,e),Y=!1},d(e){e&&(s(j),s(T),s(k),s(I),s(C),s(u),s(V),s(p),s(X),s(x),s(M),s(E),s(R),s(h),s(Q),s(r),s(q),s(W),s(J)),s(n),v(d,e),v(f,e),v(c,e),v(y,e),v(w,e)}}}const re='{"title":"AutoModel","local":"automodel","sections":[],"depth":1}';function me(H){return K(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ce extends O{constructor(n){super(),ee(this,n,me,ne,P,{})}}export{ce as component};
