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