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