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

pipeline = StableDiffusionPipelineSafe.from_pretrained("AIML-TUDA/stable-diffusion-safe")
pipeline.safety_concept`,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 Ms({props:{code:`from diffusers import StableDiffusionPipelineSafe
from diffusers.pipelines.stable_diffusion_safe import SafetyConfig

pipeline = StableDiffusionPipelineSafe.from_pretrained("AIML-TUDA/stable-diffusion-safe")
prompt = "the four horsewomen of the apocalypse, painting by tom of finland, gaston bussiere, craig mullins, j. c. leyendecker"
out = pipeline(prompt=prompt, **SafetyConfig.MAX)`,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 Ms({props:{code:`from diffusers import StableDiffusionPipelineSafe, EulerDiscreteScheduler

pipeline = StableDiffusionPipelineSafe.from_pretrained("AIML-TUDA/stable-diffusion-safe")
pipeline.scheduler = EulerDiscreteScheduler.from_config(pipeline.scheduler.config)

# or
euler_scheduler = EulerDiscreteScheduler.from_pretrained("AIML-TUDA/stable-diffusion-safe", subfolder="scheduler")
pipeline = StableDiffusionPipelineSafe.from_pretrained(
    "AIML-TUDA/stable-diffusion-safe", scheduler=euler_scheduler
)`,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>)`}}),Se=new ie({}),ye=new Gt({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.16.0/src/diffusers/pipelines/stable_diffusion_safe/__init__.py#L45"}}),De=new Gt({props:{name:"__call__",anchor:"diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput.__call__",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}]}}),we=new ie({}),Pe=new Gt({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.16.0/en/api/models#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.16.0/en/api/models#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.16.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.16.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/v0.16.0/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/v0.16.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.16.0/src/diffusers/pipelines/stable_diffusion_safe/pipeline_stable_diffusion_safe.py#L22"}}),$e=new Gt({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.16.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.16.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.16.0/src/diffusers/pipelines/stable_diffusion_safe/pipeline_stable_diffusion_safe.py#L499",returnDescription:`
<p><a
  href="/docs/diffusers/v0.16.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.16.0/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),xe=new Gt({props:{name:"enable_sequential_cpu_offload",anchor:"diffusers.StableDiffusionPipelineSafe.enable_sequential_cpu_offload",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.16.0/src/diffusers/pipelines/stable_diffusion_safe/pipeline_stable_diffusion_safe.py#L170"}}),{c(){T=i("meta"),Ht=d(),I=i("h1"),j=i("a"),et=i("span"),g(se.$$.fragment),Ia=d(),tt=i("span"),La=o("Safe Stable Diffusion"),Ft=d(),G=i("p"),Ca=o("Safe Stable Diffusion was proposed in "),ne=i("a"),Ma=o("Safe Latent Diffusion: Mitigating Inappropriate Degeneration in Diffusion Models"),Oa=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.`),zt=d(),Ae=i("p"),Na=o("The abstract of the paper is the following:"),Rt=d(),Te=i("p"),at=i("em"),qa=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."),Bt=d(),oe=i("p"),it=i("em"),Ua=o("Overview"),ja=o(":"),Vt=d(),H=i("table"),st=i("thead"),E=i("tr"),nt=i("th"),Ga=o("Pipeline"),Ha=d(),ot=i("th"),Fa=o("Tasks"),za=d(),Ie=i("th"),Ra=o("Colab"),Ba=d(),Le=i("th"),Va=o("Demo"),Ka=d(),rt=i("tbody"),$=i("tr"),lt=i("td"),re=i("a"),Wa=o("pipeline_stable_diffusion_safe.py"),Xa=d(),ft=i("td"),dt=i("em"),Ya=o("Text-to-Image Generation"),Ja=d(),Ce=i("td"),le=i("a"),Me=i("img"),Qa=d(),Oe=i("td"),fe=i("a"),Ne=i("img"),Kt=d(),L=i("h2"),F=i("a"),ct=i("span"),g(de.$$.fragment),Za=d(),pt=i("span"),ei=o("Tips"),Wt=d(),qe=i("ul"),ce=i("li"),ti=o("Safe Stable Diffusion may also be used with weights of "),Ue=i("a"),ai=o("Stable Diffusion"),ii=o("."),Xt=d(),C=i("h3"),z=i("a"),ut=i("span"),g(pe.$$.fragment),si=d(),ht=i("span"),ni=o("Run Safe Stable Diffusion"),Yt=d(),w=i("p"),oi=o("Safe Stable Diffusion can be tested very easily with the "),je=i("a"),ri=o("StableDiffusionPipelineSafe"),li=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 "),Ge=i("a"),ci=o("Conditional Image Generation Guide"),pi=o("."),Jt=d(),M=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(),k=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 "),He=i("a"),bi=o("StableDiffusionPipelineSafe"),vi=o(":"),Zt=d(),g(he.$$.fragment),ea=d(),B=i("p"),Si=o("For each image generation the active concept is also contained in "),vt=i("code"),yi=o("StableDiffusionSafePipelineOutput"),Di=o("."),ta=d(),O=i("h3"),V=i("a"),St=i("span"),g(me.$$.fragment),wi=d(),yt=i("span"),Pi=o("Using pre-defined safety configurations"),aa=d(),K=i("p"),Ei=o("You may use the 4 configurations defined in the "),ge=i("a"),$i=o("Safe Latent Diffusion paper"),xi=o(" as follows:"),ia=d(),g(_e.$$.fragment),sa=d(),D=i("p"),ki=o("The following configurations are available: "),Dt=i("code"),Ai=o("SafetyConfig.WEAK"),Ti=o(", "),wt=i("code"),Ii=o("SafetyConfig.MEDIUM"),Li=o(", "),Pt=i("code"),Ci=o("SafetyConfig.STRONG"),Mi=o(", and "),Et=i("code"),Oi=o("SafetyConfig.MAX"),Ni=o("."),na=d(),N=i("h3"),W=i("a"),$t=i("span"),g(be.$$.fragment),qi=d(),xt=i("span"),Ui=o("How to load and use different schedulers"),oa=d(),u=i("p"),ji=o("The safe stable diffusion pipeline uses "),Fe=i("a"),Gi=o("PNDMScheduler"),Hi=o(" scheduler by default. But "),kt=i("code"),Fi=o("diffusers"),zi=o(" provides many other schedulers that can be used with the stable diffusion pipeline such as "),ze=i("a"),Ri=o("DDIMScheduler"),Bi=o(", "),Re=i("a"),Vi=o("LMSDiscreteScheduler"),Ki=o(", "),Be=i("a"),Wi=o("EulerDiscreteScheduler"),Xi=o(", "),Ve=i("a"),Yi=o("EulerAncestralDiscreteScheduler"),Ji=o(` etc.
To use a different scheduler, you can either change it via the `),Ke=i("a"),Qi=o("ConfigMixin.from_config()"),Zi=o(" method or pass the "),At=i("code"),es=o("scheduler"),ts=o(" argument to the "),Tt=i("code"),as=o("from_pretrained"),is=o(" method of the pipeline. For example, to use the "),We=i("a"),ss=o("EulerDiscreteScheduler"),ns=o(", you can do the following:"),ra=d(),g(ve.$$.fragment),la=d(),q=i("h2"),X=i("a"),It=i("span"),g(Se.$$.fragment),os=d(),Lt=i("span"),rs=o("StableDiffusionSafePipelineOutput"),fa=d(),x=i("div"),g(ye.$$.fragment),ls=d(),Ct=i("p"),fs=o("Output class for Safe Stable Diffusion pipelines."),ds=d(),Y=i("div"),g(De.$$.fragment),cs=d(),Mt=i("p"),ps=o("Call self as a function."),da=d(),U=i("h2"),J=i("a"),Ot=i("span"),g(we.$$.fragment),us=d(),Nt=i("span"),hs=o("StableDiffusionPipelineSafe"),ca=d(),m=i("div"),g(Pe.$$.fragment),ms=d(),qt=i("p"),gs=o("Pipeline for text-to-image generation using Safe Latent Diffusion."),_s=d(),Xe=i("p"),bs=o("The implementation is based on the "),Ye=i("a"),vs=o("StableDiffusionPipeline"),Ss=d(),Ee=i("p"),ys=o("This model inherits from "),Je=i("a"),Ds=o("DiffusionPipeline"),ws=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.)`),Ps=d(),Q=i("div"),g($e.$$.fragment),Es=d(),Ut=i("p"),$s=o("Function invoked when calling the pipeline for generation."),xs=d(),Z=i("div"),g(xe.$$.fragment),ks=d(),ke=i("p"),As=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"),Ts=o("torch.device('meta') and loaded to GPU only when their specific submodule has its "),Is=o("forward` method called."),this.h()},l(t){const f=lo('[data-svelte="svelte-1phssyn"]',document.head);T=s(f,"META",{name:!0,content:!0}),f.forEach(a),Ht=c(t),I=s(t,"H1",{class:!0});var ua=n(I);j=s(ua,"A",{id:!0,class:!0,href:!0});var Us=n(j);et=s(Us,"SPAN",{});var js=n(et);_(se.$$.fragment,js),js.forEach(a),Us.forEach(a),Ia=c(ua),tt=s(ua,"SPAN",{});var Gs=n(tt);La=r(Gs,"Safe Stable Diffusion"),Gs.forEach(a),ua.forEach(a),Ft=c(t),G=s(t,"P",{});var ha=n(G);Ca=r(ha,"Safe Stable Diffusion was proposed in "),ne=s(ha,"A",{href:!0,rel:!0});var Hs=n(ne);Ma=r(Hs,"Safe Latent Diffusion: Mitigating Inappropriate Degeneration in Diffusion Models"),Hs.forEach(a),Oa=r(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),zt=c(t),Ae=s(t,"P",{});var Fs=n(Ae);Na=r(Fs,"The abstract of the paper is the following:"),Fs.forEach(a),Rt=c(t),Te=s(t,"P",{});var zs=n(Te);at=s(zs,"EM",{});var Rs=n(at);qa=r(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),zs.forEach(a),Bt=c(t),oe=s(t,"P",{});var Ls=n(oe);it=s(Ls,"EM",{});var Bs=n(it);Ua=r(Bs,"Overview"),Bs.forEach(a),ja=r(Ls,":"),Ls.forEach(a),Vt=c(t),H=s(t,"TABLE",{});var ma=n(H);st=s(ma,"THEAD",{});var Vs=n(st);E=s(Vs,"TR",{});var ee=n(E);nt=s(ee,"TH",{});var Ks=n(nt);Ga=r(Ks,"Pipeline"),Ks.forEach(a),Ha=c(ee),ot=s(ee,"TH",{});var Ws=n(ot);Fa=r(Ws,"Tasks"),Ws.forEach(a),za=c(ee),Ie=s(ee,"TH",{align:!0});var Xs=n(Ie);Ra=r(Xs,"Colab"),Xs.forEach(a),Ba=c(ee),Le=s(ee,"TH",{align:!0});var Ys=n(Le);Va=r(Ys,"Demo"),Ys.forEach(a),ee.forEach(a),Vs.forEach(a),Ka=c(ma),rt=s(ma,"TBODY",{});var Js=n(rt);$=s(Js,"TR",{});var te=n($);lt=s(te,"TD",{});var Qs=n(lt);re=s(Qs,"A",{href:!0,rel:!0});var Zs=n(re);Wa=r(Zs,"pipeline_stable_diffusion_safe.py"),Zs.forEach(a),Qs.forEach(a),Xa=c(te),ft=s(te,"TD",{});var en=n(ft);dt=s(en,"EM",{});var tn=n(dt);Ya=r(tn,"Text-to-Image Generation"),tn.forEach(a),en.forEach(a),Ja=c(te),Ce=s(te,"TD",{align:!0});var an=n(Ce);le=s(an,"A",{href:!0,rel:!0});var sn=n(le);Me=s(sn,"IMG",{src:!0,alt:!0}),sn.forEach(a),an.forEach(a),Qa=c(te),Oe=s(te,"TD",{align:!0});var nn=n(Oe);fe=s(nn,"A",{href:!0,rel:!0});var on=n(fe);Ne=s(on,"IMG",{src:!0,alt:!0}),on.forEach(a),nn.forEach(a),te.forEach(a),Js.forEach(a),ma.forEach(a),Kt=c(t),L=s(t,"H2",{class:!0});var ga=n(L);F=s(ga,"A",{id:!0,class:!0,href:!0});var rn=n(F);ct=s(rn,"SPAN",{});var ln=n(ct);_(de.$$.fragment,ln),ln.forEach(a),rn.forEach(a),Za=c(ga),pt=s(ga,"SPAN",{});var fn=n(pt);ei=r(fn,"Tips"),fn.forEach(a),ga.forEach(a),Wt=c(t),qe=s(t,"UL",{});var dn=n(qe);ce=s(dn,"LI",{});var _a=n(ce);ti=r(_a,"Safe Stable Diffusion may also be used with weights of "),Ue=s(_a,"A",{href:!0});var cn=n(Ue);ai=r(cn,"Stable Diffusion"),cn.forEach(a),ii=r(_a,"."),_a.forEach(a),dn.forEach(a),Xt=c(t),C=s(t,"H3",{class:!0});var ba=n(C);z=s(ba,"A",{id:!0,class:!0,href:!0});var pn=n(z);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=r(hn,"Run Safe Stable Diffusion"),hn.forEach(a),ba.forEach(a),Yt=c(t),w=s(t,"P",{});var ae=n(w);oi=r(ae,"Safe Stable Diffusion can be tested very easily with the "),je=s(ae,"A",{href:!0});var mn=n(je);ri=r(mn,"StableDiffusionPipelineSafe"),mn.forEach(a),li=r(ae,", and the "),mt=s(ae,"CODE",{});var gn=n(mt);fi=r(gn,'"AIML-TUDA/stable-diffusion-safe"'),gn.forEach(a),di=r(ae," checkpoint exactly in the same way it is shown in the "),Ge=s(ae,"A",{href:!0});var _n=n(Ge);ci=r(_n,"Conditional Image Generation Guide"),_n.forEach(a),pi=r(ae,"."),ae.forEach(a),Jt=c(t),M=s(t,"H3",{class:!0});var va=n(M);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 Sn=n(_t);hi=r(Sn,"Interacting with the Safety Concept"),Sn.forEach(a),va.forEach(a),Qt=c(t),k=s(t,"P",{});var Qe=n(k);mi=r(Qe,"To check and edit the currently used safety concept, use the "),bt=s(Qe,"CODE",{});var yn=n(bt);gi=r(yn,"safety_concept"),yn.forEach(a),_i=r(Qe," property of "),He=s(Qe,"A",{href:!0});var Dn=n(He);bi=r(Dn,"StableDiffusionPipelineSafe"),Dn.forEach(a),vi=r(Qe,":"),Qe.forEach(a),Zt=c(t),_(he.$$.fragment,t),ea=c(t),B=s(t,"P",{});var Sa=n(B);Si=r(Sa,"For each image generation the active concept is also contained in "),vt=s(Sa,"CODE",{});var wn=n(vt);yi=r(wn,"StableDiffusionSafePipelineOutput"),wn.forEach(a),Di=r(Sa,"."),Sa.forEach(a),ta=c(t),O=s(t,"H3",{class:!0});var ya=n(O);V=s(ya,"A",{id:!0,class:!0,href:!0});var Pn=n(V);St=s(Pn,"SPAN",{});var En=n(St);_(me.$$.fragment,En),En.forEach(a),Pn.forEach(a),wi=c(ya),yt=s(ya,"SPAN",{});var $n=n(yt);Pi=r($n,"Using pre-defined safety configurations"),$n.forEach(a),ya.forEach(a),aa=c(t),K=s(t,"P",{});var Da=n(K);Ei=r(Da,"You may use the 4 configurations defined in the "),ge=s(Da,"A",{href:!0,rel:!0});var xn=n(ge);$i=r(xn,"Safe Latent Diffusion paper"),xn.forEach(a),xi=r(Da," as follows:"),Da.forEach(a),ia=c(t),_(_e.$$.fragment,t),sa=c(t),D=s(t,"P",{});var A=n(D);ki=r(A,"The following configurations are available: "),Dt=s(A,"CODE",{});var kn=n(Dt);Ai=r(kn,"SafetyConfig.WEAK"),kn.forEach(a),Ti=r(A,", "),wt=s(A,"CODE",{});var An=n(wt);Ii=r(An,"SafetyConfig.MEDIUM"),An.forEach(a),Li=r(A,", "),Pt=s(A,"CODE",{});var Tn=n(Pt);Ci=r(Tn,"SafetyConfig.STRONG"),Tn.forEach(a),Mi=r(A,", and "),Et=s(A,"CODE",{});var In=n(Et);Oi=r(In,"SafetyConfig.MAX"),In.forEach(a),Ni=r(A,"."),A.forEach(a),na=c(t),N=s(t,"H3",{class:!0});var wa=n(N);W=s(wa,"A",{id:!0,class:!0,href:!0});var Ln=n(W);$t=s(Ln,"SPAN",{});var Cn=n($t);_(be.$$.fragment,Cn),Cn.forEach(a),Ln.forEach(a),qi=c(wa),xt=s(wa,"SPAN",{});var Mn=n(xt);Ui=r(Mn,"How to load and use different schedulers"),Mn.forEach(a),wa.forEach(a),oa=c(t),u=s(t,"P",{});var h=n(u);ji=r(h,"The safe stable diffusion pipeline uses "),Fe=s(h,"A",{href:!0});var On=n(Fe);Gi=r(On,"PNDMScheduler"),On.forEach(a),Hi=r(h," scheduler by default. But "),kt=s(h,"CODE",{});var Nn=n(kt);Fi=r(Nn,"diffusers"),Nn.forEach(a),zi=r(h," provides many other schedulers that can be used with the stable diffusion pipeline such as "),ze=s(h,"A",{href:!0});var qn=n(ze);Ri=r(qn,"DDIMScheduler"),qn.forEach(a),Bi=r(h,", "),Re=s(h,"A",{href:!0});var Un=n(Re);Vi=r(Un,"LMSDiscreteScheduler"),Un.forEach(a),Ki=r(h,", "),Be=s(h,"A",{href:!0});var jn=n(Be);Wi=r(jn,"EulerDiscreteScheduler"),jn.forEach(a),Xi=r(h,", "),Ve=s(h,"A",{href:!0});var Gn=n(Ve);Yi=r(Gn,"EulerAncestralDiscreteScheduler"),Gn.forEach(a),Ji=r(h,` etc.
To use a different scheduler, you can either change it via the `),Ke=s(h,"A",{href:!0});var Hn=n(Ke);Qi=r(Hn,"ConfigMixin.from_config()"),Hn.forEach(a),Zi=r(h," method or pass the "),At=s(h,"CODE",{});var Fn=n(At);es=r(Fn,"scheduler"),Fn.forEach(a),ts=r(h," argument to the "),Tt=s(h,"CODE",{});var zn=n(Tt);as=r(zn,"from_pretrained"),zn.forEach(a),is=r(h," method of the pipeline. For example, to use the "),We=s(h,"A",{href:!0});var Rn=n(We);ss=r(Rn,"EulerDiscreteScheduler"),Rn.forEach(a),ns=r(h,", you can do the following:"),h.forEach(a),ra=c(t),_(ve.$$.fragment,t),la=c(t),q=s(t,"H2",{class:!0});var Pa=n(q);X=s(Pa,"A",{id:!0,class:!0,href:!0});var Bn=n(X);It=s(Bn,"SPAN",{});var Vn=n(It);_(Se.$$.fragment,Vn),Vn.forEach(a),Bn.forEach(a),os=c(Pa),Lt=s(Pa,"SPAN",{});var Kn=n(Lt);rs=r(Kn,"StableDiffusionSafePipelineOutput"),Kn.forEach(a),Pa.forEach(a),fa=c(t),x=s(t,"DIV",{class:!0});var Ze=n(x);_(ye.$$.fragment,Ze),ls=c(Ze),Ct=s(Ze,"P",{});var Wn=n(Ct);fs=r(Wn,"Output class for Safe Stable Diffusion pipelines."),Wn.forEach(a),ds=c(Ze),Y=s(Ze,"DIV",{class:!0});var Ea=n(Y);_(De.$$.fragment,Ea),cs=c(Ea),Mt=s(Ea,"P",{});var Xn=n(Mt);ps=r(Xn,"Call self as a function."),Xn.forEach(a),Ea.forEach(a),Ze.forEach(a),da=c(t),U=s(t,"H2",{class:!0});var $a=n(U);J=s($a,"A",{id:!0,class:!0,href:!0});var Yn=n(J);Ot=s(Yn,"SPAN",{});var Jn=n(Ot);_(we.$$.fragment,Jn),Jn.forEach(a),Yn.forEach(a),us=c($a),Nt=s($a,"SPAN",{});var Qn=n(Nt);hs=r(Qn,"StableDiffusionPipelineSafe"),Qn.forEach(a),$a.forEach(a),ca=c(t),m=s(t,"DIV",{class:!0});var P=n(m);_(Pe.$$.fragment,P),ms=c(P),qt=s(P,"P",{});var Zn=n(qt);gs=r(Zn,"Pipeline for text-to-image generation using Safe Latent Diffusion."),Zn.forEach(a),_s=c(P),Xe=s(P,"P",{});var Cs=n(Xe);bs=r(Cs,"The implementation is based on the "),Ye=s(Cs,"A",{href:!0});var eo=n(Ye);vs=r(eo,"StableDiffusionPipeline"),eo.forEach(a),Cs.forEach(a),Ss=c(P),Ee=s(P,"P",{});var xa=n(Ee);ys=r(xa,"This model inherits from "),Je=s(xa,"A",{href:!0});var to=n(Je);Ds=r(to,"DiffusionPipeline"),to.forEach(a),ws=r(xa,`. 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.)`),xa.forEach(a),Ps=c(P),Q=s(P,"DIV",{class:!0});var ka=n(Q);_($e.$$.fragment,ka),Es=c(ka),Ut=s(ka,"P",{});var ao=n(Ut);$s=r(ao,"Function invoked when calling the pipeline for generation."),ao.forEach(a),ka.forEach(a),xs=c(P),Z=s(P,"DIV",{class:!0});var Aa=n(Z);_(xe.$$.fragment,Aa),ks=c(Aa),ke=s(Aa,"P",{});var Ta=n(ke);As=r(Ta,`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(Ta,"CODE",{});var io=n(jt);Ts=r(io,"torch.device('meta') and loaded to GPU only when their specific submodule has its "),io.forEach(a),Is=r(Ta,"forward` method called."),Ta.forEach(a),Aa.forEach(a),P.forEach(a),this.h()},h(){l(T,"name","hf:doc:metadata"),l(T,"content",JSON.stringify(uo)),l(j,"id","safe-stable-diffusion"),l(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"),l(j,"href","#safe-stable-diffusion"),l(I,"class","relative group"),l(ne,"href","https://arxiv.org/abs/2211.05105"),l(ne,"rel","nofollow"),l(Ie,"align","center"),l(Le,"align","center"),l(re,"href","https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion_safe/pipeline_stable_diffusion_safe.py"),l(re,"rel","nofollow"),so(Me.src,Ns="https://colab.research.google.com/assets/colab-badge.svg")||l(Me,"src",Ns),l(Me,"alt","Open In Colab"),l(le,"href","https://colab.research.google.com/github/ml-research/safe-latent-diffusion/blob/main/examples/Safe%20Latent%20Diffusion.ipynb"),l(le,"rel","nofollow"),l(Ce,"align","center"),so(Ne.src,qs="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue")||l(Ne,"src",qs),l(Ne,"alt","Huggingface Spaces"),l(fe,"href","https://huggingface.co/spaces/AIML-TUDA/unsafe-vs-safe-stable-diffusion"),l(fe,"rel","nofollow"),l(Oe,"align","center"),l(F,"id","tips"),l(F,"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"),l(F,"href","#tips"),l(L,"class","relative group"),l(Ue,"href","./stable_diffusion/text2img"),l(z,"id","run-safe-stable-diffusion"),l(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"),l(z,"href","#run-safe-stable-diffusion"),l(C,"class","relative group"),l(je,"href","/docs/diffusers/v0.16.0/en/api/pipelines/stable_diffusion_safe#diffusers.StableDiffusionPipelineSafe"),l(Ge,"href","../../using-diffusers/conditional_image_generation"),l(R,"id","interacting-with-the-safety-concept"),l(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"),l(R,"href","#interacting-with-the-safety-concept"),l(M,"class","relative group"),l(He,"href","/docs/diffusers/v0.16.0/en/api/pipelines/stable_diffusion_safe#diffusers.StableDiffusionPipelineSafe"),l(V,"id","using-predefined-safety-configurations"),l(V,"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"),l(V,"href","#using-predefined-safety-configurations"),l(O,"class","relative group"),l(ge,"href","https://arxiv.org/abs/2211.05105"),l(ge,"rel","nofollow"),l(W,"id","how-to-load-and-use-different-schedulers"),l(W,"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"),l(W,"href","#how-to-load-and-use-different-schedulers"),l(N,"class","relative group"),l(Fe,"href","/docs/diffusers/v0.16.0/en/api/schedulers/pndm#diffusers.PNDMScheduler"),l(ze,"href","/docs/diffusers/v0.16.0/en/api/schedulers/ddim#diffusers.DDIMScheduler"),l(Re,"href","/docs/diffusers/v0.16.0/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler"),l(Be,"href","/docs/diffusers/v0.16.0/en/api/schedulers/euler#diffusers.EulerDiscreteScheduler"),l(Ve,"href","/docs/diffusers/v0.16.0/en/api/schedulers/euler_ancestral#diffusers.EulerAncestralDiscreteScheduler"),l(Ke,"href","/docs/diffusers/v0.16.0/en/api/configuration#diffusers.ConfigMixin.from_config"),l(We,"href","/docs/diffusers/v0.16.0/en/api/schedulers/euler#diffusers.EulerDiscreteScheduler"),l(X,"id","diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput"),l(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"),l(X,"href","#diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput"),l(q,"class","relative group"),l(Y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(J,"id","diffusers.StableDiffusionPipelineSafe"),l(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"),l(J,"href","#diffusers.StableDiffusionPipelineSafe"),l(U,"class","relative group"),l(Ye,"href","/docs/diffusers/v0.16.0/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),l(Je,"href","/docs/diffusers/v0.16.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),l(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(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,T),p(t,Ht,f),p(t,I,f),e(I,j),e(j,et),b(se,et,null),e(I,Ia),e(I,tt),e(tt,La),p(t,Ft,f),p(t,G,f),e(G,Ca),e(G,ne),e(ne,Ma),e(G,Oa),p(t,zt,f),p(t,Ae,f),e(Ae,Na),p(t,Rt,f),p(t,Te,f),e(Te,at),e(at,qa),p(t,Bt,f),p(t,oe,f),e(oe,it),e(it,Ua),e(oe,ja),p(t,Vt,f),p(t,H,f),e(H,st),e(st,E),e(E,nt),e(nt,Ga),e(E,Ha),e(E,ot),e(ot,Fa),e(E,za),e(E,Ie),e(Ie,Ra),e(E,Ba),e(E,Le),e(Le,Va),e(H,Ka),e(H,rt),e(rt,$),e($,lt),e(lt,re),e(re,Wa),e($,Xa),e($,ft),e(ft,dt),e(dt,Ya),e($,Ja),e($,Ce),e(Ce,le),e(le,Me),e($,Qa),e($,Oe),e(Oe,fe),e(fe,Ne),p(t,Kt,f),p(t,L,f),e(L,F),e(F,ct),b(de,ct,null),e(L,Za),e(L,pt),e(pt,ei),p(t,Wt,f),p(t,qe,f),e(qe,ce),e(ce,ti),e(ce,Ue),e(Ue,ai),e(ce,ii),p(t,Xt,f),p(t,C,f),e(C,z),e(z,ut),b(pe,ut,null),e(C,si),e(C,ht),e(ht,ni),p(t,Yt,f),p(t,w,f),e(w,oi),e(w,je),e(je,ri),e(w,li),e(w,mt),e(mt,fi),e(w,di),e(w,Ge),e(Ge,ci),e(w,pi),p(t,Jt,f),p(t,M,f),e(M,R),e(R,gt),b(ue,gt,null),e(M,ui),e(M,_t),e(_t,hi),p(t,Qt,f),p(t,k,f),e(k,mi),e(k,bt),e(bt,gi),e(k,_i),e(k,He),e(He,bi),e(k,vi),p(t,Zt,f),b(he,t,f),p(t,ea,f),p(t,B,f),e(B,Si),e(B,vt),e(vt,yi),e(B,Di),p(t,ta,f),p(t,O,f),e(O,V),e(V,St),b(me,St,null),e(O,wi),e(O,yt),e(yt,Pi),p(t,aa,f),p(t,K,f),e(K,Ei),e(K,ge),e(ge,$i),e(K,xi),p(t,ia,f),b(_e,t,f),p(t,sa,f),p(t,D,f),e(D,ki),e(D,Dt),e(Dt,Ai),e(D,Ti),e(D,wt),e(wt,Ii),e(D,Li),e(D,Pt),e(Pt,Ci),e(D,Mi),e(D,Et),e(Et,Oi),e(D,Ni),p(t,na,f),p(t,N,f),e(N,W),e(W,$t),b(be,$t,null),e(N,qi),e(N,xt),e(xt,Ui),p(t,oa,f),p(t,u,f),e(u,ji),e(u,Fe),e(Fe,Gi),e(u,Hi),e(u,kt),e(kt,Fi),e(u,zi),e(u,ze),e(ze,Ri),e(u,Bi),e(u,Re),e(Re,Vi),e(u,Ki),e(u,Be),e(Be,Wi),e(u,Xi),e(u,Ve),e(Ve,Yi),e(u,Ji),e(u,Ke),e(Ke,Qi),e(u,Zi),e(u,At),e(At,es),e(u,ts),e(u,Tt),e(Tt,as),e(u,is),e(u,We),e(We,ss),e(u,ns),p(t,ra,f),b(ve,t,f),p(t,la,f),p(t,q,f),e(q,X),e(X,It),b(Se,It,null),e(q,os),e(q,Lt),e(Lt,rs),p(t,fa,f),p(t,x,f),b(ye,x,null),e(x,ls),e(x,Ct),e(Ct,fs),e(x,ds),e(x,Y),b(De,Y,null),e(Y,cs),e(Y,Mt),e(Mt,ps),p(t,da,f),p(t,U,f),e(U,J),e(J,Ot),b(we,Ot,null),e(U,us),e(U,Nt),e(Nt,hs),p(t,ca,f),p(t,m,f),b(Pe,m,null),e(m,ms),e(m,qt),e(qt,gs),e(m,_s),e(m,Xe),e(Xe,bs),e(Xe,Ye),e(Ye,vs),e(m,Ss),e(m,Ee),e(Ee,ys),e(Ee,Je),e(Je,Ds),e(Ee,ws),e(m,Ps),e(m,Q),b($e,Q,null),e(Q,Es),e(Q,Ut),e(Ut,$s),e(m,xs),e(m,Z),b(xe,Z,null),e(Z,ks),e(Z,ke),e(ke,As),e(ke,jt),e(jt,Ts),e(ke,Is),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(Se.$$.fragment,t),v(ye.$$.fragment,t),v(De.$$.fragment,t),v(we.$$.fragment,t),v(Pe.$$.fragment,t),v($e.$$.fragment,t),v(xe.$$.fragment,t),pa=!0)},o(t){S(se.$$.fragment,t),S(de.$$.fragment,t),S(pe.$$.fragment,t),S(ue.$$.fragment,t),S(he.$$.fragment,t),S(me.$$.fragment,t),S(_e.$$.fragment,t),S(be.$$.fragment,t),S(ve.$$.fragment,t),S(Se.$$.fragment,t),S(ye.$$.fragment,t),S(De.$$.fragment,t),S(we.$$.fragment,t),S(Pe.$$.fragment,t),S($e.$$.fragment,t),S(xe.$$.fragment,t),pa=!1},d(t){a(T),t&&a(Ht),t&&a(I),y(se),t&&a(Ft),t&&a(G),t&&a(zt),t&&a(Ae),t&&a(Rt),t&&a(Te),t&&a(Bt),t&&a(oe),t&&a(Vt),t&&a(H),t&&a(Kt),t&&a(L),y(de),t&&a(Wt),t&&a(qe),t&&a(Xt),t&&a(C),y(pe),t&&a(Yt),t&&a(w),t&&a(Jt),t&&a(M),y(ue),t&&a(Qt),t&&a(k),t&&a(Zt),y(he,t),t&&a(ea),t&&a(B),t&&a(ta),t&&a(O),y(me),t&&a(aa),t&&a(K),t&&a(ia),y(_e,t),t&&a(sa),t&&a(D),t&&a(na),t&&a(N),y(be),t&&a(oa),t&&a(u),t&&a(ra),y(ve,t),t&&a(la),t&&a(q),y(Se),t&&a(fa),t&&a(x),y(ye),y(De),t&&a(da),t&&a(U),y(we),t&&a(ca),t&&a(m),y(Pe),y($e),y(xe)}}}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(Os){return co(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class vo extends no{constructor(T){super();oo(this,T,ho,po,ro,{})}}export{vo as default,uo as metadata};
