Buckets:
hf-doc-build/doc / diffusers /v0.18.2 /en /_app /pages /using-diffusers /other-formats.mdx-hf-doc-builder.js
| import{S as Hi,i as Xi,s as Pi,e as s,k as c,w as m,t as l,M as zi,c as a,d as o,m as h,a as i,x as y,h as r,b as p,N as Li,G as t,g as f,y as v,q as w,o as b,B as _,v as Fi}from"../../chunks/vendor-hf-doc-builder.js";import{T as Yi}from"../../chunks/Tip-hf-doc-builder.js";import{I as Ut}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as G}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as Qi}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";function qi(at){let u,$,d,g,V,J,ye,x;return{c(){u=s("p"),$=l("We highly recommend using the "),d=s("code"),g=l(".safetensors"),V=l(" format because it is more secure than traditional pickled files which are vulnerable and can be exploited to execute any code on your machine (learn more in the "),J=s("a"),ye=l("Load safetensors"),x=l(" guide)."),this.h()},l(Y){u=a(Y,"P",{});var E=i(u);$=r(E,"We highly recommend using the "),d=a(E,"CODE",{});var B=i(d);g=r(B,".safetensors"),B.forEach(o),V=r(E," format because it is more secure than traditional pickled files which are vulnerable and can be exploited to execute any code on your machine (learn more in the "),J=a(E,"A",{href:!0});var ve=i(J);ye=r(ve,"Load safetensors"),ve.forEach(o),x=r(E," guide)."),E.forEach(o),this.h()},h(){p(J,"href","using_safetensors")},m(Y,E){f(Y,u,E),t(u,$),t(u,d),t(d,g),t(u,V),t(u,J),t(J,ye),t(u,x)},d(Y){Y&&o(u)}}}function Oi(at){let u,$;return{c(){u=s("p"),$=l("\u{1F9EA} This is an experimental feature. Only Stable Diffusion v1 checkpoints are supported by the Convert KerasCV Space at the moment.")},l(d){u=a(d,"P",{});var g=i(u);$=r(g,"\u{1F9EA} This is an experimental feature. Only Stable Diffusion v1 checkpoints are supported by the Convert KerasCV Space at the moment."),g.forEach(o)},m(d,g){f(d,u,g),t(u,$)},d(d){d&&o(u)}}}function Ki(at){let u,$,d,g,V,J,ye,x,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ha,ml;return J=new Ut({}),B=new Qi({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/other-formats.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/other-formats.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/other-formats.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/other-formats.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/other-formats.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/other-formats.ipynb"}]}}),O=new Yi({props:{$$slots:{default:[qi]},$$scope:{ctx:at}}}),we=new Ut({}),be=new Ut({}),ge=new Ut({}),ke=new G({props:{code:"aHVnZ2luZ2ZhY2UtY2xpJTIwbG9naW4=",highlighted:"huggingface-cli login"}}),Te=new G({props:{code:"Z2l0JTIwbGZzJTIwaW5zdGFsbCUwQWdpdCUyMGNsb25lJTIwaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRkNpYXJhUm93bGVzJTJGVGVtcG9yYWxOZXQ=",highlighted:`git lfs install | |
| git <span class="hljs-built_in">clone</span> https://huggingface.co/CiaraRowles/TemporalNet`}}),$e=new G({props:{code:"Y2QlMjBUZW1wb3JhbE5ldCUyMCUyNiUyNiUyMGdpdCUyMGZldGNoJTIwb3JpZ2luJTIwcmVmcyUyRnByJTJGMTMlM0FwciUyRjEzJTBBZ2l0JTIwY2hlY2tvdXQlMjBwciUyRjEz",highlighted:`<span class="hljs-built_in">cd</span> TemporalNet && git fetch origin refs/pr/13:<span class="hljs-built_in">pr</span>/13 | |
| git checkout <span class="hljs-built_in">pr</span>/13`}}),Ge=new G({props:{code:"cHl0aG9uJTIwLi4lMkZkaWZmdXNlcnMlMkZzY3JpcHRzJTJGY29udmVydF9vcmlnaW5hbF9zdGFibGVfZGlmZnVzaW9uX3RvX2RpZmZ1c2Vycy5weSUyMC0tY2hlY2twb2ludF9wYXRoJTIwdGVtcG9yYWxuZXR2My5ja3B0JTIwLS1vcmlnaW5hbF9jb25maWdfZmlsZSUyMGNsZG1fdjE1LnlhbWwlMjAtLWR1bXBfcGF0aCUyMC4lMkYlMjAtLWNvbnRyb2xuZXQ=",highlighted:"python ../diffusers/scripts/convert_original_stable_diffusion_to_diffusers.py --checkpoint_path temporalnetv3.ckpt --original_config_file cldm_v15.yaml --dump_path ./ --controlnet"}}),Be=new G({props:{code:"Z2l0JTIwcHVzaCUyMG9yaWdpbiUyMHByJTJGMTMlM0FyZWZzJTJGcHIlMkYxMw==",highlighted:'git push origin <span class="hljs-built_in">pr</span>/13:refs/pr/13'}}),De=new Ut({}),ae=new Yi({props:{warning:!0,$$slots:{default:[Oi]},$$scope:{ctx:at}}}),Pe=new G({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIyc2F5YWtwYXVsJTJGdGV4dHVhbC1pbnZlcnNpb24tY2F0LWtlcmFzY3Zfc2RfZGlmZnVzZXJzX3BpcGVsaW5lJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline | |
| pipeline = DiffusionPipeline.from_pretrained(<span class="hljs-string">"sayakpaul/textual-inversion-cat-kerascv_sd_diffusers_pipeline"</span>)`}}),ze=new G({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIyc2F5YWtwYXVsJTJGdGV4dHVhbC1pbnZlcnNpb24tY2F0LWtlcmFzY3Zfc2RfZGlmZnVzZXJzX3BpcGVsaW5lJTIyKSUwQXBpcGVsaW5lLnRvKCUyMmN1ZGElMjIpJTBBJTBBcGxhY2Vob2xkZXJfdG9rZW4lMjAlM0QlMjAlMjIlM0NteS1mdW5ueS1jYXQtdG9rZW4lM0UlMjIlMEFwcm9tcHQlMjAlM0QlMjBmJTIydHdvJTIwJTdCcGxhY2Vob2xkZXJfdG9rZW4lN0QlMjBnZXR0aW5nJTIwbWFycmllZCUyQyUyMHBob3RvcmVhbGlzdGljJTJDJTIwaGlnaCUyMHF1YWxpdHklMjIlMEFpbWFnZSUyMCUzRCUyMHBpcGVsaW5lKHByb21wdCUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0Q1MCkuaW1hZ2VzJTVCMCU1RA==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline | |
| pipeline = DiffusionPipeline.from_pretrained(<span class="hljs-string">"sayakpaul/textual-inversion-cat-kerascv_sd_diffusers_pipeline"</span>) | |
| pipeline.to(<span class="hljs-string">"cuda"</span>) | |
| placeholder_token = <span class="hljs-string">"<my-funny-cat-token>"</span> | |
| prompt = <span class="hljs-string">f"two <span class="hljs-subst">{placeholder_token}</span> getting married, photorealistic, high quality"</span> | |
| image = pipeline(prompt, num_inference_steps=<span class="hljs-number">50</span>).images[<span class="hljs-number">0</span>]`}}),Le=new Ut({}),qe=new G({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTJDJTIwVW5pUENNdWx0aXN0ZXBTY2hlZHVsZXIlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmFuZGl0ZSUyRmFueXRoaW5nLXY0LjAlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjBzYWZldHlfY2hlY2tlciUzRE5vbmUlMEEpLnRvKCUyMmN1ZGElMjIpJTBBcGlwZWxpbmUuc2NoZWR1bGVyJTIwJTNEJTIwVW5pUENNdWx0aXN0ZXBTY2hlZHVsZXIuZnJvbV9jb25maWcocGlwZWxpbmUuc2NoZWR1bGVyLmNvbmZpZyk=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline, UniPCMultistepScheduler | |
| <span class="hljs-keyword">import</span> torch | |
| pipeline = DiffusionPipeline.from_pretrained( | |
| <span class="hljs-string">"andite/anything-v4.0"</span>, torch_dtype=torch.float16, safety_checker=<span class="hljs-literal">None</span> | |
| ).to(<span class="hljs-string">"cuda"</span>) | |
| pipeline.scheduler = UniPCMultistepScheduler.from_config(pipeline.scheduler.config)`}}),Ke=new G({props:{code:"JTIzJTIwdW5jb21tZW50JTIwdG8lMjBkb3dubG9hZCUyMHRoZSUyMHNhZmV0ZW5zb3IlMjB3ZWlnaHRzJTBBJTIzIXdnZXQlMjBodHRwcyUzQSUyRiUyRmNpdml0YWkuY29tJTJGYXBpJTJGZG93bmxvYWQlMkZtb2RlbHMlMkYxOTk5OCUyMC1PJTIwaG93bHNfbW92aW5nX2Nhc3RsZS5zYWZldGVuc29ycw==",highlighted:`<span class="hljs-comment"># uncomment to download the safetensor weights</span> | |
| <span class="hljs-comment">#!wget https://civitai.com/api/download/models/19998 -O howls_moving_castle.safetensors</span>`}}),et=new G({props:{code:"cGlwZWxpbmUubG9hZF9sb3JhX3dlaWdodHMoJTIyLiUyMiUyQyUyMHdlaWdodF9uYW1lJTNEJTIyaG93bHNfbW92aW5nX2Nhc3RsZS5zYWZldGVuc29ycyUyMik=",highlighted:'pipeline.load_lora_weights(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CUyMCUyMCUyMGdlbmVyYXRvciUzRHRvcmNoLm1hbnVhbF9zZWVkKDApJTJDJTBBKS5pbWFnZXM=",highlighted:`prompt = <span class="hljs-string">"masterpiece, illustration, ultra-detailed, cityscape, san francisco, golden gate bridge, california, bay area, in the snow, beautiful detailed starry sky"</span> | |
| negative_prompt = <span class="hljs-string">"lowres, cropped, worst quality, low quality, normal quality, artifacts, signature, watermark, username, blurry, more than one bridge, bad architecture"</span> | |
| images = pipeline( | |
| prompt=prompt, | |
| negative_prompt=negative_prompt, | |
| width=<span class="hljs-number">512</span>, | |
| height=<span class="hljs-number">512</span>, | |
| num_inference_steps=<span class="hljs-number">25</span>, | |
| num_images_per_prompt=<span class="hljs-number">4</span>, | |
| generator=torch.manual_seed(<span class="hljs-number">0</span>), | |
| ).images`}}),ot=new G({props:{code:"ZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBJTBBJTBBZGVmJTIwaW1hZ2VfZ3JpZChpbWdzJTJDJTIwcm93cyUzRDIlMkMlMjBjb2xzJTNEMiklM0ElMEElMjAlMjAlMjAlMjB3JTJDJTIwaCUyMCUzRCUyMGltZ3MlNUIwJTVELnNpemUlMEElMjAlMjAlMjAlMjBncmlkJTIwJTNEJTIwSW1hZ2UubmV3KCUyMlJHQiUyMiUyQyUyMHNpemUlM0QoY29scyUyMColMjB3JTJDJTIwcm93cyUyMColMjBoKSklMEElMEElMjAlMjAlMjAlMjBmb3IlMjBpJTJDJTIwaW1nJTIwaW4lMjBlbnVtZXJhdGUoaW1ncyklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBncmlkLnBhc3RlKGltZyUyQyUyMGJveCUzRChpJTIwJTI1JTIwY29scyUyMColMjB3JTJDJTIwaSUyMCUyRiUyRiUyMGNvbHMlMjAqJTIwaCkpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwZ3JpZCUwQSUwQSUwQWltYWdlX2dyaWQoaW1hZ2VzKQ==",highlighted:`<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">image_grid</span>(<span class="hljs-params">imgs, rows=<span class="hljs-number">2</span>, cols=<span class="hljs-number">2</span></span>): | |
| w, h = imgs[<span class="hljs-number">0</span>].size | |
| grid = Image.new(<span class="hljs-string">"RGB"</span>, size=(cols * w, rows * h)) | |
| <span class="hljs-keyword">for</span> i, img <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(imgs): | |
| grid.paste(img, box=(i % cols * w, i // cols * h)) | |
| <span class="hljs-keyword">return</span> grid | |
| image_grid(images)`}}),{c(){u=s("meta"),$=c(),d=s("h1"),g=s("a"),V=s("span"),m(J.$$.fragment),ye=c(),x=s("span"),Y=l("Load different Stable Diffusion formats"),E=c(),m(B.$$.fragment),ve=c(),U=s("p"),Gl=l("Stable Diffusion models are available in different formats depending on the framework they\u2019re trained and saved with, and where you download them from. Converting these formats for use in \u{1F917} Diffusers allows you to use all the features supported by the library, such as "),it=s("a"),jl=l("using different schedulers"),Sl=l(" for inference, "),nt=s("a"),Wl=l("building your custom pipeline"),Bl=l(", and a variety of techniques and methods for "),ft=s("a"),Dl=l("optimizing inference speed"),Al=l("."),Jo=c(),m(O.$$.fragment),To=c(),pt=s("p"),Nl=l("This guide will show you how to convert other Stable Diffusion formats to be compatible with \u{1F917} Diffusers."),Eo=c(),H=s("h2"),K=s("a"),Ct=s("span"),m(we.$$.fragment),Rl=c(),Zt=s("span"),Vl=l("PyTorch .ckpt"),$o=c(),M=s("p"),xl=l("The checkpoint - or "),It=s("code"),Yl=l(".ckpt"),Hl=l(" - format is commonly used to store and save models. The "),Gt=s("code"),Xl=l(".ckpt"),Pl=l(" file contains the entire model and is typically several GBs in size. While you can load and use a "),jt=s("code"),zl=l(".ckpt"),Ll=l(" file directly with the "),ct=s("a"),Fl=l("from_single_file()"),Ql=l(" method, it is generally better to convert the "),St=s("code"),ql=l(".ckpt"),Ol=l(" file to \u{1F917} Diffusers so both formats are available."),Uo=c(),D=s("p"),Kl=l("There are two options for converting a "),Wt=s("code"),er=l(".ckpt"),tr=l(" file; use a Space to convert the checkpoint or convert the "),Bt=s("code"),or=l(".ckpt"),lr=l(" file with a script."),Co=c(),X=s("h3"),ee=s("a"),Dt=s("span"),m(be.$$.fragment),rr=c(),At=s("span"),sr=l("Convert with a Space"),Zo=c(),C=s("p"),ar=l("The easiest and most convenient way to convert a "),Nt=s("code"),ir=l(".ckpt"),nr=l(" file is to use the "),_e=s("a"),fr=l("SD to Diffusers"),pr=l(" Space. You can follow the instructions on the Space to convert the "),Rt=s("code"),cr=l(".ckpt"),hr=l(" file."),Io=c(),te=s("p"),ur=l("This approach works well for basic models, but it may struggle with more customized models. You\u2019ll know the Space failed if it returns an empty pull request or error. In this case, you can try converting the "),Vt=s("code"),dr=l(".ckpt"),mr=l(" file with a script."),Go=c(),P=s("h3"),oe=s("a"),xt=s("span"),m(ge.$$.fragment),yr=c(),Yt=s("span"),vr=l("Convert with a script"),jo=c(),A=s("p"),wr=l("\u{1F917} Diffusers provides a "),Me=s("a"),br=l("conversion script"),_r=l(" for converting "),Ht=s("code"),gr=l(".ckpt"),Mr=l(" files. This approach is more reliable than the Space above."),So=c(),ht=s("p"),kr=l("Before you start, make sure you have a local clone of \u{1F917} Diffusers to run the script and log in to your Hugging Face account so you can open pull requests and push your converted model to the Hub."),Wo=c(),m(ke.$$.fragment),Bo=c(),ut=s("p"),Jr=l("To use the script:"),Do=c(),dt=s("ol"),j=s("li"),Tr=l("Git clone the repository containing the "),Xt=s("code"),Er=l(".ckpt"),$r=l(" file you want to convert. For this example, let\u2019s convert this "),Je=s("a"),Ur=l("TemporalNet"),Cr=c(),Pt=s("code"),Zr=l(".ckpt"),Ir=l(" file:"),Ao=c(),m(Te.$$.fragment),No=c(),Ee=s("ol"),zt=s("li"),Gr=l("Open a pull request on the repository where you\u2019re converting the checkpoint from:"),Ro=c(),m($e.$$.fragment),Vo=c(),z=s("ol"),Ue=s("li"),Lt=s("p"),jr=l("There are several input arguments to configure in the conversion script, but the most important ones are:"),Sr=c(),L=s("ul"),Ft=s("li"),le=s("p"),Qt=s("code"),Wr=l("checkpoint_path"),Br=l(": the path to the "),qt=s("code"),Dr=l(".ckpt"),Ar=l(" file to convert."),Nr=c(),Ot=s("li"),re=s("p"),Kt=s("code"),Rr=l("original_config_file"),Vr=l(": a YAML file defining the configuration of the original architecture. If you can\u2019t find this file, try searching for the YAML file in the GitHub repository where you found the "),eo=s("code"),xr=l(".ckpt"),Yr=l(" file."),Hr=c(),Ce=s("li"),mt=s("p"),to=s("code"),Xr=l("dump_path"),Pr=l(": the path to the converted model."),zr=c(),F=s("p"),Lr=l("For example, you can take the "),oo=s("code"),Fr=l("cldm_v15.yaml"),Qr=l(" file from the "),Ze=s("a"),qr=l("ControlNet"),Or=l(" repository because the TemporalNet model is a Stable Diffusion v1.5 and ControlNet model."),Kr=c(),lo=s("li"),Ie=s("p"),es=l("Now you can run the script to convert the "),ro=s("code"),ts=l(".ckpt"),os=l(" file:"),xo=c(),m(Ge.$$.fragment),Yo=c(),je=s("ol"),Se=s("li"),ls=l("Once the conversion is done, upload your converted model and test out the resulting "),We=s("a"),rs=l("pull request"),ss=l("!"),Ho=c(),m(Be.$$.fragment),Xo=c(),Q=s("h2"),se=s("a"),so=s("span"),m(De.$$.fragment),as=c(),ao=s("span"),is=l("Keras .pb or .h5"),Po=c(),m(ae.$$.fragment),zo=c(),k=s("p"),Ae=s("a"),ns=l("KerasCV"),fs=l(" supports training for "),Ne=s("a"),ps=l("Stable Diffusion"),cs=l(" v1 and v2. However, it offers limited support for experimenting with Stable Diffusion models for inference and deployment whereas \u{1F917} Diffusers has a more complete set of features for this purpose, such as different "),Re=s("a"),hs=l("noise schedulers"),us=l(", "),Ve=s("a"),ds=l("flash attention"),ms=l(", and "),xe=s("a"),ys=l(`other | |
| optimization techniques`),vs=l("."),Lo=c(),T=s("p"),ws=l("The "),Ye=s("a"),bs=l("Convert KerasCV"),_s=l(" Space converts "),io=s("code"),gs=l(".pb"),Ms=l(" or "),no=s("code"),ks=l(".h5"),Js=l(" files to PyTorch, and then wraps them in a "),yt=s("a"),Ts=l("StableDiffusionPipeline"),Es=l(" so it is ready for inference. The converted checkpoint is stored in a repository on the Hugging Face Hub."),Fo=c(),N=s("p"),$s=l("For this example, let\u2019s convert the "),He=s("a"),fo=s("code"),Us=l("sayakpaul/textual-inversion-kerasio"),Cs=l(" checkpoint which was trained with Textual Inversion. It uses the special token "),po=s("code"),Zs=l("<my-funny-cat>"),Is=l(" to personalize images with cats."),Qo=c(),vt=s("p"),Gs=l("The Convert KerasCV Space allows you to input the following:"),qo=c(),Z=s("ul"),co=s("li"),js=l("Your Hugging Face token."),Ss=c(),ho=s("li"),Ws=l("Paths to download the UNet and text encoder weights from. Depending on how the model was trained, you don\u2019t necessarily need to provide the paths to both the UNet and text encoder. For example, Textual Inversion only requires the embeddings from the text encoder and a text-to-image model only requires the UNet weights."),Bs=c(),uo=s("li"),Ds=l("Placeholder token is only applicable for textual inversion models."),As=c(),Xe=s("li"),Ns=l("The "),mo=s("code"),Rs=l("output_repo_prefix"),Vs=l(" is the name of the repository where the converted model is stored."),Oo=c(),ie=s("p"),xs=l("Click the "),yo=s("strong"),Ys=l("Submit"),Hs=l(" button to automatically convert the KerasCV checkpoint! Once the checkpoint is successfully converted, you\u2019ll see a link to the new repository containing the converted checkpoint. Follow the link to the new repository, and you\u2019ll see the Convert KerasCV Space generated a model card with an inference widget to try out the converted model."),Ko=c(),ne=s("p"),Xs=l("If you prefer to run inference with code, click on the "),vo=s("strong"),Ps=l("Use in Diffusers"),zs=l(" button in the upper right corner of the model card to copy and paste the code snippet:"),el=c(),m(Pe.$$.fragment),tl=c(),wt=s("p"),Ls=l("Then you can generate an image like:"),ol=c(),m(ze.$$.fragment),ll=c(),q=s("h2"),fe=s("a"),wo=s("span"),m(Le.$$.fragment),Fs=c(),bo=s("span"),Qs=l("A1111 LoRA files"),rl=c(),S=s("p"),Fe=s("a"),qs=l("Automatic1111"),Os=l(" (A1111) is a popular web UI for Stable Diffusion that supports model sharing platforms like "),Qe=s("a"),Ks=l("Civitai"),ea=l(". Models trained with the Low-Rank Adaptation (LoRA) technique are especially popular because they\u2019re fast to train and have a much smaller file size than a fully finetuned model. \u{1F917} Diffusers supports loading A1111 LoRA checkpoints with "),bt=s("a"),ta=l("load_lora_weights()"),oa=l(":"),sl=c(),m(qe.$$.fragment),al=c(),pe=s("p"),la=l("Download a LoRA checkpoint from Civitai; this example uses the "),Oe=s("a"),ra=l("Howls Moving Castle,Interior/Scenery LoRA (Ghibli Stlye)"),sa=l(" checkpoint, but feel free to try out any LoRA checkpoint!"),il=c(),m(Ke.$$.fragment),nl=c(),ce=s("p"),aa=l("Load the LoRA checkpoint into the pipeline with the "),_t=s("a"),ia=l("load_lora_weights()"),na=l(" method:"),fl=c(),m(et.$$.fragment),pl=c(),gt=s("p"),fa=l("Now you can use the pipeline to generate images:"),cl=c(),m(tt.$$.fragment),hl=c(),Mt=s("p"),pa=l("Finally, create a helper function to display the images:"),ul=c(),m(ot.$$.fragment),dl=c(),lt=s("div"),_o=s("img"),this.h()},l(e){const n=zi('[data-svelte="svelte-1phssyn"]',document.head);u=a(n,"META",{name:!0,content:!0}),n.forEach(o),$=h(e),d=a(e,"H1",{class:!0});var rt=i(d);g=a(rt,"A",{id:!0,class:!0,href:!0});var go=i(g);V=a(go,"SPAN",{});var ua=i(V);y(J.$$.fragment,ua),ua.forEach(o),go.forEach(o),ye=h(rt),x=a(rt,"SPAN",{});var da=i(x);Y=r(da,"Load different Stable Diffusion formats"),da.forEach(o),rt.forEach(o),E=h(e),y(B.$$.fragment,e),ve=h(e),U=a(e,"P",{});var he=i(U);Gl=r(he,"Stable Diffusion models are available in different formats depending on the framework they\u2019re trained and saved with, and where you download them from. Converting these formats for use in \u{1F917} Diffusers allows you to use all the features supported by the library, such as "),it=a(he,"A",{href:!0});var ma=i(it);jl=r(ma,"using different schedulers"),ma.forEach(o),Sl=r(he," for inference, "),nt=a(he,"A",{href:!0});var ya=i(nt);Wl=r(ya,"building your custom pipeline"),ya.forEach(o),Bl=r(he,", and a variety of techniques and methods for "),ft=a(he,"A",{href:!0});var va=i(ft);Dl=r(va,"optimizing inference speed"),va.forEach(o),Al=r(he,"."),he.forEach(o),Jo=h(e),y(O.$$.fragment,e),To=h(e),pt=a(e,"P",{});var wa=i(pt);Nl=r(wa,"This guide will show you how to convert other Stable Diffusion formats to be compatible with \u{1F917} Diffusers."),wa.forEach(o),Eo=h(e),H=a(e,"H2",{class:!0});var yl=i(H);K=a(yl,"A",{id:!0,class:!0,href:!0});var ba=i(K);Ct=a(ba,"SPAN",{});var _a=i(Ct);y(we.$$.fragment,_a),_a.forEach(o),ba.forEach(o),Rl=h(yl),Zt=a(yl,"SPAN",{});var ga=i(Zt);Vl=r(ga,"PyTorch .ckpt"),ga.forEach(o),yl.forEach(o),$o=h(e),M=a(e,"P",{});var I=i(M);xl=r(I,"The checkpoint - or "),It=a(I,"CODE",{});var Ma=i(It);Yl=r(Ma,".ckpt"),Ma.forEach(o),Hl=r(I," - format is commonly used to store and save models. The "),Gt=a(I,"CODE",{});var ka=i(Gt);Xl=r(ka,".ckpt"),ka.forEach(o),Pl=r(I," file contains the entire model and is typically several GBs in size. While you can load and use a "),jt=a(I,"CODE",{});var Ja=i(jt);zl=r(Ja,".ckpt"),Ja.forEach(o),Ll=r(I," file directly with the "),ct=a(I,"A",{href:!0});var Ta=i(ct);Fl=r(Ta,"from_single_file()"),Ta.forEach(o),Ql=r(I," method, it is generally better to convert the "),St=a(I,"CODE",{});var Ea=i(St);ql=r(Ea,".ckpt"),Ea.forEach(o),Ol=r(I," file to \u{1F917} Diffusers so both formats are available."),I.forEach(o),Uo=h(e),D=a(e,"P",{});var kt=i(D);Kl=r(kt,"There are two options for converting a "),Wt=a(kt,"CODE",{});var $a=i(Wt);er=r($a,".ckpt"),$a.forEach(o),tr=r(kt," file; use a Space to convert the checkpoint or convert the "),Bt=a(kt,"CODE",{});var Ua=i(Bt);or=r(Ua,".ckpt"),Ua.forEach(o),lr=r(kt," file with a script."),kt.forEach(o),Co=h(e),X=a(e,"H3",{class:!0});var vl=i(X);ee=a(vl,"A",{id:!0,class:!0,href:!0});var Ca=i(ee);Dt=a(Ca,"SPAN",{});var Za=i(Dt);y(be.$$.fragment,Za),Za.forEach(o),Ca.forEach(o),rr=h(vl),At=a(vl,"SPAN",{});var Ia=i(At);sr=r(Ia,"Convert with a Space"),Ia.forEach(o),vl.forEach(o),Zo=h(e),C=a(e,"P",{});var ue=i(C);ar=r(ue,"The easiest and most convenient way to convert a "),Nt=a(ue,"CODE",{});var Ga=i(Nt);ir=r(Ga,".ckpt"),Ga.forEach(o),nr=r(ue," file is to use the "),_e=a(ue,"A",{href:!0,rel:!0});var ja=i(_e);fr=r(ja,"SD to Diffusers"),ja.forEach(o),pr=r(ue," Space. You can follow the instructions on the Space to convert the "),Rt=a(ue,"CODE",{});var Sa=i(Rt);cr=r(Sa,".ckpt"),Sa.forEach(o),hr=r(ue," file."),ue.forEach(o),Io=h(e),te=a(e,"P",{});var wl=i(te);ur=r(wl,"This approach works well for basic models, but it may struggle with more customized models. You\u2019ll know the Space failed if it returns an empty pull request or error. In this case, you can try converting the "),Vt=a(wl,"CODE",{});var Wa=i(Vt);dr=r(Wa,".ckpt"),Wa.forEach(o),mr=r(wl," file with a script."),wl.forEach(o),Go=h(e),P=a(e,"H3",{class:!0});var bl=i(P);oe=a(bl,"A",{id:!0,class:!0,href:!0});var Ba=i(oe);xt=a(Ba,"SPAN",{});var Da=i(xt);y(ge.$$.fragment,Da),Da.forEach(o),Ba.forEach(o),yr=h(bl),Yt=a(bl,"SPAN",{});var Aa=i(Yt);vr=r(Aa,"Convert with a script"),Aa.forEach(o),bl.forEach(o),jo=h(e),A=a(e,"P",{});var Jt=i(A);wr=r(Jt,"\u{1F917} Diffusers provides a "),Me=a(Jt,"A",{href:!0,rel:!0});var Na=i(Me);br=r(Na,"conversion script"),Na.forEach(o),_r=r(Jt," for converting "),Ht=a(Jt,"CODE",{});var Ra=i(Ht);gr=r(Ra,".ckpt"),Ra.forEach(o),Mr=r(Jt," files. This approach is more reliable than the Space above."),Jt.forEach(o),So=h(e),ht=a(e,"P",{});var Va=i(ht);kr=r(Va,"Before you start, make sure you have a local clone of \u{1F917} Diffusers to run the script and log in to your Hugging Face account so you can open pull requests and push your converted model to the Hub."),Va.forEach(o),Wo=h(e),y(ke.$$.fragment,e),Bo=h(e),ut=a(e,"P",{});var xa=i(ut);Jr=r(xa,"To use the script:"),xa.forEach(o),Do=h(e),dt=a(e,"OL",{});var Ya=i(dt);j=a(Ya,"LI",{});var de=i(j);Tr=r(de,"Git clone the repository containing the "),Xt=a(de,"CODE",{});var Ha=i(Xt);Er=r(Ha,".ckpt"),Ha.forEach(o),$r=r(de," file you want to convert. For this example, let\u2019s convert this "),Je=a(de,"A",{href:!0,rel:!0});var Xa=i(Je);Ur=r(Xa,"TemporalNet"),Xa.forEach(o),Cr=h(de),Pt=a(de,"CODE",{});var Pa=i(Pt);Zr=r(Pa,".ckpt"),Pa.forEach(o),Ir=r(de," file:"),de.forEach(o),Ya.forEach(o),Ao=h(e),y(Te.$$.fragment,e),No=h(e),Ee=a(e,"OL",{start:!0});var za=i(Ee);zt=a(za,"LI",{});var La=i(zt);Gr=r(La,"Open a pull request on the repository where you\u2019re converting the checkpoint from:"),La.forEach(o),za.forEach(o),Ro=h(e),y($e.$$.fragment,e),Vo=h(e),z=a(e,"OL",{start:!0});var _l=i(z);Ue=a(_l,"LI",{});var gl=i(Ue);Lt=a(gl,"P",{});var Fa=i(Lt);jr=r(Fa,"There are several input arguments to configure in the conversion script, but the most important ones are:"),Fa.forEach(o),Sr=h(gl),L=a(gl,"UL",{});var Tt=i(L);Ft=a(Tt,"LI",{});var Qa=i(Ft);le=a(Qa,"P",{});var Mo=i(le);Qt=a(Mo,"CODE",{});var qa=i(Qt);Wr=r(qa,"checkpoint_path"),qa.forEach(o),Br=r(Mo,": the path to the "),qt=a(Mo,"CODE",{});var Oa=i(qt);Dr=r(Oa,".ckpt"),Oa.forEach(o),Ar=r(Mo," file to convert."),Mo.forEach(o),Qa.forEach(o),Nr=h(Tt),Ot=a(Tt,"LI",{});var Ka=i(Ot);re=a(Ka,"P",{});var ko=i(re);Kt=a(ko,"CODE",{});var ei=i(Kt);Rr=r(ei,"original_config_file"),ei.forEach(o),Vr=r(ko,": a YAML file defining the configuration of the original architecture. If you can\u2019t find this file, try searching for the YAML file in the GitHub repository where you found the "),eo=a(ko,"CODE",{});var ti=i(eo);xr=r(ti,".ckpt"),ti.forEach(o),Yr=r(ko," file."),ko.forEach(o),Ka.forEach(o),Hr=h(Tt),Ce=a(Tt,"LI",{});var Ml=i(Ce);mt=a(Ml,"P",{});var ca=i(mt);to=a(ca,"CODE",{});var oi=i(to);Xr=r(oi,"dump_path"),oi.forEach(o),Pr=r(ca,": the path to the converted model."),ca.forEach(o),zr=h(Ml),F=a(Ml,"P",{});var Et=i(F);Lr=r(Et,"For example, you can take the "),oo=a(Et,"CODE",{});var li=i(oo);Fr=r(li,"cldm_v15.yaml"),li.forEach(o),Qr=r(Et," file from the "),Ze=a(Et,"A",{href:!0,rel:!0});var ri=i(Ze);qr=r(ri,"ControlNet"),ri.forEach(o),Or=r(Et," repository because the TemporalNet model is a Stable Diffusion v1.5 and ControlNet model."),Et.forEach(o),Ml.forEach(o),Tt.forEach(o),gl.forEach(o),Kr=h(_l),lo=a(_l,"LI",{});var si=i(lo);Ie=a(si,"P",{});var kl=i(Ie);es=r(kl,"Now you can run the script to convert the "),ro=a(kl,"CODE",{});var ai=i(ro);ts=r(ai,".ckpt"),ai.forEach(o),os=r(kl," file:"),kl.forEach(o),si.forEach(o),_l.forEach(o),xo=h(e),y(Ge.$$.fragment,e),Yo=h(e),je=a(e,"OL",{start:!0});var ii=i(je);Se=a(ii,"LI",{});var Jl=i(Se);ls=r(Jl,"Once the conversion is done, upload your converted model and test out the resulting "),We=a(Jl,"A",{href:!0,rel:!0});var ni=i(We);rs=r(ni,"pull request"),ni.forEach(o),ss=r(Jl,"!"),Jl.forEach(o),ii.forEach(o),Ho=h(e),y(Be.$$.fragment,e),Xo=h(e),Q=a(e,"H2",{class:!0});var Tl=i(Q);se=a(Tl,"A",{id:!0,class:!0,href:!0});var fi=i(se);so=a(fi,"SPAN",{});var pi=i(so);y(De.$$.fragment,pi),pi.forEach(o),fi.forEach(o),as=h(Tl),ao=a(Tl,"SPAN",{});var ci=i(ao);is=r(ci,"Keras .pb or .h5"),ci.forEach(o),Tl.forEach(o),Po=h(e),y(ae.$$.fragment,e),zo=h(e),k=a(e,"P",{});var W=i(k);Ae=a(W,"A",{href:!0,rel:!0});var hi=i(Ae);ns=r(hi,"KerasCV"),hi.forEach(o),fs=r(W," supports training for "),Ne=a(W,"A",{href:!0,rel:!0});var ui=i(Ne);ps=r(ui,"Stable Diffusion"),ui.forEach(o),cs=r(W," v1 and v2. However, it offers limited support for experimenting with Stable Diffusion models for inference and deployment whereas \u{1F917} Diffusers has a more complete set of features for this purpose, such as different "),Re=a(W,"A",{href:!0,rel:!0});var di=i(Re);hs=r(di,"noise schedulers"),di.forEach(o),us=r(W,", "),Ve=a(W,"A",{href:!0,rel:!0});var mi=i(Ve);ds=r(mi,"flash attention"),mi.forEach(o),ms=r(W,", and "),xe=a(W,"A",{href:!0,rel:!0});var yi=i(xe);ys=r(yi,`other | |
| optimization techniques`),yi.forEach(o),vs=r(W,"."),W.forEach(o),Lo=h(e),T=a(e,"P",{});var R=i(T);ws=r(R,"The "),Ye=a(R,"A",{href:!0,rel:!0});var vi=i(Ye);bs=r(vi,"Convert KerasCV"),vi.forEach(o),_s=r(R," Space converts "),io=a(R,"CODE",{});var wi=i(io);gs=r(wi,".pb"),wi.forEach(o),Ms=r(R," or "),no=a(R,"CODE",{});var bi=i(no);ks=r(bi,".h5"),bi.forEach(o),Js=r(R," files to PyTorch, and then wraps them in a "),yt=a(R,"A",{href:!0});var _i=i(yt);Ts=r(_i,"StableDiffusionPipeline"),_i.forEach(o),Es=r(R," so it is ready for inference. The converted checkpoint is stored in a repository on the Hugging Face Hub."),R.forEach(o),Fo=h(e),N=a(e,"P",{});var $t=i(N);$s=r($t,"For this example, let\u2019s convert the "),He=a($t,"A",{href:!0,rel:!0});var gi=i(He);fo=a(gi,"CODE",{});var Mi=i(fo);Us=r(Mi,"sayakpaul/textual-inversion-kerasio"),Mi.forEach(o),gi.forEach(o),Cs=r($t," checkpoint which was trained with Textual Inversion. It uses the special token "),po=a($t,"CODE",{});var ki=i(po);Zs=r(ki,"<my-funny-cat>"),ki.forEach(o),Is=r($t," to personalize images with cats."),$t.forEach(o),Qo=h(e),vt=a(e,"P",{});var Ji=i(vt);Gs=r(Ji,"The Convert KerasCV Space allows you to input the following:"),Ji.forEach(o),qo=h(e),Z=a(e,"UL",{});var me=i(Z);co=a(me,"LI",{});var Ti=i(co);js=r(Ti,"Your Hugging Face token."),Ti.forEach(o),Ss=h(me),ho=a(me,"LI",{});var Ei=i(ho);Ws=r(Ei,"Paths to download the UNet and text encoder weights from. Depending on how the model was trained, you don\u2019t necessarily need to provide the paths to both the UNet and text encoder. For example, Textual Inversion only requires the embeddings from the text encoder and a text-to-image model only requires the UNet weights."),Ei.forEach(o),Bs=h(me),uo=a(me,"LI",{});var $i=i(uo);Ds=r($i,"Placeholder token is only applicable for textual inversion models."),$i.forEach(o),As=h(me),Xe=a(me,"LI",{});var El=i(Xe);Ns=r(El,"The "),mo=a(El,"CODE",{});var Ui=i(mo);Rs=r(Ui,"output_repo_prefix"),Ui.forEach(o),Vs=r(El," is the name of the repository where the converted model is stored."),El.forEach(o),me.forEach(o),Oo=h(e),ie=a(e,"P",{});var $l=i(ie);xs=r($l,"Click the "),yo=a($l,"STRONG",{});var Ci=i(yo);Ys=r(Ci,"Submit"),Ci.forEach(o),Hs=r($l," button to automatically convert the KerasCV checkpoint! Once the checkpoint is successfully converted, you\u2019ll see a link to the new repository containing the converted checkpoint. Follow the link to the new repository, and you\u2019ll see the Convert KerasCV Space generated a model card with an inference widget to try out the converted model."),$l.forEach(o),Ko=h(e),ne=a(e,"P",{});var Ul=i(ne);Xs=r(Ul,"If you prefer to run inference with code, click on the "),vo=a(Ul,"STRONG",{});var Zi=i(vo);Ps=r(Zi,"Use in Diffusers"),Zi.forEach(o),zs=r(Ul," button in the upper right corner of the model card to copy and paste the code snippet:"),Ul.forEach(o),el=h(e),y(Pe.$$.fragment,e),tl=h(e),wt=a(e,"P",{});var Ii=i(wt);Ls=r(Ii,"Then you can generate an image like:"),Ii.forEach(o),ol=h(e),y(ze.$$.fragment,e),ll=h(e),q=a(e,"H2",{class:!0});var Cl=i(q);fe=a(Cl,"A",{id:!0,class:!0,href:!0});var Gi=i(fe);wo=a(Gi,"SPAN",{});var ji=i(wo);y(Le.$$.fragment,ji),ji.forEach(o),Gi.forEach(o),Fs=h(Cl),bo=a(Cl,"SPAN",{});var Si=i(bo);Qs=r(Si,"A1111 LoRA files"),Si.forEach(o),Cl.forEach(o),rl=h(e),S=a(e,"P",{});var st=i(S);Fe=a(st,"A",{href:!0,rel:!0});var Wi=i(Fe);qs=r(Wi,"Automatic1111"),Wi.forEach(o),Os=r(st," (A1111) is a popular web UI for Stable Diffusion that supports model sharing platforms like "),Qe=a(st,"A",{href:!0,rel:!0});var Bi=i(Qe);Ks=r(Bi,"Civitai"),Bi.forEach(o),ea=r(st,". Models trained with the Low-Rank Adaptation (LoRA) technique are especially popular because they\u2019re fast to train and have a much smaller file size than a fully finetuned model. \u{1F917} Diffusers supports loading A1111 LoRA checkpoints with "),bt=a(st,"A",{href:!0});var Di=i(bt);ta=r(Di,"load_lora_weights()"),Di.forEach(o),oa=r(st,":"),st.forEach(o),sl=h(e),y(qe.$$.fragment,e),al=h(e),pe=a(e,"P",{});var Zl=i(pe);la=r(Zl,"Download a LoRA checkpoint from Civitai; this example uses the "),Oe=a(Zl,"A",{href:!0,rel:!0});var Ai=i(Oe);ra=r(Ai,"Howls Moving Castle,Interior/Scenery LoRA (Ghibli Stlye)"),Ai.forEach(o),sa=r(Zl," checkpoint, but feel free to try out any LoRA checkpoint!"),Zl.forEach(o),il=h(e),y(Ke.$$.fragment,e),nl=h(e),ce=a(e,"P",{});var Il=i(ce);aa=r(Il,"Load the LoRA checkpoint into the pipeline with the "),_t=a(Il,"A",{href:!0});var Ni=i(_t);ia=r(Ni,"load_lora_weights()"),Ni.forEach(o),na=r(Il," method:"),Il.forEach(o),fl=h(e),y(et.$$.fragment,e),pl=h(e),gt=a(e,"P",{});var Ri=i(gt);fa=r(Ri,"Now you can use the pipeline to generate images:"),Ri.forEach(o),cl=h(e),y(tt.$$.fragment,e),hl=h(e),Mt=a(e,"P",{});var Vi=i(Mt);pa=r(Vi,"Finally, create a helper function to display the images:"),Vi.forEach(o),ul=h(e),y(ot.$$.fragment,e),dl=h(e),lt=a(e,"DIV",{class:!0});var xi=i(lt);_o=a(xi,"IMG",{src:!0}),xi.forEach(o),this.h()},h(){p(u,"name","hf:doc:metadata"),p(u,"content",JSON.stringify(en)),p(g,"id","load-different-stable-diffusion-formats"),p(g,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(g,"href","#load-different-stable-diffusion-formats"),p(d,"class","relative group"),p(it,"href","schedulers"),p(nt,"href","write_own_pipeline"),p(ft,"href","./optimization/opt_overview"),p(K,"id","pytorch-ckpt"),p(K,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(K,"href","#pytorch-ckpt"),p(H,"class","relative group"),p(ct,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.from_single_file"),p(ee,"id","convert-with-a-space"),p(ee,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(ee,"href","#convert-with-a-space"),p(X,"class","relative group"),p(_e,"href","https://huggingface.co/spaces/diffusers/sd-to-diffusers"),p(_e,"rel","nofollow"),p(oe,"id","convert-with-a-script"),p(oe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(oe,"href","#convert-with-a-script"),p(P,"class","relative group"),p(Me,"href","https://github.com/huggingface/diffusers/blob/main/scripts/convert_original_stable_diffusion_to_diffusers.py"),p(Me,"rel","nofollow"),p(Je,"href","https://huggingface.co/CiaraRowles/TemporalNet"),p(Je,"rel","nofollow"),p(Ee,"start","2"),p(Ze,"href","https://github.com/lllyasviel/ControlNet/tree/main/models"),p(Ze,"rel","nofollow"),p(z,"start","3"),p(We,"href","https://huggingface.co/CiaraRowles/TemporalNet/discussions/13"),p(We,"rel","nofollow"),p(je,"start","5"),p(se,"id","keras-pb-or-h5"),p(se,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(se,"href","#keras-pb-or-h5"),p(Q,"class","relative group"),p(Ae,"href","https://keras.io/keras_cv/"),p(Ae,"rel","nofollow"),p(Ne,"href","https://github.com/keras-team/keras-cv/blob/master/keras_cv/models/stable_diffusion"),p(Ne,"rel","nofollow"),p(Re,"href","https://huggingface.co/docs/diffusers/using-diffusers/schedulers"),p(Re,"rel","nofollow"),p(Ve,"href","https://huggingface.co/docs/diffusers/optimization/xformers"),p(Ve,"rel","nofollow"),p(xe,"href","https://huggingface.co/docs/diffusers/optimization/fp16"),p(xe,"rel","nofollow"),p(Ye,"href","https://huggingface.co/spaces/sayakpaul/convert-kerascv-sd-diffusers"),p(Ye,"rel","nofollow"),p(yt,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),p(He,"href","https://huggingface.co/sayakpaul/textual-inversion-kerasio/tree/main"),p(He,"rel","nofollow"),p(fe,"id","a1111-lora-files"),p(fe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(fe,"href","#a1111-lora-files"),p(q,"class","relative group"),p(Fe,"href","https://github.com/AUTOMATIC1111/stable-diffusion-webui"),p(Fe,"rel","nofollow"),p(Qe,"href","https://civitai.com/"),p(Qe,"rel","nofollow"),p(bt,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline.load_lora_weights"),p(Oe,"href","https://civitai.com/models/14605?modelVersionId=19998"),p(Oe,"rel","nofollow"),p(_t,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline.load_lora_weights"),Li(_o.src,ha="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/a1111-lora-sf.png")||p(_o,"src",ha),p(lt,"class","flex justify-center")},m(e,n){t(document.head,u),f(e,$,n),f(e,d,n),t(d,g),t(g,V),v(J,V,null),t(d,ye),t(d,x),t(x,Y),f(e,E,n),v(B,e,n),f(e,ve,n),f(e,U,n),t(U,Gl),t(U,it),t(it,jl),t(U,Sl),t(U,nt),t(nt,Wl),t(U,Bl),t(U,ft),t(ft,Dl),t(U,Al),f(e,Jo,n),v(O,e,n),f(e,To,n),f(e,pt,n),t(pt,Nl),f(e,Eo,n),f(e,H,n),t(H,K),t(K,Ct),v(we,Ct,null),t(H,Rl),t(H,Zt),t(Zt,Vl),f(e,$o,n),f(e,M,n),t(M,xl),t(M,It),t(It,Yl),t(M,Hl),t(M,Gt),t(Gt,Xl),t(M,Pl),t(M,jt),t(jt,zl),t(M,Ll),t(M,ct),t(ct,Fl),t(M,Ql),t(M,St),t(St,ql),t(M,Ol),f(e,Uo,n),f(e,D,n),t(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),t(pe,Oe),t(Oe,ra),t(pe,sa),f(e,il,n),v(Ke,e,n),f(e,nl,n),f(e,ce,n),t(ce,aa),t(ce,_t),t(_t,ia),t(ce,na),f(e,fl,n),v(et,e,n),f(e,pl,n),f(e,gt,n),t(gt,fa),f(e,cl,n),v(tt,e,n),f(e,hl,n),f(e,Mt,n),t(Mt,pa),f(e,ul,n),v(ot,e,n),f(e,dl,n),f(e,lt,n),t(lt,_o),ml=!0},p(e,[n]){const rt={};n&2&&(rt.$$scope={dirty:n,ctx:e}),O.$set(rt);const go={};n&2&&(go.$$scope={dirty:n,ctx:e}),ae.$set(go)},i(e){ml||(w(J.$$.fragment,e),w(B.$$.fragment,e),w(O.$$.fragment,e),w(we.$$.fragment,e),w(be.$$.fragment,e),w(ge.$$.fragment,e),w(ke.$$.fragment,e),w(Te.$$.fragment,e),w($e.$$.fragment,e),w(Ge.$$.fragment,e),w(Be.$$.fragment,e),w(De.$$.fragment,e),w(ae.$$.fragment,e),w(Pe.$$.fragment,e),w(ze.$$.fragment,e),w(Le.$$.fragment,e),w(qe.$$.fragment,e),w(Ke.$$.fragment,e),w(et.$$.fragment,e),w(tt.$$.fragment,e),w(ot.$$.fragment,e),ml=!0)},o(e){b(J.$$.fragment,e),b(B.$$.fragment,e),b(O.$$.fragment,e),b(we.$$.fragment,e),b(be.$$.fragment,e),b(ge.$$.fragment,e),b(ke.$$.fragment,e),b(Te.$$.fragment,e),b($e.$$.fragment,e),b(Ge.$$.fragment,e),b(Be.$$.fragment,e),b(De.$$.fragment,e),b(ae.$$.fragment,e),b(Pe.$$.fragment,e),b(ze.$$.fragment,e),b(Le.$$.fragment,e),b(qe.$$.fragment,e),b(Ke.$$.fragment,e),b(et.$$.fragment,e),b(tt.$$.fragment,e),b(ot.$$.fragment,e),ml=!1},d(e){o(u),e&&o($),e&&o(d),_(J),e&&o(E),_(B,e),e&&o(ve),e&&o(U),e&&o(Jo),_(O,e),e&&o(To),e&&o(pt),e&&o(Eo),e&&o(H),_(we),e&&o($o),e&&o(M),e&&o(Uo),e&&o(D),e&&o(Co),e&&o(X),_(be),e&&o(Zo),e&&o(C),e&&o(Io),e&&o(te),e&&o(Go),e&&o(P),_(ge),e&&o(jo),e&&o(A),e&&o(So),e&&o(ht),e&&o(Wo),_(ke,e),e&&o(Bo),e&&o(ut),e&&o(Do),e&&o(dt),e&&o(Ao),_(Te,e),e&&o(No),e&&o(Ee),e&&o(Ro),_($e,e),e&&o(Vo),e&&o(z),e&&o(xo),_(Ge,e),e&&o(Yo),e&&o(je),e&&o(Ho),_(Be,e),e&&o(Xo),e&&o(Q),_(De),e&&o(Po),_(ae,e),e&&o(zo),e&&o(k),e&&o(Lo),e&&o(T),e&&o(Fo),e&&o(N),e&&o(Qo),e&&o(vt),e&&o(qo),e&&o(Z),e&&o(Oo),e&&o(ie),e&&o(Ko),e&&o(ne),e&&o(el),_(Pe,e),e&&o(tl),e&&o(wt),e&&o(ol),_(ze,e),e&&o(ll),e&&o(q),_(Le),e&&o(rl),e&&o(S),e&&o(sl),_(qe,e),e&&o(al),e&&o(pe),e&&o(il),_(Ke,e),e&&o(nl),e&&o(ce),e&&o(fl),_(et,e),e&&o(pl),e&&o(gt),e&&o(cl),_(tt,e),e&&o(hl),e&&o(Mt),e&&o(ul),_(ot,e),e&&o(dl),e&&o(lt)}}}const en={local:"load-different-stable-diffusion-formats",sections:[{local:"pytorch-ckpt",sections:[{local:"convert-with-a-space",title:"Convert with a Space"},{local:"convert-with-a-script",title:"Convert with a script"}],title:"PyTorch .ckpt"},{local:"keras-pb-or-h5",title:"Keras .pb or .h5"},{local:"a1111-lora-files",title:"A1111 LoRA files"}],title:"Load different Stable Diffusion formats"};function tn(at){return Fi(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class nn extends Hi{constructor(u){super();Xi(this,u,tn,Ki,Pi,{})}}export{nn as default,en as metadata}; | |
Xet Storage Details
- Size:
- 44.3 kB
- Xet hash:
- 950c2cfcab22953dc7a2c9c5195a428d79e4d3f984e80f3f5303c134ce3e33aa
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.