import{S as so,i as no,s as oo,e as a,k as d,w as g,t as o,M as ro,c as s,d as i,m as c,a as n,x as _,h as r,b as l,N as lo,G as e,g as p,y as b,L as fo,q as v,o as S,B as y,v as co}from"../../../chunks/vendor-hf-doc-builder.js";import{D as Ut}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as Os}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as ae}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function po(Ns){let T,zt,A,z,Je,se,Ai,Qe,Ii,Ht,H,Li,ne,Mi,Ci,Ft,ke,Oi,Gt,Te,Ze,Ni,Rt,oe,et,qi,ji,Bt,F,tt,E,it,Ui,zi,at,Hi,Fi,Ae,Gi,Ri,Ie,Bi,Vi,st,$,nt,re,Wi,Ki,ot,rt,Xi,Yi,Le,le,Me,qs,Ji,Ce,Qi,Vt,I,G,lt,fe,Zi,ft,ea,Wt,Oe,de,ta,Ne,ia,aa,Kt,L,R,dt,ce,sa,ct,na,Xt,P,oa,qe,ra,la,pt,fa,da,je,ca,pa,Yt,M,B,ut,pe,ua,ht,ha,Jt,C,ma,mt,ga,_a,Ue,ba,Qt,ue,Zt,V,va,gt,Sa,ya,ei,O,W,_t,he,Da,bt,wa,ti,K,Pa,me,Ea,$a,ii,ge,ai,D,xa,vt,ka,Ta,St,Aa,Ia,yt,La,Ma,Dt,Ca,Oa,si,N,X,wt,_e,Na,Pt,qa,ni,u,ja,ze,Ua,za,Et,Ha,Fa,He,Ga,Ra,Fe,Ba,Va,Ge,Wa,Ka,Re,Xa,Ya,Be,Ja,Qa,$t,Za,es,xt,ts,is,Ve,as,ss,oi,be,ri,q,Y,kt,ve,ns,Tt,os,li,j,Se,rs,At,ls,fi,U,J,It,ye,fs,Lt,ds,di,m,De,cs,Mt,ps,us,We,hs,Ke,ms,gs,we,_s,Xe,bs,vs,Ss,Q,Pe,ys,Ct,Ds,ws,x,Ee,Ps,Ot,Es,$s,Nt,xs,ks,Z,$e,Ts,xe,As,qt,Is,Ls,ci;return se=new ae({}),fe=new ae({}),ce=new ae({}),pe=new ae({}),ue=new Os({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 ae({}),ge=new Os({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 ae({}),be=new Os({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 ae({}),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.11.0/src/diffusers/pipelines/stable_diffusion_safe/__init__.py#L46"}}),ye=new ae({}),De=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:": typing.Union[diffusers.schedulers.scheduling_ddim.DDIMScheduler, diffusers.schedulers.scheduling_dpmsolver_multistep.DPMSolverMultistepScheduler, diffusers.schedulers.scheduling_euler_ancestral_discrete.EulerAncestralDiscreteScheduler, diffusers.schedulers.scheduling_euler_discrete.EulerDiscreteScheduler, diffusers.schedulers.scheduling_lms_discrete.LMSDiscreteScheduler, diffusers.schedulers.scheduling_pndm.PNDMScheduler]"},{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.11.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.11.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.11.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.11.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/v0.11.0/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/v0.11.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.11.0/src/diffusers/pipelines/stable_diffusion_safe/pipeline_stable_diffusion_safe.py#L30"}}),Pe=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.11.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.11.0/en/api/pipelines/stable_diffusion#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.11.0/src/diffusers/pipelines/stable_diffusion_safe/pipeline_stable_diffusion_safe.py#L494",returnDescription:`
<p><a
  href="/docs/diffusers/v0.11.0/en/api/pipelines/stable_diffusion#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.11.0/en/api/pipelines/stable_diffusion#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),Ee=new Ut({props:{name:"enable_attention_slicing",anchor:"diffusers.StableDiffusionPipelineSafe.enable_attention_slicing",parameters:[{name:"slice_size",val:": typing.Union[str, int, NoneType] = 'auto'"}],parametersDescription:[{anchor:"diffusers.StableDiffusionPipelineSafe.enable_attention_slicing.slice_size",description:`<strong>slice_size</strong> (<code>str</code> or <code>int</code>, <em>optional</em>, defaults to <code>&quot;auto&quot;</code>) &#x2014;
When <code>&quot;auto&quot;</code>, halves the input to the attention heads, so attention will be computed in two steps. If
<code>&quot;max&quot;</code>, maxium amount of memory will be saved by running only one slice at a time. If a number is
provided, uses as many slices as <code>attention_head_dim // slice_size</code>. In this case, <code>attention_head_dim</code>
must be a multiple of <code>slice_size</code>.`,name:"slice_size"}],source:"https://github.com/huggingface/diffusers/blob/v0.11.0/src/diffusers/pipeline_utils.py#L849"}}),$e=new Ut({props:{name:"disable_attention_slicing",anchor:"diffusers.StableDiffusionPipelineSafe.disable_attention_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.11.0/src/diffusers/pipeline_utils.py#L865"}}),{c(){T=a("meta"),zt=d(),A=a("h1"),z=a("a"),Je=a("span"),g(se.$$.fragment),Ai=d(),Qe=a("span"),Ii=o("Safe Stable Diffusion"),Ht=d(),H=a("p"),Li=o("Safe Stable Diffusion was proposed in "),ne=a("a"),Mi=o("Safe Latent Diffusion: Mitigating Inappropriate Degeneration in Diffusion Models"),Ci=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.`),Ft=d(),ke=a("p"),Oi=o("The abstract of the paper is the following:"),Gt=d(),Te=a("p"),Ze=a("em"),Ni=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."),Rt=d(),oe=a("p"),et=a("em"),qi=o("Overview"),ji=o(":"),Bt=d(),F=a("table"),tt=a("thead"),E=a("tr"),it=a("th"),Ui=o("Pipeline"),zi=d(),at=a("th"),Hi=o("Tasks"),Fi=d(),Ae=a("th"),Gi=o("Colab"),Ri=d(),Ie=a("th"),Bi=o("Demo"),Vi=d(),st=a("tbody"),$=a("tr"),nt=a("td"),re=a("a"),Wi=o("pipeline_stable_diffusion_safe.py"),Ki=d(),ot=a("td"),rt=a("em"),Xi=o("Text-to-Image Generation"),Yi=d(),Le=a("td"),le=a("a"),Me=a("img"),Ji=d(),Ce=a("td"),Qi=o("-"),Vt=d(),I=a("h2"),G=a("a"),lt=a("span"),g(fe.$$.fragment),Zi=d(),ft=a("span"),ea=o("Tips"),Wt=d(),Oe=a("ul"),de=a("li"),ta=o("Safe Stable Diffusion may also be used with weights of "),Ne=a("a"),ia=o("Stable Diffusion"),aa=o("."),Kt=d(),L=a("h3"),R=a("a"),dt=a("span"),g(ce.$$.fragment),sa=d(),ct=a("span"),na=o("Run Safe Stable Diffusion"),Xt=d(),P=a("p"),oa=o("Safe Stable Diffusion can be tested very easily with the "),qe=a("a"),ra=o("StableDiffusionPipelineSafe"),la=o(", and the "),pt=a("code"),fa=o('"AIML-TUDA/stable-diffusion-safe"'),da=o(" checkpoint exactly in the same way it is shown in the "),je=a("a"),ca=o("Conditional Image Generation Guide"),pa=o("."),Yt=d(),M=a("h3"),B=a("a"),ut=a("span"),g(pe.$$.fragment),ua=d(),ht=a("span"),ha=o("Interacting with the Safety Concept"),Jt=d(),C=a("p"),ma=o("To check and edit the currently used safety concept, use the "),mt=a("code"),ga=o("safety_concept"),_a=o(" property of "),Ue=a("a"),ba=o("StableDiffusionPipelineSafe"),Qt=d(),g(ue.$$.fragment),Zt=d(),V=a("p"),va=o("For each image generation the active concept is also contained in "),gt=a("code"),Sa=o("StableDiffusionSafePipelineOutput"),ya=o("."),ei=d(),O=a("h3"),W=a("a"),_t=a("span"),g(he.$$.fragment),Da=d(),bt=a("span"),wa=o("Using pre-defined safety configurations"),ti=d(),K=a("p"),Pa=o("You may use the 4 configurations defined in the "),me=a("a"),Ea=o("Safe Latent Diffusion paper"),$a=o(" as follows:"),ii=d(),g(ge.$$.fragment),ai=d(),D=a("p"),xa=o("The following configurations are available: "),vt=a("code"),ka=o("SafetyConfig.WEAK"),Ta=o(", "),St=a("code"),Aa=o("SafetyConfig.MEDIUM"),Ia=o(", "),yt=a("code"),La=o("SafetyConfig.STRONg"),Ma=o(", and "),Dt=a("code"),Ca=o("SafetyConfig.MAX"),Oa=o("."),si=d(),N=a("h3"),X=a("a"),wt=a("span"),g(_e.$$.fragment),Na=d(),Pt=a("span"),qa=o("How to load and use different schedulers."),ni=d(),u=a("p"),ja=o("The safe stable diffusion pipeline uses "),ze=a("a"),Ua=o("PNDMScheduler"),za=o(" scheduler by default. But "),Et=a("code"),Ha=o("diffusers"),Fa=o(" provides many other schedulers that can be used with the stable diffusion pipeline such as "),He=a("a"),Ga=o("DDIMScheduler"),Ra=o(", "),Fe=a("a"),Ba=o("LMSDiscreteScheduler"),Va=o(", "),Ge=a("a"),Wa=o("EulerDiscreteScheduler"),Ka=o(", "),Re=a("a"),Xa=o("EulerAncestralDiscreteScheduler"),Ya=o(` etc.
To use a different scheduler, you can either change it via the `),Be=a("a"),Ja=o("ConfigMixin.from_config()"),Qa=o(" method or pass the "),$t=a("code"),Za=o("scheduler"),es=o(" argument to the "),xt=a("code"),ts=o("from_pretrained"),is=o(" method of the pipeline. For example, to use the "),Ve=a("a"),as=o("EulerDiscreteScheduler"),ss=o(", you can do the following:"),oi=d(),g(be.$$.fragment),ri=d(),q=a("h2"),Y=a("a"),kt=a("span"),g(ve.$$.fragment),ns=d(),Tt=a("span"),os=o("StableDiffusionSafePipelineOutput"),li=d(),j=a("div"),g(Se.$$.fragment),rs=d(),At=a("p"),ls=o("Output class for Safe Stable Diffusion pipelines."),fi=d(),U=a("h2"),J=a("a"),It=a("span"),g(ye.$$.fragment),fs=d(),Lt=a("span"),ds=o("StableDiffusionPipelineSafe"),di=d(),m=a("div"),g(De.$$.fragment),cs=d(),Mt=a("p"),ps=o("Pipeline for text-to-image generation using Safe Latent Diffusion."),us=d(),We=a("p"),hs=o("The implementation is based on the "),Ke=a("a"),ms=o("StableDiffusionPipeline"),gs=d(),we=a("p"),_s=o("This model inherits from "),Xe=a("a"),bs=o("DiffusionPipeline"),vs=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.)`),Ss=d(),Q=a("div"),g(Pe.$$.fragment),ys=d(),Ct=a("p"),Ds=o("Function invoked when calling the pipeline for generation."),ws=d(),x=a("div"),g(Ee.$$.fragment),Ps=d(),Ot=a("p"),Es=o("Enable sliced attention computation."),$s=d(),Nt=a("p"),xs=o(`When this option is enabled, the attention module will split the input tensor in slices, to compute attention
in several steps. This is useful to save some memory in exchange for a small speed decrease.`),ks=d(),Z=a("div"),g($e.$$.fragment),Ts=d(),xe=a("p"),As=o("Disable sliced attention computation. If "),qt=a("code"),Is=o("enable_attention_slicing"),Ls=o(` was previously invoked, this method will go
back to computing attention in one step.`),this.h()},l(t){const f=ro('[data-svelte="svelte-1phssyn"]',document.head);T=s(f,"META",{name:!0,content:!0}),f.forEach(i),zt=c(t),A=s(t,"H1",{class:!0});var pi=n(A);z=s(pi,"A",{id:!0,class:!0,href:!0});var js=n(z);Je=s(js,"SPAN",{});var Us=n(Je);_(se.$$.fragment,Us),Us.forEach(i),js.forEach(i),Ai=c(pi),Qe=s(pi,"SPAN",{});var zs=n(Qe);Ii=r(zs,"Safe Stable Diffusion"),zs.forEach(i),pi.forEach(i),Ht=c(t),H=s(t,"P",{});var ui=n(H);Li=r(ui,"Safe Stable Diffusion was proposed in "),ne=s(ui,"A",{href:!0,rel:!0});var Hs=n(ne);Mi=r(Hs,"Safe Latent Diffusion: Mitigating Inappropriate Degeneration in Diffusion Models"),Hs.forEach(i),Ci=r(ui,` 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.`),ui.forEach(i),Ft=c(t),ke=s(t,"P",{});var Fs=n(ke);Oi=r(Fs,"The abstract of the paper is the following:"),Fs.forEach(i),Gt=c(t),Te=s(t,"P",{});var Gs=n(Te);Ze=s(Gs,"EM",{});var Rs=n(Ze);Ni=r(Rs,"Text-conditioned image generation models have recently achieved astonishing results in image quality and text alignment and are consequently employed in a fast-growing number of applications. Since they are highly data-driven, relying on billion-sized datasets randomly scraped from the internet, they also suffer, as we demonstrate, from degenerated and biased human behavior. In turn, they may even reinforce such biases. To help combat these undesired side effects, we present safe latent diffusion (SLD). Specifically, to measure the inappropriate degeneration due to unfiltered and imbalanced training sets, we establish a novel image generation test bed-inappropriate image prompts (I2P)-containing dedicated, real-world image-to-text prompts covering concepts such as nudity and violence. As our exhaustive empirical evaluation demonstrates, the introduced SLD removes and suppresses inappropriate image parts during the diffusion process, with no additional training required and no adverse effect on overall image quality or text alignment."),Rs.forEach(i),Gs.forEach(i),Rt=c(t),oe=s(t,"P",{});var Ms=n(oe);et=s(Ms,"EM",{});var Bs=n(et);qi=r(Bs,"Overview"),Bs.forEach(i),ji=r(Ms,":"),Ms.forEach(i),Bt=c(t),F=s(t,"TABLE",{});var hi=n(F);tt=s(hi,"THEAD",{});var Vs=n(tt);E=s(Vs,"TR",{});var ee=n(E);it=s(ee,"TH",{});var Ws=n(it);Ui=r(Ws,"Pipeline"),Ws.forEach(i),zi=c(ee),at=s(ee,"TH",{});var Ks=n(at);Hi=r(Ks,"Tasks"),Ks.forEach(i),Fi=c(ee),Ae=s(ee,"TH",{align:!0});var Xs=n(Ae);Gi=r(Xs,"Colab"),Xs.forEach(i),Ri=c(ee),Ie=s(ee,"TH",{align:!0});var Ys=n(Ie);Bi=r(Ys,"Demo"),Ys.forEach(i),ee.forEach(i),Vs.forEach(i),Vi=c(hi),st=s(hi,"TBODY",{});var Js=n(st);$=s(Js,"TR",{});var te=n($);nt=s(te,"TD",{});var Qs=n(nt);re=s(Qs,"A",{href:!0,rel:!0});var Zs=n(re);Wi=r(Zs,"pipeline_stable_diffusion_safe.py"),Zs.forEach(i),Qs.forEach(i),Ki=c(te),ot=s(te,"TD",{});var en=n(ot);rt=s(en,"EM",{});var tn=n(rt);Xi=r(tn,"Text-to-Image Generation"),tn.forEach(i),en.forEach(i),Yi=c(te),Le=s(te,"TD",{align:!0});var an=n(Le);le=s(an,"A",{href:!0,rel:!0});var sn=n(le);Me=s(sn,"IMG",{src:!0,alt:!0}),sn.forEach(i),an.forEach(i),Ji=c(te),Ce=s(te,"TD",{align:!0});var nn=n(Ce);Qi=r(nn,"-"),nn.forEach(i),te.forEach(i),Js.forEach(i),hi.forEach(i),Vt=c(t),I=s(t,"H2",{class:!0});var mi=n(I);G=s(mi,"A",{id:!0,class:!0,href:!0});var on=n(G);lt=s(on,"SPAN",{});var rn=n(lt);_(fe.$$.fragment,rn),rn.forEach(i),on.forEach(i),Zi=c(mi),ft=s(mi,"SPAN",{});var ln=n(ft);ea=r(ln,"Tips"),ln.forEach(i),mi.forEach(i),Wt=c(t),Oe=s(t,"UL",{});var fn=n(Oe);de=s(fn,"LI",{});var gi=n(de);ta=r(gi,"Safe Stable Diffusion may also be used with weights of "),Ne=s(gi,"A",{href:!0});var dn=n(Ne);ia=r(dn,"Stable Diffusion"),dn.forEach(i),aa=r(gi,"."),gi.forEach(i),fn.forEach(i),Kt=c(t),L=s(t,"H3",{class:!0});var _i=n(L);R=s(_i,"A",{id:!0,class:!0,href:!0});var cn=n(R);dt=s(cn,"SPAN",{});var pn=n(dt);_(ce.$$.fragment,pn),pn.forEach(i),cn.forEach(i),sa=c(_i),ct=s(_i,"SPAN",{});var un=n(ct);na=r(un,"Run Safe Stable Diffusion"),un.forEach(i),_i.forEach(i),Xt=c(t),P=s(t,"P",{});var ie=n(P);oa=r(ie,"Safe Stable Diffusion can be tested very easily with the "),qe=s(ie,"A",{href:!0});var hn=n(qe);ra=r(hn,"StableDiffusionPipelineSafe"),hn.forEach(i),la=r(ie,", and the "),pt=s(ie,"CODE",{});var mn=n(pt);fa=r(mn,'"AIML-TUDA/stable-diffusion-safe"'),mn.forEach(i),da=r(ie," checkpoint exactly in the same way it is shown in the "),je=s(ie,"A",{href:!0});var gn=n(je);ca=r(gn,"Conditional Image Generation Guide"),gn.forEach(i),pa=r(ie,"."),ie.forEach(i),Yt=c(t),M=s(t,"H3",{class:!0});var bi=n(M);B=s(bi,"A",{id:!0,class:!0,href:!0});var _n=n(B);ut=s(_n,"SPAN",{});var bn=n(ut);_(pe.$$.fragment,bn),bn.forEach(i),_n.forEach(i),ua=c(bi),ht=s(bi,"SPAN",{});var vn=n(ht);ha=r(vn,"Interacting with the Safety Concept"),vn.forEach(i),bi.forEach(i),Jt=c(t),C=s(t,"P",{});var jt=n(C);ma=r(jt,"To check and edit the currently used safety concept, use the "),mt=s(jt,"CODE",{});var Sn=n(mt);ga=r(Sn,"safety_concept"),Sn.forEach(i),_a=r(jt," property of "),Ue=s(jt,"A",{href:!0});var yn=n(Ue);ba=r(yn,"StableDiffusionPipelineSafe"),yn.forEach(i),jt.forEach(i),Qt=c(t),_(ue.$$.fragment,t),Zt=c(t),V=s(t,"P",{});var vi=n(V);va=r(vi,"For each image generation the active concept is also contained in "),gt=s(vi,"CODE",{});var Dn=n(gt);Sa=r(Dn,"StableDiffusionSafePipelineOutput"),Dn.forEach(i),ya=r(vi,"."),vi.forEach(i),ei=c(t),O=s(t,"H3",{class:!0});var Si=n(O);W=s(Si,"A",{id:!0,class:!0,href:!0});var wn=n(W);_t=s(wn,"SPAN",{});var Pn=n(_t);_(he.$$.fragment,Pn),Pn.forEach(i),wn.forEach(i),Da=c(Si),bt=s(Si,"SPAN",{});var En=n(bt);wa=r(En,"Using pre-defined safety configurations"),En.forEach(i),Si.forEach(i),ti=c(t),K=s(t,"P",{});var yi=n(K);Pa=r(yi,"You may use the 4 configurations defined in the "),me=s(yi,"A",{href:!0,rel:!0});var $n=n(me);Ea=r($n,"Safe Latent Diffusion paper"),$n.forEach(i),$a=r(yi," as follows:"),yi.forEach(i),ii=c(t),_(ge.$$.fragment,t),ai=c(t),D=s(t,"P",{});var k=n(D);xa=r(k,"The following configurations are available: "),vt=s(k,"CODE",{});var xn=n(vt);ka=r(xn,"SafetyConfig.WEAK"),xn.forEach(i),Ta=r(k,", "),St=s(k,"CODE",{});var kn=n(St);Aa=r(kn,"SafetyConfig.MEDIUM"),kn.forEach(i),Ia=r(k,", "),yt=s(k,"CODE",{});var Tn=n(yt);La=r(Tn,"SafetyConfig.STRONg"),Tn.forEach(i),Ma=r(k,", and "),Dt=s(k,"CODE",{});var An=n(Dt);Ca=r(An,"SafetyConfig.MAX"),An.forEach(i),Oa=r(k,"."),k.forEach(i),si=c(t),N=s(t,"H3",{class:!0});var Di=n(N);X=s(Di,"A",{id:!0,class:!0,href:!0});var In=n(X);wt=s(In,"SPAN",{});var Ln=n(wt);_(_e.$$.fragment,Ln),Ln.forEach(i),In.forEach(i),Na=c(Di),Pt=s(Di,"SPAN",{});var Mn=n(Pt);qa=r(Mn,"How to load and use different schedulers."),Mn.forEach(i),Di.forEach(i),ni=c(t),u=s(t,"P",{});var h=n(u);ja=r(h,"The safe stable diffusion pipeline uses "),ze=s(h,"A",{href:!0});var Cn=n(ze);Ua=r(Cn,"PNDMScheduler"),Cn.forEach(i),za=r(h," scheduler by default. But "),Et=s(h,"CODE",{});var On=n(Et);Ha=r(On,"diffusers"),On.forEach(i),Fa=r(h," provides many other schedulers that can be used with the stable diffusion pipeline such as "),He=s(h,"A",{href:!0});var Nn=n(He);Ga=r(Nn,"DDIMScheduler"),Nn.forEach(i),Ra=r(h,", "),Fe=s(h,"A",{href:!0});var qn=n(Fe);Ba=r(qn,"LMSDiscreteScheduler"),qn.forEach(i),Va=r(h,", "),Ge=s(h,"A",{href:!0});var jn=n(Ge);Wa=r(jn,"EulerDiscreteScheduler"),jn.forEach(i),Ka=r(h,", "),Re=s(h,"A",{href:!0});var Un=n(Re);Xa=r(Un,"EulerAncestralDiscreteScheduler"),Un.forEach(i),Ya=r(h,` etc.
To use a different scheduler, you can either change it via the `),Be=s(h,"A",{href:!0});var zn=n(Be);Ja=r(zn,"ConfigMixin.from_config()"),zn.forEach(i),Qa=r(h," method or pass the "),$t=s(h,"CODE",{});var Hn=n($t);Za=r(Hn,"scheduler"),Hn.forEach(i),es=r(h," argument to the "),xt=s(h,"CODE",{});var Fn=n(xt);ts=r(Fn,"from_pretrained"),Fn.forEach(i),is=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(i),ss=r(h,", you can do the following:"),h.forEach(i),oi=c(t),_(be.$$.fragment,t),ri=c(t),q=s(t,"H2",{class:!0});var wi=n(q);Y=s(wi,"A",{id:!0,class:!0,href:!0});var Rn=n(Y);kt=s(Rn,"SPAN",{});var Bn=n(kt);_(ve.$$.fragment,Bn),Bn.forEach(i),Rn.forEach(i),ns=c(wi),Tt=s(wi,"SPAN",{});var Vn=n(Tt);os=r(Vn,"StableDiffusionSafePipelineOutput"),Vn.forEach(i),wi.forEach(i),li=c(t),j=s(t,"DIV",{class:!0});var Pi=n(j);_(Se.$$.fragment,Pi),rs=c(Pi),At=s(Pi,"P",{});var Wn=n(At);ls=r(Wn,"Output class for Safe Stable Diffusion pipelines."),Wn.forEach(i),Pi.forEach(i),fi=c(t),U=s(t,"H2",{class:!0});var Ei=n(U);J=s(Ei,"A",{id:!0,class:!0,href:!0});var Kn=n(J);It=s(Kn,"SPAN",{});var Xn=n(It);_(ye.$$.fragment,Xn),Xn.forEach(i),Kn.forEach(i),fs=c(Ei),Lt=s(Ei,"SPAN",{});var Yn=n(Lt);ds=r(Yn,"StableDiffusionPipelineSafe"),Yn.forEach(i),Ei.forEach(i),di=c(t),m=s(t,"DIV",{class:!0});var w=n(m);_(De.$$.fragment,w),cs=c(w),Mt=s(w,"P",{});var Jn=n(Mt);ps=r(Jn,"Pipeline for text-to-image generation using Safe Latent Diffusion."),Jn.forEach(i),us=c(w),We=s(w,"P",{});var Cs=n(We);hs=r(Cs,"The implementation is based on the "),Ke=s(Cs,"A",{href:!0});var Qn=n(Ke);ms=r(Qn,"StableDiffusionPipeline"),Qn.forEach(i),Cs.forEach(i),gs=c(w),we=s(w,"P",{});var $i=n(we);_s=r($i,"This model inherits from "),Xe=s($i,"A",{href:!0});var Zn=n(Xe);bs=r(Zn,"DiffusionPipeline"),Zn.forEach(i),vs=r($i,`. 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.)`),$i.forEach(i),Ss=c(w),Q=s(w,"DIV",{class:!0});var xi=n(Q);_(Pe.$$.fragment,xi),ys=c(xi),Ct=s(xi,"P",{});var eo=n(Ct);Ds=r(eo,"Function invoked when calling the pipeline for generation."),eo.forEach(i),xi.forEach(i),ws=c(w),x=s(w,"DIV",{class:!0});var Ye=n(x);_(Ee.$$.fragment,Ye),Ps=c(Ye),Ot=s(Ye,"P",{});var to=n(Ot);Es=r(to,"Enable sliced attention computation."),to.forEach(i),$s=c(Ye),Nt=s(Ye,"P",{});var io=n(Nt);xs=r(io,`When this option is enabled, the attention module will split the input tensor in slices, to compute attention
in several steps. This is useful to save some memory in exchange for a small speed decrease.`),io.forEach(i),Ye.forEach(i),ks=c(w),Z=s(w,"DIV",{class:!0});var ki=n(Z);_($e.$$.fragment,ki),Ts=c(ki),xe=s(ki,"P",{});var Ti=n(xe);As=r(Ti,"Disable sliced attention computation. If "),qt=s(Ti,"CODE",{});var ao=n(qt);Is=r(ao,"enable_attention_slicing"),ao.forEach(i),Ls=r(Ti,` was previously invoked, this method will go
back to computing attention in one step.`),Ti.forEach(i),ki.forEach(i),w.forEach(i),this.h()},h(){l(T,"name","hf:doc:metadata"),l(T,"content",JSON.stringify(uo)),l(z,"id","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","#safe-stable-diffusion"),l(A,"class","relative group"),l(ne,"href","https://arxiv.org/abs/2211.05105"),l(ne,"rel","nofollow"),l(Ae,"align","center"),l(Ie,"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"),lo(Me.src,qs="https://colab.research.google.com/assets/colab-badge.svg")||l(Me,"src",qs),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(Le,"align","center"),l(Ce,"align","center"),l(G,"id","tips"),l(G,"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(G,"href","#tips"),l(I,"class","relative group"),l(Ne,"href","./api/pipelines/stable_diffusion"),l(R,"id","run-safe-stable-diffusion"),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","#run-safe-stable-diffusion"),l(L,"class","relative group"),l(qe,"href","/docs/diffusers/v0.11.0/en/api/pipelines/stable_diffusion_safe#diffusers.StableDiffusionPipelineSafe"),l(je,"href","./using-diffusers/conditional_image_generation"),l(B,"id","interacting-with-the-safety-concept"),l(B,"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(B,"href","#interacting-with-the-safety-concept"),l(M,"class","relative group"),l(Ue,"href","/docs/diffusers/v0.11.0/en/api/pipelines/stable_diffusion_safe#diffusers.StableDiffusionPipelineSafe"),l(W,"id","using-predefined-safety-configurations"),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","#using-predefined-safety-configurations"),l(O,"class","relative group"),l(me,"href","https://arxiv.org/abs/2211.05105"),l(me,"rel","nofollow"),l(X,"id","how-to-load-and-use-different-schedulers"),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","#how-to-load-and-use-different-schedulers"),l(N,"class","relative group"),l(ze,"href","/docs/diffusers/v0.11.0/en/api/schedulers/pndm#diffusers.PNDMScheduler"),l(He,"href","/docs/diffusers/v0.11.0/en/api/schedulers/ddim#diffusers.DDIMScheduler"),l(Fe,"href","/docs/diffusers/v0.11.0/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler"),l(Ge,"href","/docs/diffusers/v0.11.0/en/api/schedulers/euler#diffusers.EulerDiscreteScheduler"),l(Re,"href","/docs/diffusers/v0.11.0/en/api/schedulers/euler_ancestral#diffusers.EulerAncestralDiscreteScheduler"),l(Be,"href","/docs/diffusers/v0.11.0/en/api/configuration#diffusers.ConfigMixin.from_config"),l(Ve,"href","/docs/diffusers/v0.11.0/en/api/schedulers/euler#diffusers.EulerDiscreteScheduler"),l(Y,"id","diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput"),l(Y,"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(Y,"href","#diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput"),l(q,"class","relative group"),l(j,"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(Ke,"href","/docs/diffusers/v0.11.0/en/api/pipelines/stable_diffusion#diffusers.StableDiffusionPipeline"),l(Xe,"href","/docs/diffusers/v0.11.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(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(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(m,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,f){e(document.head,T),p(t,zt,f),p(t,A,f),e(A,z),e(z,Je),b(se,Je,null),e(A,Ai),e(A,Qe),e(Qe,Ii),p(t,Ht,f),p(t,H,f),e(H,Li),e(H,ne),e(ne,Mi),e(H,Ci),p(t,Ft,f),p(t,ke,f),e(ke,Oi),p(t,Gt,f),p(t,Te,f),e(Te,Ze),e(Ze,Ni),p(t,Rt,f),p(t,oe,f),e(oe,et),e(et,qi),e(oe,ji),p(t,Bt,f),p(t,F,f),e(F,tt),e(tt,E),e(E,it),e(it,Ui),e(E,zi),e(E,at),e(at,Hi),e(E,Fi),e(E,Ae),e(Ae,Gi),e(E,Ri),e(E,Ie),e(Ie,Bi),e(F,Vi),e(F,st),e(st,$),e($,nt),e(nt,re),e(re,Wi),e($,Ki),e($,ot),e(ot,rt),e(rt,Xi),e($,Yi),e($,Le),e(Le,le),e(le,Me),e($,Ji),e($,Ce),e(Ce,Qi),p(t,Vt,f),p(t,I,f),e(I,G),e(G,lt),b(fe,lt,null),e(I,Zi),e(I,ft),e(ft,ea),p(t,Wt,f),p(t,Oe,f),e(Oe,de),e(de,ta),e(de,Ne),e(Ne,ia),e(de,aa),p(t,Kt,f),p(t,L,f),e(L,R),e(R,dt),b(ce,dt,null),e(L,sa),e(L,ct),e(ct,na),p(t,Xt,f),p(t,P,f),e(P,oa),e(P,qe),e(qe,ra),e(P,la),e(P,pt),e(pt,fa),e(P,da),e(P,je),e(je,ca),e(P,pa),p(t,Yt,f),p(t,M,f),e(M,B),e(B,ut),b(pe,ut,null),e(M,ua),e(M,ht),e(ht,ha),p(t,Jt,f),p(t,C,f),e(C,ma),e(C,mt),e(mt,ga),e(C,_a),e(C,Ue),e(Ue,ba),p(t,Qt,f),b(ue,t,f),p(t,Zt,f),p(t,V,f),e(V,va),e(V,gt),e(gt,Sa),e(V,ya),p(t,ei,f),p(t,O,f),e(O,W),e(W,_t),b(he,_t,null),e(O,Da),e(O,bt),e(bt,wa),p(t,ti,f),p(t,K,f),e(K,Pa),e(K,me),e(me,Ea),e(K,$a),p(t,ii,f),b(ge,t,f),p(t,ai,f),p(t,D,f),e(D,xa),e(D,vt),e(vt,ka),e(D,Ta),e(D,St),e(St,Aa),e(D,Ia),e(D,yt),e(yt,La),e(D,Ma),e(D,Dt),e(Dt,Ca),e(D,Oa),p(t,si,f),p(t,N,f),e(N,X),e(X,wt),b(_e,wt,null),e(N,Na),e(N,Pt),e(Pt,qa),p(t,ni,f),p(t,u,f),e(u,ja),e(u,ze),e(ze,Ua),e(u,za),e(u,Et),e(Et,Ha),e(u,Fa),e(u,He),e(He,Ga),e(u,Ra),e(u,Fe),e(Fe,Ba),e(u,Va),e(u,Ge),e(Ge,Wa),e(u,Ka),e(u,Re),e(Re,Xa),e(u,Ya),e(u,Be),e(Be,Ja),e(u,Qa),e(u,$t),e($t,Za),e(u,es),e(u,xt),e(xt,ts),e(u,is),e(u,Ve),e(Ve,as),e(u,ss),p(t,oi,f),b(be,t,f),p(t,ri,f),p(t,q,f),e(q,Y),e(Y,kt),b(ve,kt,null),e(q,ns),e(q,Tt),e(Tt,os),p(t,li,f),p(t,j,f),b(Se,j,null),e(j,rs),e(j,At),e(At,ls),p(t,fi,f),p(t,U,f),e(U,J),e(J,It),b(ye,It,null),e(U,fs),e(U,Lt),e(Lt,ds),p(t,di,f),p(t,m,f),b(De,m,null),e(m,cs),e(m,Mt),e(Mt,ps),e(m,us),e(m,We),e(We,hs),e(We,Ke),e(Ke,ms),e(m,gs),e(m,we),e(we,_s),e(we,Xe),e(Xe,bs),e(we,vs),e(m,Ss),e(m,Q),b(Pe,Q,null),e(Q,ys),e(Q,Ct),e(Ct,Ds),e(m,ws),e(m,x),b(Ee,x,null),e(x,Ps),e(x,Ot),e(Ot,Es),e(x,$s),e(x,Nt),e(Nt,xs),e(m,ks),e(m,Z),b($e,Z,null),e(Z,Ts),e(Z,xe),e(xe,As),e(xe,qt),e(qt,Is),e(xe,Ls),ci=!0},p:fo,i(t){ci||(v(se.$$.fragment,t),v(fe.$$.fragment,t),v(ce.$$.fragment,t),v(pe.$$.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(Pe.$$.fragment,t),v(Ee.$$.fragment,t),v($e.$$.fragment,t),ci=!0)},o(t){S(se.$$.fragment,t),S(fe.$$.fragment,t),S(ce.$$.fragment,t),S(pe.$$.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(Pe.$$.fragment,t),S(Ee.$$.fragment,t),S($e.$$.fragment,t),ci=!1},d(t){i(T),t&&i(zt),t&&i(A),y(se),t&&i(Ht),t&&i(H),t&&i(Ft),t&&i(ke),t&&i(Gt),t&&i(Te),t&&i(Rt),t&&i(oe),t&&i(Bt),t&&i(F),t&&i(Vt),t&&i(I),y(fe),t&&i(Wt),t&&i(Oe),t&&i(Kt),t&&i(L),y(ce),t&&i(Xt),t&&i(P),t&&i(Yt),t&&i(M),y(pe),t&&i(Jt),t&&i(C),t&&i(Qt),y(ue,t),t&&i(Zt),t&&i(V),t&&i(ei),t&&i(O),y(he),t&&i(ti),t&&i(K),t&&i(ii),y(ge,t),t&&i(ai),t&&i(D),t&&i(si),t&&i(N),y(_e),t&&i(ni),t&&i(u),t&&i(oi),y(be,t),t&&i(ri),t&&i(q),y(ve),t&&i(li),t&&i(j),y(Se),t&&i(fi),t&&i(U),y(ye),t&&i(di),t&&i(m),y(De),y(Pe),y(Ee),y($e)}}}const uo={local:"safe-stable-diffusion",sections:[{local:"tips",sections:[{local:"run-safe-stable-diffusion",title:"Run Safe Stable Diffusion"},{local:"interacting-with-the-safety-concept",title:"Interacting with the Safety Concept"},{local:"using-predefined-safety-configurations",title:"Using pre-defined safety configurations"},{local:"how-to-load-and-use-different-schedulers",title:"How to load and use different schedulers."}],title:"Tips"},{local:"diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput",title:"StableDiffusionSafePipelineOutput"},{local:"diffusers.StableDiffusionPipelineSafe",title:"StableDiffusionPipelineSafe"}],title:"Safe Stable Diffusion"};function ho(Ns){return co(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class vo extends so{constructor(T){super();no(this,T,ho,po,oo,{})}}export{vo as default,uo as metadata};
