Buckets:
hf-doc-build/doc / diffusers /main /en /_app /pages /using-diffusers /using_safetensors.mdx-hf-doc-builder.js
| import{S as Oo,i as zo,s as Ao,e as l,k as h,w as Z,t as o,M as Vo,c as r,d as s,m as d,a as i,x as U,h as a,b as f,G as e,g as c,y as B,L as Xo,q as G,o as J,B as P,v as Yo}from"../../chunks/vendor-hf-doc-builder.js";import{I as Xs}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as he}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as Lo}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";function Fo(Ys){let C,Ye,W,D,de,x,yt,ue,bt,Le,R,Fe,m,O,wt,gt,pe,vt,_t,me,Et,Mt,z,ye,kt,$t,be,Tt,Zt,we,Ut,Bt,Qe,_,Gt,ge,Jt,Pt,ve,Ct,Wt,qe,A,He,u,jt,V,_e,St,Dt,Ee,It,Nt,Me,xt,Rt,ke,Ot,zt,$e,At,Vt,Te,Xt,Yt,Ke,E,Lt,Ze,Ft,Qt,Ue,qt,Ht,et,X,tt,M,Kt,Be,es,ts,le,ss,os,st,Y,ot,j,I,Ge,L,as,Je,ls,at,p,rs,Pe,is,ns,Ce,fs,cs,F,hs,ds,We,us,ps,je,ms,ys,Q,bs,ws,lt,y,gs,Se,vs,_s,De,Es,Ms,q,ks,$s,Ie,Ts,Zs,rt,H,it,S,N,Ne,K,Us,xe,Bs,nt,re,Gs,ft,k,Re,Oe,Js,Ps,g,ee,Cs,ze,Ws,js,Ss,Ae,Ds,Is,te,Ns,Ve,xs,Rs,se,Os,Xe,oe,zs,ae,As,Vs,ct;return x=new Xs({}),R=new Lo({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/using_safetensors.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/using_safetensors.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/using_safetensors.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/using_safetensors.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/using_safetensors.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/using_safetensors.ipynb"}]}}),A=new he({props:{code:"JTIzJTIwdW5jb21tZW50JTIwdG8lMjBpbnN0YWxsJTIwdGhlJTIwbmVjZXNzYXJ5JTIwbGlicmFyaWVzJTIwaW4lMjBDb2xhYiUwQSUyMyFwaXAlMjBpbnN0YWxsJTIwc2FmZXRlbnNvcnM=",highlighted:`<span class="hljs-comment"># uncomment to install the necessary libraries in Colab</span> | |
| <span class="hljs-comment">#!pip install safetensors</span>`}}),X=new he({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline | |
| pipeline = DiffusionPipeline.from_pretrained(<span class="hljs-string">"runwayml/stable-diffusion-v1-5"</span>, use_safetensors=<span class="hljs-literal">True</span>)`}}),Y=new he({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25QaXBlbGluZS5mcm9tX3NpbmdsZV9maWxlKCUwQSUyMCUyMCUyMCUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZXYXJyaW9yTWFtYTc3NyUyRk9yYW5nZU1peHMlMkZibG9iJTJGbWFpbiUyRk1vZGVscyUyRkFieXNzT3JhbmdlTWl4JTJGQWJ5c3NPcmFuZ2VNaXguc2FmZXRlbnNvcnMlMjIlMEEp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline | |
| pipeline = StableDiffusionPipeline.from_single_file( | |
| <span class="hljs-string">"https://huggingface.co/WarriorMama777/OrangeMixs/blob/main/Models/AbyssOrangeMix/AbyssOrangeMix.safetensors"</span> | |
| )`}}),L=new Xs({}),H=new he({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLTItMSUyMiUyQyUyMHJldmlzaW9uJTNEJTIycmVmcyUyRnByJTJGMjIlMjIlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline | |
| pipeline = DiffusionPipeline.from_pretrained( | |
| <span class="hljs-string">"stabilityai/stable-diffusion-2-1"</span>, revision=<span class="hljs-string">"refs/pr/22"</span>, use_safetensors=<span class="hljs-literal">True</span> | |
| )`}}),K=new Xs({}),te=new he({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLTItMSUyMiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUpJTBBJTIyTG9hZGVkJTIwaW4lMjBzYWZldGVuc29ycyUyMDAlM0EwMCUzQTAyLjAzMzY1OCUyMiUwQSUyMkxvYWRlZCUyMGluJTIwUHlUb3JjaCUyMDAlM0EwMCUzQTAyLjY2MzM3OSUyMg==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline | |
| pipeline = StableDiffusionPipeline.from_pretrained(<span class="hljs-string">"stabilityai/stable-diffusion-2-1"</span>, use_safetensors=<span class="hljs-literal">True</span>) | |
| <span class="hljs-string">"Loaded in safetensors 0:00:02.033658"</span> | |
| <span class="hljs-string">"Loaded in PyTorch 0:00:02.663379"</span>`}}),se=new he({props:{code:"c2FmZXRlbnNvcnMlM0ElMjAzLjQ4NzNtcyUwQVB5VG9yY2glM0ElMjAxNzIuNzUzN21z",highlighted:`safetensors: 3.4873ms | |
| PyTorch: 172.7537ms`}}),{c(){C=l("meta"),Ye=h(),W=l("h1"),D=l("a"),de=l("span"),Z(x.$$.fragment),yt=h(),ue=l("span"),bt=o("Load safetensors"),Le=h(),Z(R.$$.fragment),Fe=h(),m=l("p"),O=l("a"),wt=o("safetensors"),gt=o(" is a safe and fast file format for storing and loading tensors. Typically, PyTorch model weights are saved or "),pe=l("em"),vt=o("pickled"),_t=o(" into a "),me=l("code"),Et=o(".bin"),Mt=o(" file with Python\u2019s "),z=l("a"),ye=l("code"),kt=o("pickle"),$t=o(" utility. However, "),be=l("code"),Tt=o("pickle"),Zt=o(" is not secure and pickled files may contain malicious code that can be executed. safetensors is a secure alternative to "),we=l("code"),Ut=o("pickle"),Bt=o(", making it ideal for sharing model weights."),Qe=h(),_=l("p"),Gt=o("This guide will show you how you load "),ge=l("code"),Jt=o(".safetensor"),Pt=o(" files, and how to convert Stable Diffusion model weights stored in other formats to "),ve=l("code"),Ct=o(".safetensor"),Wt=o(". Before you start, make sure you have safetensors installed:"),qe=h(),Z(A.$$.fragment),He=h(),u=l("p"),jt=o("If you look at the "),V=l("a"),_e=l("code"),St=o("runwayml/stable-diffusion-v1-5"),Dt=o(" repository, you\u2019ll see weights inside the "),Ee=l("code"),It=o("text_encoder"),Nt=o(", "),Me=l("code"),xt=o("unet"),Rt=o(" and "),ke=l("code"),Ot=o("vae"),zt=o(" subfolders are stored in the "),$e=l("code"),At=o(".safetensors"),Vt=o(" format. By default, \u{1F917} Diffusers automatically loads these "),Te=l("code"),Xt=o(".safetensors"),Yt=o(" files from their subfolders if they\u2019re available in the model repository."),Ke=h(),E=l("p"),Lt=o("For more explicit control, you can optionally set "),Ze=l("code"),Ft=o("use_safetensors=True"),Qt=o(" (if "),Ue=l("code"),qt=o("safetensors"),Ht=o(" is not installed, you\u2019ll get an error message asking you to install it):"),et=h(),Z(X.$$.fragment),tt=h(),M=l("p"),Kt=o("However, model weights are not necessarily stored in separate subfolders like in the example above. Sometimes, all the weights are stored in a single "),Be=l("code"),es=o(".safetensors"),ts=o(" file. In this case, if the weights are Stable Diffusion weights, you can load the file directly with the "),le=l("a"),ss=o("from_single_file()"),os=o(" method:"),st=h(),Z(Y.$$.fragment),ot=h(),j=l("h2"),I=l("a"),Ge=l("span"),Z(L.$$.fragment),as=h(),Je=l("span"),ls=o("Convert to safetensors"),at=h(),p=l("p"),rs=o("Not all weights on the Hub are available in the "),Pe=l("code"),is=o(".safetensors"),ns=o(" format, and you may encounter weights stored as "),Ce=l("code"),fs=o(".bin"),cs=o(". In this case, use the "),F=l("a"),hs=o("Convert Space"),ds=o(" to convert the weights to "),We=l("code"),us=o(".safetensors"),ps=o(". The Convert Space downloads the pickled weights, converts them, and opens a Pull Request to upload the newly converted "),je=l("code"),ms=o(".safetensors"),ys=o(" file on the Hub. This way, if there is any malicious code contained in the pickled files, they\u2019re uploaded to the Hub - which has a "),Q=l("a"),bs=o("security scanner"),ws=o(" to detect unsafe files and suspicious pickle imports - instead of your computer."),lt=h(),y=l("p"),gs=o("You can use the model with the new "),Se=l("code"),vs=o(".safetensors"),_s=o(" weights by specifying the reference to the Pull Request in the "),De=l("code"),Es=o("revision"),Ms=o(" parameter (you can also test it in this "),q=l("a"),ks=o("Check PR"),$s=o(" Space on the Hub), for example "),Ie=l("code"),Ts=o("refs/pr/22"),Zs=o(":"),rt=h(),Z(H.$$.fragment),it=h(),S=l("h2"),N=l("a"),Ne=l("span"),Z(K.$$.fragment),Us=h(),xe=l("span"),Bs=o("Why use safetensors?"),nt=h(),re=l("p"),Gs=o("There are several reasons for using safetensors:"),ft=h(),k=l("ul"),Re=l("li"),Oe=l("p"),Js=o("Safety is the number one reason for using safetensors. As open-source and model distribution grows, it is important to be able to trust the model weights you downloaded don\u2019t contain any malicious code. The current size of the header in safetensors prevents parsing extremely large JSON files."),Ps=h(),g=l("li"),ee=l("p"),Cs=o("Loading speed between switching models is another reason to use safetensors, which performs zero-copy of the tensors. It is especially fast compared to "),ze=l("code"),Ws=o("pickle"),js=o(" if you\u2019re loading the weights to CPU (the default case), and just as fast if not faster when directly loading the weights to GPU. You\u2019ll only notice the performance difference if the model is already loaded, and not if you\u2019re downloading the weights or loading the model for the first time."),Ss=h(),Ae=l("p"),Ds=o("The time it takes to load the entire pipeline:"),Is=h(),Z(te.$$.fragment),Ns=h(),Ve=l("p"),xs=o("But the actual time it takes to load 500MB of the model weights is only:"),Rs=h(),Z(se.$$.fragment),Os=h(),Xe=l("li"),oe=l("p"),zs=o("Lazy loading is also supported in safetensors, which is useful in distributed settings to only load some of the tensors. This format allowed the "),ae=l("a"),As=o("BLOOM"),Vs=o(" model to be loaded in 45 seconds on 8 GPUs instead of 10 minutes with regular PyTorch weights."),this.h()},l(t){const n=Vo('[data-svelte="svelte-1phssyn"]',document.head);C=r(n,"META",{name:!0,content:!0}),n.forEach(s),Ye=d(t),W=r(t,"H1",{class:!0});var ht=i(W);D=r(ht,"A",{id:!0,class:!0,href:!0});var Ls=i(D);de=r(Ls,"SPAN",{});var Fs=i(de);U(x.$$.fragment,Fs),Fs.forEach(s),Ls.forEach(s),yt=d(ht),ue=r(ht,"SPAN",{});var Qs=i(ue);bt=a(Qs,"Load safetensors"),Qs.forEach(s),ht.forEach(s),Le=d(t),U(R.$$.fragment,t),Fe=d(t),m=r(t,"P",{});var v=i(m);O=r(v,"A",{href:!0,rel:!0});var qs=i(O);wt=a(qs,"safetensors"),qs.forEach(s),gt=a(v," is a safe and fast file format for storing and loading tensors. Typically, PyTorch model weights are saved or "),pe=r(v,"EM",{});var Hs=i(pe);vt=a(Hs,"pickled"),Hs.forEach(s),_t=a(v," into a "),me=r(v,"CODE",{});var Ks=i(me);Et=a(Ks,".bin"),Ks.forEach(s),Mt=a(v," file with Python\u2019s "),z=r(v,"A",{href:!0,rel:!0});var eo=i(z);ye=r(eo,"CODE",{});var to=i(ye);kt=a(to,"pickle"),to.forEach(s),eo.forEach(s),$t=a(v," utility. However, "),be=r(v,"CODE",{});var so=i(be);Tt=a(so,"pickle"),so.forEach(s),Zt=a(v," is not secure and pickled files may contain malicious code that can be executed. safetensors is a secure alternative to "),we=r(v,"CODE",{});var oo=i(we);Ut=a(oo,"pickle"),oo.forEach(s),Bt=a(v,", making it ideal for sharing model weights."),v.forEach(s),Qe=d(t),_=r(t,"P",{});var ie=i(_);Gt=a(ie,"This guide will show you how you load "),ge=r(ie,"CODE",{});var ao=i(ge);Jt=a(ao,".safetensor"),ao.forEach(s),Pt=a(ie," files, and how to convert Stable Diffusion model weights stored in other formats to "),ve=r(ie,"CODE",{});var lo=i(ve);Ct=a(lo,".safetensor"),lo.forEach(s),Wt=a(ie,". Before you start, make sure you have safetensors installed:"),ie.forEach(s),qe=d(t),U(A.$$.fragment,t),He=d(t),u=r(t,"P",{});var b=i(u);jt=a(b,"If you look at the "),V=r(b,"A",{href:!0,rel:!0});var ro=i(V);_e=r(ro,"CODE",{});var io=i(_e);St=a(io,"runwayml/stable-diffusion-v1-5"),io.forEach(s),ro.forEach(s),Dt=a(b," repository, you\u2019ll see weights inside the "),Ee=r(b,"CODE",{});var no=i(Ee);It=a(no,"text_encoder"),no.forEach(s),Nt=a(b,", "),Me=r(b,"CODE",{});var fo=i(Me);xt=a(fo,"unet"),fo.forEach(s),Rt=a(b," and "),ke=r(b,"CODE",{});var co=i(ke);Ot=a(co,"vae"),co.forEach(s),zt=a(b," subfolders are stored in the "),$e=r(b,"CODE",{});var ho=i($e);At=a(ho,".safetensors"),ho.forEach(s),Vt=a(b," format. By default, \u{1F917} Diffusers automatically loads these "),Te=r(b,"CODE",{});var uo=i(Te);Xt=a(uo,".safetensors"),uo.forEach(s),Yt=a(b," files from their subfolders if they\u2019re available in the model repository."),b.forEach(s),Ke=d(t),E=r(t,"P",{});var ne=i(E);Lt=a(ne,"For more explicit control, you can optionally set "),Ze=r(ne,"CODE",{});var po=i(Ze);Ft=a(po,"use_safetensors=True"),po.forEach(s),Qt=a(ne," (if "),Ue=r(ne,"CODE",{});var mo=i(Ue);qt=a(mo,"safetensors"),mo.forEach(s),Ht=a(ne," is not installed, you\u2019ll get an error message asking you to install it):"),ne.forEach(s),et=d(t),U(X.$$.fragment,t),tt=d(t),M=r(t,"P",{});var fe=i(M);Kt=a(fe,"However, model weights are not necessarily stored in separate subfolders like in the example above. Sometimes, all the weights are stored in a single "),Be=r(fe,"CODE",{});var yo=i(Be);es=a(yo,".safetensors"),yo.forEach(s),ts=a(fe," file. In this case, if the weights are Stable Diffusion weights, you can load the file directly with the "),le=r(fe,"A",{href:!0});var bo=i(le);ss=a(bo,"from_single_file()"),bo.forEach(s),os=a(fe," method:"),fe.forEach(s),st=d(t),U(Y.$$.fragment,t),ot=d(t),j=r(t,"H2",{class:!0});var dt=i(j);I=r(dt,"A",{id:!0,class:!0,href:!0});var wo=i(I);Ge=r(wo,"SPAN",{});var go=i(Ge);U(L.$$.fragment,go),go.forEach(s),wo.forEach(s),as=d(dt),Je=r(dt,"SPAN",{});var vo=i(Je);ls=a(vo,"Convert to safetensors"),vo.forEach(s),dt.forEach(s),at=d(t),p=r(t,"P",{});var w=i(p);rs=a(w,"Not all weights on the Hub are available in the "),Pe=r(w,"CODE",{});var _o=i(Pe);is=a(_o,".safetensors"),_o.forEach(s),ns=a(w," format, and you may encounter weights stored as "),Ce=r(w,"CODE",{});var Eo=i(Ce);fs=a(Eo,".bin"),Eo.forEach(s),cs=a(w,". In this case, use the "),F=r(w,"A",{href:!0,rel:!0});var Mo=i(F);hs=a(Mo,"Convert Space"),Mo.forEach(s),ds=a(w," to convert the weights to "),We=r(w,"CODE",{});var ko=i(We);us=a(ko,".safetensors"),ko.forEach(s),ps=a(w,". The Convert Space downloads the pickled weights, converts them, and opens a Pull Request to upload the newly converted "),je=r(w,"CODE",{});var $o=i(je);ms=a($o,".safetensors"),$o.forEach(s),ys=a(w," file on the Hub. This way, if there is any malicious code contained in the pickled files, they\u2019re uploaded to the Hub - which has a "),Q=r(w,"A",{href:!0,rel:!0});var To=i(Q);bs=a(To,"security scanner"),To.forEach(s),ws=a(w," to detect unsafe files and suspicious pickle imports - instead of your computer."),w.forEach(s),lt=d(t),y=r(t,"P",{});var $=i(y);gs=a($,"You can use the model with the new "),Se=r($,"CODE",{});var Zo=i(Se);vs=a(Zo,".safetensors"),Zo.forEach(s),_s=a($," weights by specifying the reference to the Pull Request in the "),De=r($,"CODE",{});var Uo=i(De);Es=a(Uo,"revision"),Uo.forEach(s),Ms=a($," parameter (you can also test it in this "),q=r($,"A",{href:!0,rel:!0});var Bo=i(q);ks=a(Bo,"Check PR"),Bo.forEach(s),$s=a($," Space on the Hub), for example "),Ie=r($,"CODE",{});var Go=i(Ie);Ts=a(Go,"refs/pr/22"),Go.forEach(s),Zs=a($,":"),$.forEach(s),rt=d(t),U(H.$$.fragment,t),it=d(t),S=r(t,"H2",{class:!0});var ut=i(S);N=r(ut,"A",{id:!0,class:!0,href:!0});var Jo=i(N);Ne=r(Jo,"SPAN",{});var Po=i(Ne);U(K.$$.fragment,Po),Po.forEach(s),Jo.forEach(s),Us=d(ut),xe=r(ut,"SPAN",{});var Co=i(xe);Bs=a(Co,"Why use safetensors?"),Co.forEach(s),ut.forEach(s),nt=d(t),re=r(t,"P",{});var Wo=i(re);Gs=a(Wo,"There are several reasons for using safetensors:"),Wo.forEach(s),ft=d(t),k=r(t,"UL",{});var ce=i(k);Re=r(ce,"LI",{});var jo=i(Re);Oe=r(jo,"P",{});var So=i(Oe);Js=a(So,"Safety is the number one reason for using safetensors. As open-source and model distribution grows, it is important to be able to trust the model weights you downloaded don\u2019t contain any malicious code. The current size of the header in safetensors prevents parsing extremely large JSON files."),So.forEach(s),jo.forEach(s),Ps=d(ce),g=r(ce,"LI",{});var T=i(g);ee=r(T,"P",{});var pt=i(ee);Cs=a(pt,"Loading speed between switching models is another reason to use safetensors, which performs zero-copy of the tensors. It is especially fast compared to "),ze=r(pt,"CODE",{});var Do=i(ze);Ws=a(Do,"pickle"),Do.forEach(s),js=a(pt," if you\u2019re loading the weights to CPU (the default case), and just as fast if not faster when directly loading the weights to GPU. You\u2019ll only notice the performance difference if the model is already loaded, and not if you\u2019re downloading the weights or loading the model for the first time."),pt.forEach(s),Ss=d(T),Ae=r(T,"P",{});var Io=i(Ae);Ds=a(Io,"The time it takes to load the entire pipeline:"),Io.forEach(s),Is=d(T),U(te.$$.fragment,T),Ns=d(T),Ve=r(T,"P",{});var No=i(Ve);xs=a(No,"But the actual time it takes to load 500MB of the model weights is only:"),No.forEach(s),Rs=d(T),U(se.$$.fragment,T),T.forEach(s),Os=d(ce),Xe=r(ce,"LI",{});var xo=i(Xe);oe=r(xo,"P",{});var mt=i(oe);zs=a(mt,"Lazy loading is also supported in safetensors, which is useful in distributed settings to only load some of the tensors. This format allowed the "),ae=r(mt,"A",{href:!0,rel:!0});var Ro=i(ae);As=a(Ro,"BLOOM"),Ro.forEach(s),Vs=a(mt," model to be loaded in 45 seconds on 8 GPUs instead of 10 minutes with regular PyTorch weights."),mt.forEach(s),xo.forEach(s),ce.forEach(s),this.h()},h(){f(C,"name","hf:doc:metadata"),f(C,"content",JSON.stringify(Qo)),f(D,"id","load-safetensors"),f(D,"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"),f(D,"href","#load-safetensors"),f(W,"class","relative group"),f(O,"href","https://github.com/huggingface/safetensors"),f(O,"rel","nofollow"),f(z,"href","https://docs.python.org/3/library/pickle.html"),f(z,"rel","nofollow"),f(V,"href","https://huggingface.co/runwayml/stable-diffusion-v1-5/tree/main"),f(V,"rel","nofollow"),f(le,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline.from_single_file"),f(I,"id","convert-to-safetensors"),f(I,"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"),f(I,"href","#convert-to-safetensors"),f(j,"class","relative group"),f(F,"href","https://huggingface.co/spaces/diffusers/convert"),f(F,"rel","nofollow"),f(Q,"href","https://huggingface.co/docs/hub/security-pickle#hubs-security-scanner"),f(Q,"rel","nofollow"),f(q,"href","https://huggingface.co/spaces/diffusers/check_pr"),f(q,"rel","nofollow"),f(N,"id","why-use-safetensors"),f(N,"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"),f(N,"href","#why-use-safetensors"),f(S,"class","relative group"),f(ae,"href","https://huggingface.co/bigscience/bloom"),f(ae,"rel","nofollow")},m(t,n){e(document.head,C),c(t,Ye,n),c(t,W,n),e(W,D),e(D,de),B(x,de,null),e(W,yt),e(W,ue),e(ue,bt),c(t,Le,n),B(R,t,n),c(t,Fe,n),c(t,m,n),e(m,O),e(O,wt),e(m,gt),e(m,pe),e(pe,vt),e(m,_t),e(m,me),e(me,Et),e(m,Mt),e(m,z),e(z,ye),e(ye,kt),e(m,$t),e(m,be),e(be,Tt),e(m,Zt),e(m,we),e(we,Ut),e(m,Bt),c(t,Qe,n),c(t,_,n),e(_,Gt),e(_,ge),e(ge,Jt),e(_,Pt),e(_,ve),e(ve,Ct),e(_,Wt),c(t,qe,n),B(A,t,n),c(t,He,n),c(t,u,n),e(u,jt),e(u,V),e(V,_e),e(_e,St),e(u,Dt),e(u,Ee),e(Ee,It),e(u,Nt),e(u,Me),e(Me,xt),e(u,Rt),e(u,ke),e(ke,Ot),e(u,zt),e(u,$e),e($e,At),e(u,Vt),e(u,Te),e(Te,Xt),e(u,Yt),c(t,Ke,n),c(t,E,n),e(E,Lt),e(E,Ze),e(Ze,Ft),e(E,Qt),e(E,Ue),e(Ue,qt),e(E,Ht),c(t,et,n),B(X,t,n),c(t,tt,n),c(t,M,n),e(M,Kt),e(M,Be),e(Be,es),e(M,ts),e(M,le),e(le,ss),e(M,os),c(t,st,n),B(Y,t,n),c(t,ot,n),c(t,j,n),e(j,I),e(I,Ge),B(L,Ge,null),e(j,as),e(j,Je),e(Je,ls),c(t,at,n),c(t,p,n),e(p,rs),e(p,Pe),e(Pe,is),e(p,ns),e(p,Ce),e(Ce,fs),e(p,cs),e(p,F),e(F,hs),e(p,ds),e(p,We),e(We,us),e(p,ps),e(p,je),e(je,ms),e(p,ys),e(p,Q),e(Q,bs),e(p,ws),c(t,lt,n),c(t,y,n),e(y,gs),e(y,Se),e(Se,vs),e(y,_s),e(y,De),e(De,Es),e(y,Ms),e(y,q),e(q,ks),e(y,$s),e(y,Ie),e(Ie,Ts),e(y,Zs),c(t,rt,n),B(H,t,n),c(t,it,n),c(t,S,n),e(S,N),e(N,Ne),B(K,Ne,null),e(S,Us),e(S,xe),e(xe,Bs),c(t,nt,n),c(t,re,n),e(re,Gs),c(t,ft,n),c(t,k,n),e(k,Re),e(Re,Oe),e(Oe,Js),e(k,Ps),e(k,g),e(g,ee),e(ee,Cs),e(ee,ze),e(ze,Ws),e(ee,js),e(g,Ss),e(g,Ae),e(Ae,Ds),e(g,Is),B(te,g,null),e(g,Ns),e(g,Ve),e(Ve,xs),e(g,Rs),B(se,g,null),e(k,Os),e(k,Xe),e(Xe,oe),e(oe,zs),e(oe,ae),e(ae,As),e(oe,Vs),ct=!0},p:Xo,i(t){ct||(G(x.$$.fragment,t),G(R.$$.fragment,t),G(A.$$.fragment,t),G(X.$$.fragment,t),G(Y.$$.fragment,t),G(L.$$.fragment,t),G(H.$$.fragment,t),G(K.$$.fragment,t),G(te.$$.fragment,t),G(se.$$.fragment,t),ct=!0)},o(t){J(x.$$.fragment,t),J(R.$$.fragment,t),J(A.$$.fragment,t),J(X.$$.fragment,t),J(Y.$$.fragment,t),J(L.$$.fragment,t),J(H.$$.fragment,t),J(K.$$.fragment,t),J(te.$$.fragment,t),J(se.$$.fragment,t),ct=!1},d(t){s(C),t&&s(Ye),t&&s(W),P(x),t&&s(Le),P(R,t),t&&s(Fe),t&&s(m),t&&s(Qe),t&&s(_),t&&s(qe),P(A,t),t&&s(He),t&&s(u),t&&s(Ke),t&&s(E),t&&s(et),P(X,t),t&&s(tt),t&&s(M),t&&s(st),P(Y,t),t&&s(ot),t&&s(j),P(L),t&&s(at),t&&s(p),t&&s(lt),t&&s(y),t&&s(rt),P(H,t),t&&s(it),t&&s(S),P(K),t&&s(nt),t&&s(re),t&&s(ft),t&&s(k),P(te),P(se)}}}const Qo={local:"load-safetensors",sections:[{local:"convert-to-safetensors",title:"Convert to safetensors"},{local:"why-use-safetensors",title:"Why use safetensors?"}],title:"Load safetensors"};function qo(Ys){return Yo(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class sa extends Oo{constructor(C){super();zo(this,C,qo,Fo,Ao,{})}}export{sa as default,Qo as metadata}; | |
Xet Storage Details
- Size:
- 22.3 kB
- Xet hash:
- c0a9b99299ee100a996812abf644e92663832fba08a20abafadeaec1338aa38d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.