import{S as no,i as oo,s as lo,e as i,k as d,w as g,t as o,M as ro,c as s,d as a,m as c,a as n,x as _,h as l,b as r,N as so,G as e,g as p,y as b,L as fo,q as v,o as y,B as S,v as co}from"../../../../chunks/vendor-hf-doc-builder.js";import{D as Vt}from"../../../../chunks/Docstring-hf-doc-builder.js";import{C as Cs}from"../../../../chunks/CodeBlock-hf-doc-builder.js";import{I as ie}from"../../../../chunks/IconCopyLink-hf-doc-builder.js";function po(Ls){let k,Wt,U,J,et,se,Ua,tt,Ia,Ot,V,Za,ne,Ca,La,jt,Te,Ga,Rt,ke,at,Aa,Ft,oe,it,Na,Ja,qt,W,st,P,nt,Va,Wa,ot,Oa,ja,Ue,Ra,Fa,Ie,qa,Ba,lt,M,rt,le,za,Ha,ft,dt,Ya,Xa,Ze,re,Ce,Gs,Qa,Le,fe,Ge,As,Bt,I,O,ct,de,Ka,pt,ei,zt,Ae,ce,ti,Ne,ai,ii,Ht,Z,j,ut,pe,si,ht,ni,Yt,D,oi,Je,li,ri,mt,fi,di,Ve,ci,pi,Xt,C,R,gt,ue,ui,_t,hi,Qt,x,mi,bt,gi,_i,We,bi,vi,Kt,he,ea,F,yi,vt,Si,wi,ta,L,q,yt,me,Di,St,Ei,aa,B,Pi,ge,Mi,$i,ia,_e,sa,w,xi,wt,Ti,ki,Dt,Ui,Ii,Et,Zi,Ci,Pt,Li,Gi,na,G,z,Mt,be,Ai,$t,Ni,oa,u,Ji,Oe,Vi,Wi,xt,Oi,ji,je,Ri,Fi,Re,qi,Bi,Fe,zi,Hi,qe,Yi,Xi,Be,Qi,Ki,Tt,es,ts,kt,as,is,ze,ss,ns,la,ve,ra,A,H,Ut,ye,os,It,ls,fa,$,Se,rs,Zt,fs,ds,Y,we,cs,Ct,ps,da,N,X,Lt,De,us,Gt,hs,ca,m,Ee,ms,At,gs,_s,He,bs,Ye,vs,ys,Pe,Ss,Xe,ws,Ds,Es,Q,Me,Ps,Nt,Ms,$s,K,$e,xs,xe,Ts,Jt,ks,Us,pa;return se=new ie({}),de=new ie({}),pe=new ie({}),ue=new ie({}),he=new Cs({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lU2FmZSUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmVTYWZlLmZyb21fcHJldHJhaW5lZCglMjJBSU1MLVRVREElMkZzdGFibGUtZGlmZnVzaW9uLXNhZmUlMjIpJTBBcGlwZWxpbmUuc2FmZXR5X2NvbmNlcHQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipelineSafe

<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline = StableDiffusionPipelineSafe.from_pretrained(<span class="hljs-string">&quot;AIML-TUDA/stable-diffusion-safe&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline.safety_concept`}}),me=new ie({}),_e=new Cs({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lU2FmZSUwQWZyb20lMjBkaWZmdXNlcnMucGlwZWxpbmVzLnN0YWJsZV9kaWZmdXNpb25fc2FmZSUyMGltcG9ydCUyMFNhZmV0eUNvbmZpZyUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmVTYWZlLmZyb21fcHJldHJhaW5lZCglMjJBSU1MLVRVREElMkZzdGFibGUtZGlmZnVzaW9uLXNhZmUlMjIpJTBBcHJvbXB0JTIwJTNEJTIwJTIydGhlJTIwZm91ciUyMGhvcnNld29tZW4lMjBvZiUyMHRoZSUyMGFwb2NhbHlwc2UlMkMlMjBwYWludGluZyUyMGJ5JTIwdG9tJTIwb2YlMjBmaW5sYW5kJTJDJTIwZ2FzdG9uJTIwYnVzc2llcmUlMkMlMjBjcmFpZyUyMG11bGxpbnMlMkMlMjBqLiUyMGMuJTIwbGV5ZW5kZWNrZXIlMjIlMEFvdXQlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlM0Rwcm9tcHQlMkMlMjAqKlNhZmV0eUNvbmZpZy5NQVgp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipelineSafe
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers.pipelines.stable_diffusion_safe <span class="hljs-keyword">import</span> SafetyConfig

<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline = StableDiffusionPipelineSafe.from_pretrained(<span class="hljs-string">&quot;AIML-TUDA/stable-diffusion-safe&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;the four horsewomen of the apocalypse, painting by tom of finland, gaston bussiere, craig mullins, j. c. leyendecker&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>out = pipeline(prompt=prompt, **SafetyConfig.MAX)`}}),be=new ie({}),ve=new Cs({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lU2FmZSUyQyUyMEV1bGVyRGlzY3JldGVTY2hlZHVsZXIlMEElMEFwaXBlbGluZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lU2FmZS5mcm9tX3ByZXRyYWluZWQoJTIyQUlNTC1UVURBJTJGc3RhYmxlLWRpZmZ1c2lvbi1zYWZlJTIyKSUwQXBpcGVsaW5lLnNjaGVkdWxlciUyMCUzRCUyMEV1bGVyRGlzY3JldGVTY2hlZHVsZXIuZnJvbV9jb25maWcocGlwZWxpbmUuc2NoZWR1bGVyLmNvbmZpZyklMEElMEElMjMlMjBvciUwQWV1bGVyX3NjaGVkdWxlciUyMCUzRCUyMEV1bGVyRGlzY3JldGVTY2hlZHVsZXIuZnJvbV9wcmV0cmFpbmVkKCUyMkFJTUwtVFVEQSUyRnN0YWJsZS1kaWZmdXNpb24tc2FmZSUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnNjaGVkdWxlciUyMiklMEFwaXBlbGluZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lU2FmZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyQUlNTC1UVURBJTJGc3RhYmxlLWRpZmZ1c2lvbi1zYWZlJTIyJTJDJTIwc2NoZWR1bGVyJTNEZXVsZXJfc2NoZWR1bGVyJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipelineSafe, EulerDiscreteScheduler

<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline = StableDiffusionPipelineSafe.from_pretrained(<span class="hljs-string">&quot;AIML-TUDA/stable-diffusion-safe&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline.scheduler = EulerDiscreteScheduler.from_config(pipeline.scheduler.config)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># or</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>euler_scheduler = EulerDiscreteScheduler.from_pretrained(<span class="hljs-string">&quot;AIML-TUDA/stable-diffusion-safe&quot;</span>, subfolder=<span class="hljs-string">&quot;scheduler&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline = StableDiffusionPipelineSafe.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;AIML-TUDA/stable-diffusion-safe&quot;</span>, scheduler=euler_scheduler
<span class="hljs-meta">... </span>)`}}),ye=new ie({}),Se=new Vt({props:{name:"class diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput",anchor:"diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput",parameters:[{name:"images",val:": typing.Union[typing.List[PIL.Image.Image], numpy.ndarray]"},{name:"nsfw_content_detected",val:": typing.Optional[typing.List[bool]]"},{name:"unsafe_images",val:": typing.Union[typing.List[PIL.Image.Image], numpy.ndarray, NoneType]"},{name:"applied_safety_concept",val:": typing.Optional[str]"}],parametersDescription:[{anchor:"diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput.images",description:`<strong>images</strong> (<code>List[PIL.Image.Image]</code> or <code>np.ndarray</code>) &#x2014;
List of denoised PIL images of length <code>batch_size</code> or numpy array of shape <code>(batch_size, height, width, num_channels)</code>. PIL images or numpy array present the denoised images of the diffusion pipeline.`,name:"images"},{anchor:"diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput.nsfw_content_detected",description:`<strong>nsfw_content_detected</strong> (<code>List[bool]</code>) &#x2014;
List of flags denoting whether the corresponding generated image likely represents &#x201C;not-safe-for-work&#x201D;
(nsfw) content, or <code>None</code> if safety checking could not be performed.`,name:"nsfw_content_detected"},{anchor:"diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput.images",description:`<strong>images</strong> (<code>List[PIL.Image.Image]</code> or <code>np.ndarray</code>) &#x2014;
List of denoised PIL images that were flagged by the safety checker any may contain &#x201C;not-safe-for-work&#x201D;
(nsfw) content, or <code>None</code> if no safety check was performed or no images were flagged.`,name:"images"},{anchor:"diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput.applied_safety_concept",description:`<strong>applied_safety_concept</strong> (<code>str</code>) &#x2014;
The safety concept that was applied for safety guidance, or <code>None</code> if safety guidance was disabled`,name:"applied_safety_concept"}],source:"https://github.com/huggingface/diffusers/blob/v0.18.0/src/diffusers/pipelines/stable_diffusion_safe/__init__.py#L45"}}),we=new Vt({props:{name:"__call__",anchor:"diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput.__call__",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}]}}),De=new ie({}),Ee=new Vt({props:{name:"class diffusers.StableDiffusionPipelineSafe",anchor:"diffusers.StableDiffusionPipelineSafe",parameters:[{name:"vae",val:": AutoencoderKL"},{name:"text_encoder",val:": CLIPTextModel"},{name:"tokenizer",val:": CLIPTokenizer"},{name:"unet",val:": UNet2DConditionModel"},{name:"scheduler",val:": KarrasDiffusionSchedulers"},{name:"safety_checker",val:": SafeStableDiffusionSafetyChecker"},{name:"feature_extractor",val:": CLIPImageProcessor"},{name:"requires_safety_checker",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.StableDiffusionPipelineSafe.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/v0.18.0/en/api/models/autoencoderkl#diffusers.AutoencoderKL">AutoencoderKL</a>) &#x2014;
Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.StableDiffusionPipelineSafe.text_encoder",description:`<strong>text_encoder</strong> (<code>CLIPTextModel</code>) &#x2014;
Frozen text-encoder. Stable Diffusion uses the text portion of
<a href="https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel" rel="nofollow">CLIP</a>, specifically
the <a href="https://huggingface.co/openai/clip-vit-large-patch14" rel="nofollow">clip-vit-large-patch14</a> variant.`,name:"text_encoder"},{anchor:"diffusers.StableDiffusionPipelineSafe.tokenizer",description:`<strong>tokenizer</strong> (<code>CLIPTokenizer</code>) &#x2014;
Tokenizer of class
<a href="https://huggingface.co/docs/transformers/v4.21.0/en/model_doc/clip#transformers.CLIPTokenizer" rel="nofollow">CLIPTokenizer</a>.`,name:"tokenizer"},{anchor:"diffusers.StableDiffusionPipelineSafe.unet",description:'<strong>unet</strong> (<a href="/docs/diffusers/v0.18.0/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) &#x2014; Conditional U-Net architecture to denoise the encoded image latents.',name:"unet"},{anchor:"diffusers.StableDiffusionPipelineSafe.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/v0.18.0/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) &#x2014;
A scheduler to be used in combination with <code>unet</code> to denoise the encoded image latents. Can be one of
<a href="/docs/diffusers/v0.18.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/v0.18.0/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/v0.18.0/en/api/schedulers/pndm#diffusers.PNDMScheduler">PNDMScheduler</a>.`,name:"scheduler"},{anchor:"diffusers.StableDiffusionPipelineSafe.safety_checker",description:`<strong>safety_checker</strong> (<code>StableDiffusionSafetyChecker</code>) &#x2014;
Classification module that estimates whether generated images could be considered offensive or harmful.
Please, refer to the <a href="https://huggingface.co/runwayml/stable-diffusion-v1-5" rel="nofollow">model card</a> for details.`,name:"safety_checker"},{anchor:"diffusers.StableDiffusionPipelineSafe.feature_extractor",description:`<strong>feature_extractor</strong> (<code>CLIPImageProcessor</code>) &#x2014;
Model that extracts features from generated images to be used as inputs for the <code>safety_checker</code>.`,name:"feature_extractor"}],source:"https://github.com/huggingface/diffusers/blob/v0.18.0/src/diffusers/pipelines/stable_diffusion_safe/pipeline_stable_diffusion_safe.py#L22"}}),Me=new Vt({props:{name:"__call__",anchor:"diffusers.StableDiffusionPipelineSafe.__call__",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]]"},{name:"height",val:": typing.Optional[int] = None"},{name:"width",val:": typing.Optional[int] = None"},{name:"num_inference_steps",val:": int = 50"},{name:"guidance_scale",val:": float = 7.5"},{name:"negative_prompt",val:": typing.Union[str, typing.List[str], NoneType] = None"},{name:"num_images_per_prompt",val:": typing.Optional[int] = 1"},{name:"eta",val:": float = 0.0"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_type",val:": typing.Optional[str] = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"callback",val:": typing.Union[typing.Callable[[int, int, torch.FloatTensor], NoneType], NoneType] = None"},{name:"callback_steps",val:": int = 1"},{name:"sld_guidance_scale",val:": typing.Optional[float] = 1000"},{name:"sld_warmup_steps",val:": typing.Optional[int] = 10"},{name:"sld_threshold",val:": typing.Optional[float] = 0.01"},{name:"sld_momentum_scale",val:": typing.Optional[float] = 0.3"},{name:"sld_mom_beta",val:": typing.Optional[float] = 0.4"}],parametersDescription:[{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>) &#x2014;
The prompt or prompts to guide the image generation.`,name:"prompt"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to self.unet.config.sample_size * self.vae_scale_factor) &#x2014;
The height in pixels of the generated image.`,name:"height"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.width",description:`<strong>width</strong> (<code>int</code>, <em>optional</em>, defaults to self.unet.config.sample_size * self.vae_scale_factor) &#x2014;
The width in pixels of the generated image.`,name:"width"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 50) &#x2014;
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.`,name:"num_inference_steps"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 7.5) &#x2014;
Guidance scale as defined in <a href="https://arxiv.org/abs/2207.12598" rel="nofollow">Classifier-Free Diffusion Guidance</a>.
<code>guidance_scale</code> is defined as <code>w</code> of equation 2. of <a href="https://arxiv.org/pdf/2205.11487.pdf" rel="nofollow">Imagen
Paper</a>. Guidance scale is enabled by setting <code>guidance_scale &gt; 1</code>. Higher guidance scale encourages to generate images that are closely linked to the text <code>prompt</code>,
usually at the expense of lower image quality.`,name:"guidance_scale"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts not to guide the image generation. Ignored when not using guidance (i.e., ignored
if <code>guidance_scale</code> is less than <code>1</code>).`,name:"negative_prompt"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of images to generate per prompt.`,name:"num_images_per_prompt"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.eta",description:`<strong>eta</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Corresponds to parameter eta (&#x3B7;) in the DDIM paper: <a href="https://arxiv.org/abs/2010.02502" rel="nofollow">https://arxiv.org/abs/2010.02502</a>. Only applies to
<a href="/docs/diffusers/v0.18.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">schedulers.DDIMScheduler</a>, will be ignored for others.`,name:"eta"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
One or a list of <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow">torch generator(s)</a>
to make generation deterministic.`,name:"generator"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.latents",description:`<strong>latents</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents, sampled from a Gaussian distribution, to be used as inputs for image
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
tensor will ge generated by sampling using the supplied random <code>generator</code>.`,name:"latents"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pil&quot;</code>) &#x2014;
The output format of the generate image. Choose between
<a href="https://pillow.readthedocs.io/en/stable/" rel="nofollow">PIL</a>: <code>PIL.Image.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <a href="/docs/diffusers/v0.18.0/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput">StableDiffusionPipelineOutput</a> instead of a
plain tuple.`,name:"return_dict"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.callback",description:`<strong>callback</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
A function that will be called every <code>callback_steps</code> steps during inference. The function will be
called with the following arguments: <code>callback(step: int, timestep: int, latents: torch.FloatTensor)</code>.`,name:"callback"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.callback_steps",description:`<strong>callback_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The frequency at which the <code>callback</code> function will be called. If not specified, the callback will be
called at every step.`,name:"callback_steps"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.sld_guidance_scale",description:`<strong>sld_guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 1000) &#x2014;
Safe latent guidance as defined in <a href="https://arxiv.org/abs/2211.05105" rel="nofollow">Safe Latent Diffusion</a>.
<code>sld_guidance_scale</code> is defined as sS of Eq. 6. If set to be less than 1, safety guidance will be
disabled.`,name:"sld_guidance_scale"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.sld_warmup_steps",description:`<strong>sld_warmup_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 10) &#x2014;
Number of warmup steps for safety guidance. SLD will only be applied for diffusion steps greater than
<code>sld_warmup_steps</code>. <code>sld_warmup_steps</code> is defined as <code>delta</code> of <a href="https://arxiv.org/abs/2211.05105" rel="nofollow">Safe Latent
Diffusion</a>.`,name:"sld_warmup_steps"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.sld_threshold",description:`<strong>sld_threshold</strong> (<code>float</code>, <em>optional</em>, defaults to 0.01) &#x2014;
Threshold that separates the hyperplane between appropriate and inappropriate images. <code>sld_threshold</code>
is defined as <code>lamda</code> of Eq. 5 in <a href="https://arxiv.org/abs/2211.05105" rel="nofollow">Safe Latent Diffusion</a>.`,name:"sld_threshold"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.sld_momentum_scale",description:`<strong>sld_momentum_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 0.3) &#x2014;
Scale of the SLD momentum to be added to the safety guidance at each diffusion step. If set to 0.0
momentum will be disabled. Momentum is already built up during warmup, i.e. for diffusion steps smaller
than <code>sld_warmup_steps</code>. <code>sld_momentum_scale</code> is defined as <code>sm</code> of Eq. 7 in <a href="https://arxiv.org/abs/2211.05105" rel="nofollow">Safe Latent
Diffusion</a>.`,name:"sld_momentum_scale"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.sld_mom_beta",description:`<strong>sld_mom_beta</strong> (<code>float</code>, <em>optional</em>, defaults to 0.4) &#x2014;
Defines how safety guidance momentum builds up. <code>sld_mom_beta</code> indicates how much of the previous
momentum will be kept. Momentum is already built up during warmup, i.e. for diffusion steps smaller
than <code>sld_warmup_steps</code>. <code>sld_mom_beta</code> is defined as <code>beta m</code> of Eq. 8 in <a href="https://arxiv.org/abs/2211.05105" rel="nofollow">Safe Latent
Diffusion</a>.`,name:"sld_mom_beta"}],source:"https://github.com/huggingface/diffusers/blob/v0.18.0/src/diffusers/pipelines/stable_diffusion_safe/pipeline_stable_diffusion_safe.py#L504",returnDescription:`
<p><a
  href="/docs/diffusers/v0.18.0/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> if <code>return_dict</code> is True, otherwise a <code>tuple. When returning a tuple, the first element is a list with the generated images, and the second element is a list of </code>bool<code>s denoting whether the corresponding generated image likely represents "not-safe-for-work" (nsfw) content, according to the </code>safety_checker\`.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/v0.18.0/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),$e=new Vt({props:{name:"enable_sequential_cpu_offload",anchor:"diffusers.StableDiffusionPipelineSafe.enable_sequential_cpu_offload",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.18.0/src/diffusers/pipelines/stable_diffusion_safe/pipeline_stable_diffusion_safe.py#L170"}}),{c(){k=i("meta"),Wt=d(),U=i("h1"),J=i("a"),et=i("span"),g(se.$$.fragment),Ua=d(),tt=i("span"),Ia=o("Safe Stable Diffusion"),Ot=d(),V=i("p"),Za=o("Safe Stable Diffusion was proposed in "),ne=i("a"),Ca=o("Safe Latent Diffusion: Mitigating Inappropriate Degeneration in Diffusion Models"),La=o(` and mitigates the well known issue that models like Stable Diffusion that are trained on unfiltered, web-crawled datasets tend to suffer from inappropriate degeneration. For instance Stable Diffusion may unexpectedly generate nudity, violence, images depicting self-harm, or otherwise offensive content.
Safe Stable Diffusion is an extension to the Stable Diffusion that drastically reduces content like this.`),jt=d(),Te=i("p"),Ga=o("The abstract of the paper is the following:"),Rt=d(),ke=i("p"),at=i("em"),Aa=o("Text-conditioned image generation models have recently achieved astonishing results in image quality and text alignment and are consequently employed in a fast-growing number of applications. Since they are highly data-driven, relying on billion-sized datasets randomly scraped from the internet, they also suffer, as we demonstrate, from degenerated and biased human behavior. In turn, they may even reinforce such biases. To help combat these undesired side effects, we present safe latent diffusion (SLD). Specifically, to measure the inappropriate degeneration due to unfiltered and imbalanced training sets, we establish a novel image generation test bed-inappropriate image prompts (I2P)-containing dedicated, real-world image-to-text prompts covering concepts such as nudity and violence. As our exhaustive empirical evaluation demonstrates, the introduced SLD removes and suppresses inappropriate image parts during the diffusion process, with no additional training required and no adverse effect on overall image quality or text alignment."),Ft=d(),oe=i("p"),it=i("em"),Na=o("Overview"),Ja=o(":"),qt=d(),W=i("table"),st=i("thead"),P=i("tr"),nt=i("th"),Va=o("Pipeline"),Wa=d(),ot=i("th"),Oa=o("Tasks"),ja=d(),Ue=i("th"),Ra=o("Colab"),Fa=d(),Ie=i("th"),qa=o("Demo"),Ba=d(),lt=i("tbody"),M=i("tr"),rt=i("td"),le=i("a"),za=o("pipeline_stable_diffusion_safe.py"),Ha=d(),ft=i("td"),dt=i("em"),Ya=o("Text-to-Image Generation"),Xa=d(),Ze=i("td"),re=i("a"),Ce=i("img"),Qa=d(),Le=i("td"),fe=i("a"),Ge=i("img"),Bt=d(),I=i("h2"),O=i("a"),ct=i("span"),g(de.$$.fragment),Ka=d(),pt=i("span"),ei=o("Tips"),zt=d(),Ae=i("ul"),ce=i("li"),ti=o("Safe Stable Diffusion may also be used with weights of "),Ne=i("a"),ai=o("Stable Diffusion"),ii=o("."),Ht=d(),Z=i("h3"),j=i("a"),ut=i("span"),g(pe.$$.fragment),si=d(),ht=i("span"),ni=o("Run Safe Stable Diffusion"),Yt=d(),D=i("p"),oi=o("Safe Stable Diffusion can be tested very easily with the "),Je=i("a"),li=o("StableDiffusionPipelineSafe"),ri=o(", and the "),mt=i("code"),fi=o('"AIML-TUDA/stable-diffusion-safe"'),di=o(" checkpoint exactly in the same way it is shown in the "),Ve=i("a"),ci=o("Conditional Image Generation Guide"),pi=o("."),Xt=d(),C=i("h3"),R=i("a"),gt=i("span"),g(ue.$$.fragment),ui=d(),_t=i("span"),hi=o("Interacting with the Safety Concept"),Qt=d(),x=i("p"),mi=o("To check and edit the currently used safety concept, use the "),bt=i("code"),gi=o("safety_concept"),_i=o(" property of "),We=i("a"),bi=o("StableDiffusionPipelineSafe"),vi=o(":"),Kt=d(),g(he.$$.fragment),ea=d(),F=i("p"),yi=o("For each image generation the active concept is also contained in "),vt=i("code"),Si=o("StableDiffusionSafePipelineOutput"),wi=o("."),ta=d(),L=i("h3"),q=i("a"),yt=i("span"),g(me.$$.fragment),Di=d(),St=i("span"),Ei=o("Using pre-defined safety configurations"),aa=d(),B=i("p"),Pi=o("You may use the 4 configurations defined in the "),ge=i("a"),Mi=o("Safe Latent Diffusion paper"),$i=o(" as follows:"),ia=d(),g(_e.$$.fragment),sa=d(),w=i("p"),xi=o("The following configurations are available: "),wt=i("code"),Ti=o("SafetyConfig.WEAK"),ki=o(", "),Dt=i("code"),Ui=o("SafetyConfig.MEDIUM"),Ii=o(", "),Et=i("code"),Zi=o("SafetyConfig.STRONG"),Ci=o(", and "),Pt=i("code"),Li=o("SafetyConfig.MAX"),Gi=o("."),na=d(),G=i("h3"),z=i("a"),Mt=i("span"),g(be.$$.fragment),Ai=d(),$t=i("span"),Ni=o("How to load and use different schedulers"),oa=d(),u=i("p"),Ji=o("The safe stable diffusion pipeline uses "),Oe=i("a"),Vi=o("PNDMScheduler"),Wi=o(" scheduler by default. But "),xt=i("code"),Oi=o("diffusers"),ji=o(" provides many other schedulers that can be used with the stable diffusion pipeline such as "),je=i("a"),Ri=o("DDIMScheduler"),Fi=o(", "),Re=i("a"),qi=o("LMSDiscreteScheduler"),Bi=o(", "),Fe=i("a"),zi=o("EulerDiscreteScheduler"),Hi=o(", "),qe=i("a"),Yi=o("EulerAncestralDiscreteScheduler"),Xi=o(` etc.
To use a different scheduler, you can either change it via the `),Be=i("a"),Qi=o("ConfigMixin.from_config()"),Ki=o(" method or pass the "),Tt=i("code"),es=o("scheduler"),ts=o(" argument to the "),kt=i("code"),as=o("from_pretrained"),is=o(" method of the pipeline. For example, to use the "),ze=i("a"),ss=o("EulerDiscreteScheduler"),ns=o(", you can do the following:"),la=d(),g(ve.$$.fragment),ra=d(),A=i("h2"),H=i("a"),Ut=i("span"),g(ye.$$.fragment),os=d(),It=i("span"),ls=o("StableDiffusionSafePipelineOutput"),fa=d(),$=i("div"),g(Se.$$.fragment),rs=d(),Zt=i("p"),fs=o("Output class for Safe Stable Diffusion pipelines."),ds=d(),Y=i("div"),g(we.$$.fragment),cs=d(),Ct=i("p"),ps=o("Call self as a function."),da=d(),N=i("h2"),X=i("a"),Lt=i("span"),g(De.$$.fragment),us=d(),Gt=i("span"),hs=o("StableDiffusionPipelineSafe"),ca=d(),m=i("div"),g(Ee.$$.fragment),ms=d(),At=i("p"),gs=o("Pipeline for text-to-image generation using Safe Latent Diffusion."),_s=d(),He=i("p"),bs=o("The implementation is based on the "),Ye=i("a"),vs=o("StableDiffusionPipeline"),ys=d(),Pe=i("p"),Ss=o("This model inherits from "),Xe=i("a"),ws=o("DiffusionPipeline"),Ds=o(`. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)`),Es=d(),Q=i("div"),g(Me.$$.fragment),Ps=d(),Nt=i("p"),Ms=o("Function invoked when calling the pipeline for generation."),$s=d(),K=i("div"),g($e.$$.fragment),xs=d(),xe=i("p"),Ts=o(`Offloads all models to CPU using accelerate, significantly reducing memory usage. When called, unet,
text_encoder, vae and safety checker have their state dicts saved to CPU and then are moved to a
`),Jt=i("code"),ks=o("torch.device('meta') and loaded to GPU only when their specific submodule has its "),Us=o("forward` method called."),this.h()},l(t){const f=ro('[data-svelte="svelte-1phssyn"]',document.head);k=s(f,"META",{name:!0,content:!0}),f.forEach(a),Wt=c(t),U=s(t,"H1",{class:!0});var ua=n(U);J=s(ua,"A",{id:!0,class:!0,href:!0});var Ns=n(J);et=s(Ns,"SPAN",{});var Js=n(et);_(se.$$.fragment,Js),Js.forEach(a),Ns.forEach(a),Ua=c(ua),tt=s(ua,"SPAN",{});var Vs=n(tt);Ia=l(Vs,"Safe Stable Diffusion"),Vs.forEach(a),ua.forEach(a),Ot=c(t),V=s(t,"P",{});var ha=n(V);Za=l(ha,"Safe Stable Diffusion was proposed in "),ne=s(ha,"A",{href:!0,rel:!0});var Ws=n(ne);Ca=l(Ws,"Safe Latent Diffusion: Mitigating Inappropriate Degeneration in Diffusion Models"),Ws.forEach(a),La=l(ha,` and mitigates the well known issue that models like Stable Diffusion that are trained on unfiltered, web-crawled datasets tend to suffer from inappropriate degeneration. For instance Stable Diffusion may unexpectedly generate nudity, violence, images depicting self-harm, or otherwise offensive content.
Safe Stable Diffusion is an extension to the Stable Diffusion that drastically reduces content like this.`),ha.forEach(a),jt=c(t),Te=s(t,"P",{});var Os=n(Te);Ga=l(Os,"The abstract of the paper is the following:"),Os.forEach(a),Rt=c(t),ke=s(t,"P",{});var js=n(ke);at=s(js,"EM",{});var Rs=n(at);Aa=l(Rs,"Text-conditioned image generation models have recently achieved astonishing results in image quality and text alignment and are consequently employed in a fast-growing number of applications. Since they are highly data-driven, relying on billion-sized datasets randomly scraped from the internet, they also suffer, as we demonstrate, from degenerated and biased human behavior. In turn, they may even reinforce such biases. To help combat these undesired side effects, we present safe latent diffusion (SLD). Specifically, to measure the inappropriate degeneration due to unfiltered and imbalanced training sets, we establish a novel image generation test bed-inappropriate image prompts (I2P)-containing dedicated, real-world image-to-text prompts covering concepts such as nudity and violence. As our exhaustive empirical evaluation demonstrates, the introduced SLD removes and suppresses inappropriate image parts during the diffusion process, with no additional training required and no adverse effect on overall image quality or text alignment."),Rs.forEach(a),js.forEach(a),Ft=c(t),oe=s(t,"P",{});var Is=n(oe);it=s(Is,"EM",{});var Fs=n(it);Na=l(Fs,"Overview"),Fs.forEach(a),Ja=l(Is,":"),Is.forEach(a),qt=c(t),W=s(t,"TABLE",{});var ma=n(W);st=s(ma,"THEAD",{});var qs=n(st);P=s(qs,"TR",{});var ee=n(P);nt=s(ee,"TH",{});var Bs=n(nt);Va=l(Bs,"Pipeline"),Bs.forEach(a),Wa=c(ee),ot=s(ee,"TH",{});var zs=n(ot);Oa=l(zs,"Tasks"),zs.forEach(a),ja=c(ee),Ue=s(ee,"TH",{align:!0});var Hs=n(Ue);Ra=l(Hs,"Colab"),Hs.forEach(a),Fa=c(ee),Ie=s(ee,"TH",{align:!0});var Ys=n(Ie);qa=l(Ys,"Demo"),Ys.forEach(a),ee.forEach(a),qs.forEach(a),Ba=c(ma),lt=s(ma,"TBODY",{});var Xs=n(lt);M=s(Xs,"TR",{});var te=n(M);rt=s(te,"TD",{});var Qs=n(rt);le=s(Qs,"A",{href:!0,rel:!0});var Ks=n(le);za=l(Ks,"pipeline_stable_diffusion_safe.py"),Ks.forEach(a),Qs.forEach(a),Ha=c(te),ft=s(te,"TD",{});var en=n(ft);dt=s(en,"EM",{});var tn=n(dt);Ya=l(tn,"Text-to-Image Generation"),tn.forEach(a),en.forEach(a),Xa=c(te),Ze=s(te,"TD",{align:!0});var an=n(Ze);re=s(an,"A",{href:!0,rel:!0});var sn=n(re);Ce=s(sn,"IMG",{src:!0,alt:!0}),sn.forEach(a),an.forEach(a),Qa=c(te),Le=s(te,"TD",{align:!0});var nn=n(Le);fe=s(nn,"A",{href:!0,rel:!0});var on=n(fe);Ge=s(on,"IMG",{src:!0,alt:!0}),on.forEach(a),nn.forEach(a),te.forEach(a),Xs.forEach(a),ma.forEach(a),Bt=c(t),I=s(t,"H2",{class:!0});var ga=n(I);O=s(ga,"A",{id:!0,class:!0,href:!0});var ln=n(O);ct=s(ln,"SPAN",{});var rn=n(ct);_(de.$$.fragment,rn),rn.forEach(a),ln.forEach(a),Ka=c(ga),pt=s(ga,"SPAN",{});var fn=n(pt);ei=l(fn,"Tips"),fn.forEach(a),ga.forEach(a),zt=c(t),Ae=s(t,"UL",{});var dn=n(Ae);ce=s(dn,"LI",{});var _a=n(ce);ti=l(_a,"Safe Stable Diffusion may also be used with weights of "),Ne=s(_a,"A",{href:!0});var cn=n(Ne);ai=l(cn,"Stable Diffusion"),cn.forEach(a),ii=l(_a,"."),_a.forEach(a),dn.forEach(a),Ht=c(t),Z=s(t,"H3",{class:!0});var ba=n(Z);j=s(ba,"A",{id:!0,class:!0,href:!0});var pn=n(j);ut=s(pn,"SPAN",{});var un=n(ut);_(pe.$$.fragment,un),un.forEach(a),pn.forEach(a),si=c(ba),ht=s(ba,"SPAN",{});var hn=n(ht);ni=l(hn,"Run Safe Stable Diffusion"),hn.forEach(a),ba.forEach(a),Yt=c(t),D=s(t,"P",{});var ae=n(D);oi=l(ae,"Safe Stable Diffusion can be tested very easily with the "),Je=s(ae,"A",{href:!0});var mn=n(Je);li=l(mn,"StableDiffusionPipelineSafe"),mn.forEach(a),ri=l(ae,", and the "),mt=s(ae,"CODE",{});var gn=n(mt);fi=l(gn,'"AIML-TUDA/stable-diffusion-safe"'),gn.forEach(a),di=l(ae," checkpoint exactly in the same way it is shown in the "),Ve=s(ae,"A",{href:!0});var _n=n(Ve);ci=l(_n,"Conditional Image Generation Guide"),_n.forEach(a),pi=l(ae,"."),ae.forEach(a),Xt=c(t),C=s(t,"H3",{class:!0});var va=n(C);R=s(va,"A",{id:!0,class:!0,href:!0});var bn=n(R);gt=s(bn,"SPAN",{});var vn=n(gt);_(ue.$$.fragment,vn),vn.forEach(a),bn.forEach(a),ui=c(va),_t=s(va,"SPAN",{});var yn=n(_t);hi=l(yn,"Interacting with the Safety Concept"),yn.forEach(a),va.forEach(a),Qt=c(t),x=s(t,"P",{});var Qe=n(x);mi=l(Qe,"To check and edit the currently used safety concept, use the "),bt=s(Qe,"CODE",{});var Sn=n(bt);gi=l(Sn,"safety_concept"),Sn.forEach(a),_i=l(Qe," property of "),We=s(Qe,"A",{href:!0});var wn=n(We);bi=l(wn,"StableDiffusionPipelineSafe"),wn.forEach(a),vi=l(Qe,":"),Qe.forEach(a),Kt=c(t),_(he.$$.fragment,t),ea=c(t),F=s(t,"P",{});var ya=n(F);yi=l(ya,"For each image generation the active concept is also contained in "),vt=s(ya,"CODE",{});var Dn=n(vt);Si=l(Dn,"StableDiffusionSafePipelineOutput"),Dn.forEach(a),wi=l(ya,"."),ya.forEach(a),ta=c(t),L=s(t,"H3",{class:!0});var Sa=n(L);q=s(Sa,"A",{id:!0,class:!0,href:!0});var En=n(q);yt=s(En,"SPAN",{});var Pn=n(yt);_(me.$$.fragment,Pn),Pn.forEach(a),En.forEach(a),Di=c(Sa),St=s(Sa,"SPAN",{});var Mn=n(St);Ei=l(Mn,"Using pre-defined safety configurations"),Mn.forEach(a),Sa.forEach(a),aa=c(t),B=s(t,"P",{});var wa=n(B);Pi=l(wa,"You may use the 4 configurations defined in the "),ge=s(wa,"A",{href:!0,rel:!0});var $n=n(ge);Mi=l($n,"Safe Latent Diffusion paper"),$n.forEach(a),$i=l(wa," as follows:"),wa.forEach(a),ia=c(t),_(_e.$$.fragment,t),sa=c(t),w=s(t,"P",{});var T=n(w);xi=l(T,"The following configurations are available: "),wt=s(T,"CODE",{});var xn=n(wt);Ti=l(xn,"SafetyConfig.WEAK"),xn.forEach(a),ki=l(T,", "),Dt=s(T,"CODE",{});var Tn=n(Dt);Ui=l(Tn,"SafetyConfig.MEDIUM"),Tn.forEach(a),Ii=l(T,", "),Et=s(T,"CODE",{});var kn=n(Et);Zi=l(kn,"SafetyConfig.STRONG"),kn.forEach(a),Ci=l(T,", and "),Pt=s(T,"CODE",{});var Un=n(Pt);Li=l(Un,"SafetyConfig.MAX"),Un.forEach(a),Gi=l(T,"."),T.forEach(a),na=c(t),G=s(t,"H3",{class:!0});var Da=n(G);z=s(Da,"A",{id:!0,class:!0,href:!0});var In=n(z);Mt=s(In,"SPAN",{});var Zn=n(Mt);_(be.$$.fragment,Zn),Zn.forEach(a),In.forEach(a),Ai=c(Da),$t=s(Da,"SPAN",{});var Cn=n($t);Ni=l(Cn,"How to load and use different schedulers"),Cn.forEach(a),Da.forEach(a),oa=c(t),u=s(t,"P",{});var h=n(u);Ji=l(h,"The safe stable diffusion pipeline uses "),Oe=s(h,"A",{href:!0});var Ln=n(Oe);Vi=l(Ln,"PNDMScheduler"),Ln.forEach(a),Wi=l(h," scheduler by default. But "),xt=s(h,"CODE",{});var Gn=n(xt);Oi=l(Gn,"diffusers"),Gn.forEach(a),ji=l(h," provides many other schedulers that can be used with the stable diffusion pipeline such as "),je=s(h,"A",{href:!0});var An=n(je);Ri=l(An,"DDIMScheduler"),An.forEach(a),Fi=l(h,", "),Re=s(h,"A",{href:!0});var Nn=n(Re);qi=l(Nn,"LMSDiscreteScheduler"),Nn.forEach(a),Bi=l(h,", "),Fe=s(h,"A",{href:!0});var Jn=n(Fe);zi=l(Jn,"EulerDiscreteScheduler"),Jn.forEach(a),Hi=l(h,", "),qe=s(h,"A",{href:!0});var Vn=n(qe);Yi=l(Vn,"EulerAncestralDiscreteScheduler"),Vn.forEach(a),Xi=l(h,` etc.
To use a different scheduler, you can either change it via the `),Be=s(h,"A",{href:!0});var Wn=n(Be);Qi=l(Wn,"ConfigMixin.from_config()"),Wn.forEach(a),Ki=l(h," method or pass the "),Tt=s(h,"CODE",{});var On=n(Tt);es=l(On,"scheduler"),On.forEach(a),ts=l(h," argument to the "),kt=s(h,"CODE",{});var jn=n(kt);as=l(jn,"from_pretrained"),jn.forEach(a),is=l(h," method of the pipeline. For example, to use the "),ze=s(h,"A",{href:!0});var Rn=n(ze);ss=l(Rn,"EulerDiscreteScheduler"),Rn.forEach(a),ns=l(h,", you can do the following:"),h.forEach(a),la=c(t),_(ve.$$.fragment,t),ra=c(t),A=s(t,"H2",{class:!0});var Ea=n(A);H=s(Ea,"A",{id:!0,class:!0,href:!0});var Fn=n(H);Ut=s(Fn,"SPAN",{});var qn=n(Ut);_(ye.$$.fragment,qn),qn.forEach(a),Fn.forEach(a),os=c(Ea),It=s(Ea,"SPAN",{});var Bn=n(It);ls=l(Bn,"StableDiffusionSafePipelineOutput"),Bn.forEach(a),Ea.forEach(a),fa=c(t),$=s(t,"DIV",{class:!0});var Ke=n($);_(Se.$$.fragment,Ke),rs=c(Ke),Zt=s(Ke,"P",{});var zn=n(Zt);fs=l(zn,"Output class for Safe Stable Diffusion pipelines."),zn.forEach(a),ds=c(Ke),Y=s(Ke,"DIV",{class:!0});var Pa=n(Y);_(we.$$.fragment,Pa),cs=c(Pa),Ct=s(Pa,"P",{});var Hn=n(Ct);ps=l(Hn,"Call self as a function."),Hn.forEach(a),Pa.forEach(a),Ke.forEach(a),da=c(t),N=s(t,"H2",{class:!0});var Ma=n(N);X=s(Ma,"A",{id:!0,class:!0,href:!0});var Yn=n(X);Lt=s(Yn,"SPAN",{});var Xn=n(Lt);_(De.$$.fragment,Xn),Xn.forEach(a),Yn.forEach(a),us=c(Ma),Gt=s(Ma,"SPAN",{});var Qn=n(Gt);hs=l(Qn,"StableDiffusionPipelineSafe"),Qn.forEach(a),Ma.forEach(a),ca=c(t),m=s(t,"DIV",{class:!0});var E=n(m);_(Ee.$$.fragment,E),ms=c(E),At=s(E,"P",{});var Kn=n(At);gs=l(Kn,"Pipeline for text-to-image generation using Safe Latent Diffusion."),Kn.forEach(a),_s=c(E),He=s(E,"P",{});var Zs=n(He);bs=l(Zs,"The implementation is based on the "),Ye=s(Zs,"A",{href:!0});var eo=n(Ye);vs=l(eo,"StableDiffusionPipeline"),eo.forEach(a),Zs.forEach(a),ys=c(E),Pe=s(E,"P",{});var $a=n(Pe);Ss=l($a,"This model inherits from "),Xe=s($a,"A",{href:!0});var to=n(Xe);ws=l(to,"DiffusionPipeline"),to.forEach(a),Ds=l($a,`. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)`),$a.forEach(a),Es=c(E),Q=s(E,"DIV",{class:!0});var xa=n(Q);_(Me.$$.fragment,xa),Ps=c(xa),Nt=s(xa,"P",{});var ao=n(Nt);Ms=l(ao,"Function invoked when calling the pipeline for generation."),ao.forEach(a),xa.forEach(a),$s=c(E),K=s(E,"DIV",{class:!0});var Ta=n(K);_($e.$$.fragment,Ta),xs=c(Ta),xe=s(Ta,"P",{});var ka=n(xe);Ts=l(ka,`Offloads all models to CPU using accelerate, significantly reducing memory usage. When called, unet,
text_encoder, vae and safety checker have their state dicts saved to CPU and then are moved to a
`),Jt=s(ka,"CODE",{});var io=n(Jt);ks=l(io,"torch.device('meta') and loaded to GPU only when their specific submodule has its "),io.forEach(a),Us=l(ka,"forward` method called."),ka.forEach(a),Ta.forEach(a),E.forEach(a),this.h()},h(){r(k,"name","hf:doc:metadata"),r(k,"content",JSON.stringify(uo)),r(J,"id","safe-stable-diffusion"),r(J,"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"),r(J,"href","#safe-stable-diffusion"),r(U,"class","relative group"),r(ne,"href","https://arxiv.org/abs/2211.05105"),r(ne,"rel","nofollow"),r(Ue,"align","center"),r(Ie,"align","center"),r(le,"href","https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion_safe/pipeline_stable_diffusion_safe.py"),r(le,"rel","nofollow"),so(Ce.src,Gs="https://colab.research.google.com/assets/colab-badge.svg")||r(Ce,"src",Gs),r(Ce,"alt","Open In Colab"),r(re,"href","https://colab.research.google.com/github/ml-research/safe-latent-diffusion/blob/main/examples/Safe%20Latent%20Diffusion.ipynb"),r(re,"rel","nofollow"),r(Ze,"align","center"),so(Ge.src,As="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue")||r(Ge,"src",As),r(Ge,"alt","Huggingface Spaces"),r(fe,"href","https://huggingface.co/spaces/AIML-TUDA/unsafe-vs-safe-stable-diffusion"),r(fe,"rel","nofollow"),r(Le,"align","center"),r(O,"id","tips"),r(O,"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"),r(O,"href","#tips"),r(I,"class","relative group"),r(Ne,"href","./stable_diffusion/text2img"),r(j,"id","run-safe-stable-diffusion"),r(j,"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"),r(j,"href","#run-safe-stable-diffusion"),r(Z,"class","relative group"),r(Je,"href","/docs/diffusers/v0.18.0/en/api/pipelines/stable_diffusion/stable_diffusion_safe#diffusers.StableDiffusionPipelineSafe"),r(Ve,"href","../../using-diffusers/conditional_image_generation"),r(R,"id","interacting-with-the-safety-concept"),r(R,"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"),r(R,"href","#interacting-with-the-safety-concept"),r(C,"class","relative group"),r(We,"href","/docs/diffusers/v0.18.0/en/api/pipelines/stable_diffusion/stable_diffusion_safe#diffusers.StableDiffusionPipelineSafe"),r(q,"id","using-predefined-safety-configurations"),r(q,"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"),r(q,"href","#using-predefined-safety-configurations"),r(L,"class","relative group"),r(ge,"href","https://arxiv.org/abs/2211.05105"),r(ge,"rel","nofollow"),r(z,"id","how-to-load-and-use-different-schedulers"),r(z,"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"),r(z,"href","#how-to-load-and-use-different-schedulers"),r(G,"class","relative group"),r(Oe,"href","/docs/diffusers/v0.18.0/en/api/schedulers/pndm#diffusers.PNDMScheduler"),r(je,"href","/docs/diffusers/v0.18.0/en/api/schedulers/ddim#diffusers.DDIMScheduler"),r(Re,"href","/docs/diffusers/v0.18.0/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler"),r(Fe,"href","/docs/diffusers/v0.18.0/en/api/schedulers/euler#diffusers.EulerDiscreteScheduler"),r(qe,"href","/docs/diffusers/v0.18.0/en/api/schedulers/euler_ancestral#diffusers.EulerAncestralDiscreteScheduler"),r(Be,"href","/docs/diffusers/v0.18.0/en/api/configuration#diffusers.ConfigMixin.from_config"),r(ze,"href","/docs/diffusers/v0.18.0/en/api/schedulers/euler#diffusers.EulerDiscreteScheduler"),r(H,"id","diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput"),r(H,"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"),r(H,"href","#diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput"),r(A,"class","relative group"),r(Y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),r($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),r(X,"id","diffusers.StableDiffusionPipelineSafe"),r(X,"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"),r(X,"href","#diffusers.StableDiffusionPipelineSafe"),r(N,"class","relative group"),r(Ye,"href","/docs/diffusers/v0.18.0/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),r(Xe,"href","/docs/diffusers/v0.18.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),r(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),r(K,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),r(m,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,f){e(document.head,k),p(t,Wt,f),p(t,U,f),e(U,J),e(J,et),b(se,et,null),e(U,Ua),e(U,tt),e(tt,Ia),p(t,Ot,f),p(t,V,f),e(V,Za),e(V,ne),e(ne,Ca),e(V,La),p(t,jt,f),p(t,Te,f),e(Te,Ga),p(t,Rt,f),p(t,ke,f),e(ke,at),e(at,Aa),p(t,Ft,f),p(t,oe,f),e(oe,it),e(it,Na),e(oe,Ja),p(t,qt,f),p(t,W,f),e(W,st),e(st,P),e(P,nt),e(nt,Va),e(P,Wa),e(P,ot),e(ot,Oa),e(P,ja),e(P,Ue),e(Ue,Ra),e(P,Fa),e(P,Ie),e(Ie,qa),e(W,Ba),e(W,lt),e(lt,M),e(M,rt),e(rt,le),e(le,za),e(M,Ha),e(M,ft),e(ft,dt),e(dt,Ya),e(M,Xa),e(M,Ze),e(Ze,re),e(re,Ce),e(M,Qa),e(M,Le),e(Le,fe),e(fe,Ge),p(t,Bt,f),p(t,I,f),e(I,O),e(O,ct),b(de,ct,null),e(I,Ka),e(I,pt),e(pt,ei),p(t,zt,f),p(t,Ae,f),e(Ae,ce),e(ce,ti),e(ce,Ne),e(Ne,ai),e(ce,ii),p(t,Ht,f),p(t,Z,f),e(Z,j),e(j,ut),b(pe,ut,null),e(Z,si),e(Z,ht),e(ht,ni),p(t,Yt,f),p(t,D,f),e(D,oi),e(D,Je),e(Je,li),e(D,ri),e(D,mt),e(mt,fi),e(D,di),e(D,Ve),e(Ve,ci),e(D,pi),p(t,Xt,f),p(t,C,f),e(C,R),e(R,gt),b(ue,gt,null),e(C,ui),e(C,_t),e(_t,hi),p(t,Qt,f),p(t,x,f),e(x,mi),e(x,bt),e(bt,gi),e(x,_i),e(x,We),e(We,bi),e(x,vi),p(t,Kt,f),b(he,t,f),p(t,ea,f),p(t,F,f),e(F,yi),e(F,vt),e(vt,Si),e(F,wi),p(t,ta,f),p(t,L,f),e(L,q),e(q,yt),b(me,yt,null),e(L,Di),e(L,St),e(St,Ei),p(t,aa,f),p(t,B,f),e(B,Pi),e(B,ge),e(ge,Mi),e(B,$i),p(t,ia,f),b(_e,t,f),p(t,sa,f),p(t,w,f),e(w,xi),e(w,wt),e(wt,Ti),e(w,ki),e(w,Dt),e(Dt,Ui),e(w,Ii),e(w,Et),e(Et,Zi),e(w,Ci),e(w,Pt),e(Pt,Li),e(w,Gi),p(t,na,f),p(t,G,f),e(G,z),e(z,Mt),b(be,Mt,null),e(G,Ai),e(G,$t),e($t,Ni),p(t,oa,f),p(t,u,f),e(u,Ji),e(u,Oe),e(Oe,Vi),e(u,Wi),e(u,xt),e(xt,Oi),e(u,ji),e(u,je),e(je,Ri),e(u,Fi),e(u,Re),e(Re,qi),e(u,Bi),e(u,Fe),e(Fe,zi),e(u,Hi),e(u,qe),e(qe,Yi),e(u,Xi),e(u,Be),e(Be,Qi),e(u,Ki),e(u,Tt),e(Tt,es),e(u,ts),e(u,kt),e(kt,as),e(u,is),e(u,ze),e(ze,ss),e(u,ns),p(t,la,f),b(ve,t,f),p(t,ra,f),p(t,A,f),e(A,H),e(H,Ut),b(ye,Ut,null),e(A,os),e(A,It),e(It,ls),p(t,fa,f),p(t,$,f),b(Se,$,null),e($,rs),e($,Zt),e(Zt,fs),e($,ds),e($,Y),b(we,Y,null),e(Y,cs),e(Y,Ct),e(Ct,ps),p(t,da,f),p(t,N,f),e(N,X),e(X,Lt),b(De,Lt,null),e(N,us),e(N,Gt),e(Gt,hs),p(t,ca,f),p(t,m,f),b(Ee,m,null),e(m,ms),e(m,At),e(At,gs),e(m,_s),e(m,He),e(He,bs),e(He,Ye),e(Ye,vs),e(m,ys),e(m,Pe),e(Pe,Ss),e(Pe,Xe),e(Xe,ws),e(Pe,Ds),e(m,Es),e(m,Q),b(Me,Q,null),e(Q,Ps),e(Q,Nt),e(Nt,Ms),e(m,$s),e(m,K),b($e,K,null),e(K,xs),e(K,xe),e(xe,Ts),e(xe,Jt),e(Jt,ks),e(xe,Us),pa=!0},p:fo,i(t){pa||(v(se.$$.fragment,t),v(de.$$.fragment,t),v(pe.$$.fragment,t),v(ue.$$.fragment,t),v(he.$$.fragment,t),v(me.$$.fragment,t),v(_e.$$.fragment,t),v(be.$$.fragment,t),v(ve.$$.fragment,t),v(ye.$$.fragment,t),v(Se.$$.fragment,t),v(we.$$.fragment,t),v(De.$$.fragment,t),v(Ee.$$.fragment,t),v(Me.$$.fragment,t),v($e.$$.fragment,t),pa=!0)},o(t){y(se.$$.fragment,t),y(de.$$.fragment,t),y(pe.$$.fragment,t),y(ue.$$.fragment,t),y(he.$$.fragment,t),y(me.$$.fragment,t),y(_e.$$.fragment,t),y(be.$$.fragment,t),y(ve.$$.fragment,t),y(ye.$$.fragment,t),y(Se.$$.fragment,t),y(we.$$.fragment,t),y(De.$$.fragment,t),y(Ee.$$.fragment,t),y(Me.$$.fragment,t),y($e.$$.fragment,t),pa=!1},d(t){a(k),t&&a(Wt),t&&a(U),S(se),t&&a(Ot),t&&a(V),t&&a(jt),t&&a(Te),t&&a(Rt),t&&a(ke),t&&a(Ft),t&&a(oe),t&&a(qt),t&&a(W),t&&a(Bt),t&&a(I),S(de),t&&a(zt),t&&a(Ae),t&&a(Ht),t&&a(Z),S(pe),t&&a(Yt),t&&a(D),t&&a(Xt),t&&a(C),S(ue),t&&a(Qt),t&&a(x),t&&a(Kt),S(he,t),t&&a(ea),t&&a(F),t&&a(ta),t&&a(L),S(me),t&&a(aa),t&&a(B),t&&a(ia),S(_e,t),t&&a(sa),t&&a(w),t&&a(na),t&&a(G),S(be),t&&a(oa),t&&a(u),t&&a(la),S(ve,t),t&&a(ra),t&&a(A),S(ye),t&&a(fa),t&&a($),S(Se),S(we),t&&a(da),t&&a(N),S(De),t&&a(ca),t&&a(m),S(Ee),S(Me),S($e)}}}const uo={local:"safe-stable-diffusion",sections:[{local:"tips",sections:[{local:"run-safe-stable-diffusion",title:"Run Safe Stable Diffusion"},{local:"interacting-with-the-safety-concept",title:"Interacting with the Safety Concept"},{local:"using-predefined-safety-configurations",title:"Using pre-defined safety configurations"},{local:"how-to-load-and-use-different-schedulers",title:"How to load and use different schedulers"}],title:"Tips"},{local:"diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput",title:"StableDiffusionSafePipelineOutput"},{local:"diffusers.StableDiffusionPipelineSafe",title:"StableDiffusionPipelineSafe"}],title:"Safe Stable Diffusion"};function ho(Ls){return co(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class vo extends no{constructor(k){super();oo(this,k,ho,po,lo,{})}}export{vo as default,uo as metadata};
