import{s as Ye,o as qe,n as Ae}from"../chunks/scheduler.8c3d61f6.js";import{S as Re,i as Fe,g as l,s as i,r as h,A as Qe,h as r,f as n,c as s,j as te,u as _,x as m,k as ne,y as f,a,v as b,d as S,t as y,w as v}from"../chunks/index.da70eac4.js";import{T as Ke}from"../chunks/Tip.1d9b8c37.js";import{D as ve}from"../chunks/Docstring.ee4b6913.js";import{C as Ce}from"../chunks/CodeBlock.00a903b3.js";import{E as et}from"../chunks/ExampleCodeBlock.f7bd2c1f.js";import{H as we,E as tt}from"../chunks/EditOnGithub.1e64e623.js";function nt(z){let o,$='Make sure to check out the Stable Diffusion <a href="overview#tips">Tips</a> section to learn how to explore the tradeoff between scheduler speed and quality, and how to reuse pipeline components efficiently!';return{c(){o=l("p"),o.innerHTML=$},l(c){o=r(c,"P",{"data-svelte-h":!0}),m(o)!=="svelte-1j961ct"&&(o.innerHTML=$)},m(c,g){a(c,o,g)},p:Ae,d(c){c&&n(o)}}}function at(z){let o,$="Examples:",c,g,w;return g=new Ce({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmVTYWZlJTBBZnJvbSUyMGRpZmZ1c2Vycy5waXBlbGluZXMuc3RhYmxlX2RpZmZ1c2lvbl9zYWZlJTIwaW1wb3J0JTIwU2FmZXR5Q29uZmlnJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25QaXBlbGluZVNhZmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMkFJTUwtVFVEQSUyRnN0YWJsZS1kaWZmdXNpb24tc2FmZSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSkudG8oJTIyY3VkYSUyMiklMEFwcm9tcHQlMjAlM0QlMjAlMjJ0aGUlMjBmb3VyJTIwaG9yc2V3b21lbiUyMG9mJTIwdGhlJTIwYXBvY2FseXBzZSUyQyUyMHBhaW50aW5nJTIwYnklMjB0b20lMjBvZiUyMGZpbmxhbmQlMkMlMjBnYXN0b24lMjBidXNzaWVyZSUyQyUyMGNyYWlnJTIwbXVsbGlucyUyQyUyMGouJTIwYy4lMjBsZXllbmRlY2tlciUyMiUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTNEcHJvbXB0JTJDJTIwKipTYWZldHlDb25maWcuTUVESVVNKS5pbWFnZXMlNUIwJTVE",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipelineSafe
<span class="hljs-keyword">from</span> diffusers.pipelines.stable_diffusion_safe <span class="hljs-keyword">import</span> SafetyConfig

pipeline = StableDiffusionPipelineSafe.from_pretrained(
    <span class="hljs-string">&quot;AIML-TUDA/stable-diffusion-safe&quot;</span>, torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</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>
image = pipeline(prompt=prompt, **SafetyConfig.MEDIUM).images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){o=l("p"),o.textContent=$,c=i(),h(g.$$.fragment)},l(d){o=r(d,"P",{"data-svelte-h":!0}),m(o)!=="svelte-kvfsh7"&&(o.textContent=$),c=s(d),_(g.$$.fragment,d)},m(d,M){a(d,o,M),a(d,c,M),b(g,d,M),w=!0},p:Ae,i(d){w||(S(g.$$.fragment,d),w=!0)},o(d){y(g.$$.fragment,d),w=!1},d(d){d&&(n(o),n(c)),v(g,d)}}}function it(z){let o,$,c,g,w,d,M,Le='Safe Stable Diffusion was proposed in <a href="https://huggingface.co/papers/2211.05105" rel="nofollow">Safe Latent Diffusion: Mitigating Inappropriate Degeneration in Diffusion Models</a> and mitigates inappropriate degeneration from Stable Diffusion models because they’re trained on unfiltered web-crawled datasets. For instance Stable Diffusion may unexpectedly generate nudity, violence, images depicting self-harm, and otherwise offensive content. Safe Stable Diffusion is an extension of Stable Diffusion that drastically reduces this type of content.',ie,U,Je="The abstract from the paper is:",se,Z,Ge="<em>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.</em>",oe,C,le,L,je='Use the <code>safety_concept</code> property of <a href="/docs/diffusers/v0.30.0/en/api/pipelines/stable_diffusion/stable_diffusion_safe#diffusers.StableDiffusionPipelineSafe">StableDiffusionPipelineSafe</a> to check and edit the current safety concept:',re,J,fe,G,Ne="For each image generation the active concept is also contained in <code>StableDiffusionSafePipelineOutput</code>.",de,j,We="There are 4 configurations (<code>SafetyConfig.WEAK</code>, <code>SafetyConfig.MEDIUM</code>, <code>SafetyConfig.STRONG</code>, and <code>SafetyConfig.MAX</code>) that can be applied:",pe,N,ce,T,ue,W,me,p,V,Me,A,Ve='Pipeline based on the <a href="/docs/diffusers/v0.30.0/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline">StableDiffusionPipeline</a> for text-to-image generation using Safe Latent Diffusion.',xe,Y,Be=`This model inherits from <a href="/docs/diffusers/v0.30.0/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a>. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`,$e,q,Oe="The pipeline also inherits the following loading methods:",De,R,He='<li><a href="/docs/diffusers/v0.30.0/en/api/loaders/ip_adapter#diffusers.loaders.IPAdapterMixin.load_ip_adapter">load_ip_adapter()</a> for loading IP Adapters</li>',Pe,D,B,Te,F,Ee="The call function to the pipeline for generation.",ke,k,ge,O,he,x,H,Ie,Q,Xe="Output class for Safe Stable Diffusion pipelines.",Ue,I,E,Ze,K,ze="Call self as a function.",_e,X,be,ae,Se;return w=new we({props:{title:"Safe Stable Diffusion",local:"safe-stable-diffusion",headingTag:"h1"}}),C=new we({props:{title:"Tips",local:"tips",headingTag:"h2"}}),J=new Ce({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lU2FmZSUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmVTYWZlLmZyb21fcHJldHJhaW5lZCglMjJBSU1MLVRVREElMkZzdGFibGUtZGlmZnVzaW9uLXNhZmUlMjIpJTBBcGlwZWxpbmUuc2FmZXR5X2NvbmNlcHQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipelineSafe

<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline = StableDiffusionPipelineSafe.from_pretrained(<span class="hljs-string">&quot;AIML-TUDA/stable-diffusion-safe&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline.safety_concept
<span class="hljs-string">&#x27;an image showing hate, harassment, violence, suffering, humiliation, harm, suicide, sexual, nudity, bodily fluids, blood, obscene gestures, illegal activity, drug use, theft, vandalism, weapons, child abuse, brutality, cruelty&#x27;</span>`,wrap:!1}}),N=new Ce({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lU2FmZSUwQWZyb20lMjBkaWZmdXNlcnMucGlwZWxpbmVzLnN0YWJsZV9kaWZmdXNpb25fc2FmZSUyMGltcG9ydCUyMFNhZmV0eUNvbmZpZyUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmVTYWZlLmZyb21fcHJldHJhaW5lZCglMjJBSU1MLVRVREElMkZzdGFibGUtZGlmZnVzaW9uLXNhZmUlMjIpJTBBcHJvbXB0JTIwJTNEJTIwJTIydGhlJTIwZm91ciUyMGhvcnNld29tZW4lMjBvZiUyMHRoZSUyMGFwb2NhbHlwc2UlMkMlMjBwYWludGluZyUyMGJ5JTIwdG9tJTIwb2YlMjBmaW5sYW5kJTJDJTIwZ2FzdG9uJTIwYnVzc2llcmUlMkMlMjBjcmFpZyUyMG11bGxpbnMlMkMlMjBqLiUyMGMuJTIwbGV5ZW5kZWNrZXIlMjIlMEFvdXQlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlM0Rwcm9tcHQlMkMlMjAqKlNhZmV0eUNvbmZpZy5NQVgp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipelineSafe
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers.pipelines.stable_diffusion_safe <span class="hljs-keyword">import</span> SafetyConfig

<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline = StableDiffusionPipelineSafe.from_pretrained(<span class="hljs-string">&quot;AIML-TUDA/stable-diffusion-safe&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;the four horsewomen of the apocalypse, painting by tom of finland, gaston bussiere, craig mullins, j. c. leyendecker&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>out = pipeline(prompt=prompt, **SafetyConfig.MAX)`,wrap:!1}}),T=new Ke({props:{$$slots:{default:[nt]},$$scope:{ctx:z}}}),W=new we({props:{title:"StableDiffusionPipelineSafe",local:"diffusers.StableDiffusionPipelineSafe",headingTag:"h2"}}),V=new ve({props:{name:"class diffusers.StableDiffusionPipelineSafe",anchor:"diffusers.StableDiffusionPipelineSafe",parameters:[{name:"vae",val:": AutoencoderKL"},{name:"text_encoder",val:": CLIPTextModel"},{name:"tokenizer",val:": CLIPTokenizer"},{name:"unet",val:": UNet2DConditionModel"},{name:"scheduler",val:": KarrasDiffusionSchedulers"},{name:"safety_checker",val:": SafeStableDiffusionSafetyChecker"},{name:"feature_extractor",val:": CLIPImageProcessor"},{name:"image_encoder",val:": Optional = None"},{name:"requires_safety_checker",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.StableDiffusionPipelineSafe.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/v0.30.0/en/api/models/autoencoderkl#diffusers.AutoencoderKL">AutoencoderKL</a>) &#x2014;
Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.StableDiffusionPipelineSafe.text_encoder",description:`<strong>text_encoder</strong> (<a href="https://huggingface.co/docs/transformers/v4.44.0/en/model_doc/clip#transformers.CLIPTextModel" rel="nofollow">CLIPTextModel</a>) &#x2014;
Frozen text-encoder (<a href="https://huggingface.co/openai/clip-vit-large-patch14" rel="nofollow">clip-vit-large-patch14</a>).`,name:"text_encoder"},{anchor:"diffusers.StableDiffusionPipelineSafe.tokenizer",description:`<strong>tokenizer</strong> (<a href="https://huggingface.co/docs/transformers/v4.44.0/en/model_doc/clip#transformers.CLIPTokenizer" rel="nofollow">CLIPTokenizer</a>) &#x2014;
A <code>CLIPTokenizer</code> to tokenize text.`,name:"tokenizer"},{anchor:"diffusers.StableDiffusionPipelineSafe.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/v0.30.0/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) &#x2014;
A <code>UNet2DConditionModel</code> to denoise the encoded image latents.`,name:"unet"},{anchor:"diffusers.StableDiffusionPipelineSafe.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/v0.30.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.30.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/v0.30.0/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/v0.30.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 more details
about a model&#x2019;s potential harms.`,name:"safety_checker"},{anchor:"diffusers.StableDiffusionPipelineSafe.feature_extractor",description:`<strong>feature_extractor</strong> (<a href="https://huggingface.co/docs/transformers/v4.44.0/en/model_doc/clip#transformers.CLIPImageProcessor" rel="nofollow">CLIPImageProcessor</a>) &#x2014;
A <code>CLIPImageProcessor</code> to extract features from generated images; used as inputs to the <code>safety_checker</code>.`,name:"feature_extractor"}],source:"https://github.com/huggingface/diffusers/blob/v0.30.0/src/diffusers/pipelines/stable_diffusion_safe/pipeline_stable_diffusion_safe.py#L25"}}),B=new ve({props:{name:"__call__",anchor:"diffusers.StableDiffusionPipelineSafe.__call__",parameters:[{name:"prompt",val:": Union"},{name:"height",val:": Optional = None"},{name:"width",val:": Optional = None"},{name:"num_inference_steps",val:": int = 50"},{name:"guidance_scale",val:": float = 7.5"},{name:"negative_prompt",val:": Union = None"},{name:"num_images_per_prompt",val:": Optional = 1"},{name:"eta",val:": float = 0.0"},{name:"generator",val:": Union = None"},{name:"latents",val:": Optional = None"},{name:"ip_adapter_image",val:": Union = None"},{name:"output_type",val:": Optional = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"callback",val:": Optional = None"},{name:"callback_steps",val:": int = 1"},{name:"sld_guidance_scale",val:": Optional = 1000"},{name:"sld_warmup_steps",val:": Optional = 10"},{name:"sld_threshold",val:": Optional = 0.01"},{name:"sld_momentum_scale",val:": Optional = 0.3"},{name:"sld_mom_beta",val:": Optional = 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 image generation. If not defined, you need to pass <code>prompt_embeds</code>.`,name:"prompt"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.unet.config.sample_size * self.vae_scale_factor</code>) &#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 <code>self.unet.config.sample_size * self.vae_scale_factor</code>) &#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;
A higher guidance scale value encourages the model to generate images closely linked to the text
<code>prompt</code> at the expense of lower image quality. Guidance scale is enabled when <code>guidance_scale &gt; 1</code>.`,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 to guide what to not include in image generation. If not defined, you need to
pass <code>negative_prompt_embeds</code> instead. Ignored when not using guidance (<code>guidance_scale &lt; 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;) from the <a href="https://arxiv.org/abs/2010.02502" rel="nofollow">DDIM</a> paper. Only applies
to the <a href="/docs/diffusers/v0.30.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, and is ignored in other schedulers.`,name:"eta"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code> or <code>List[torch.Generator]</code>, <em>optional</em>) &#x2014;
A <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow"><code>torch.Generator</code></a> to make
generation deterministic.`,name:"generator"},{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.latents",description:`<strong>latents</strong> (<code>torch.Tensor</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 is generated by sampling using the supplied random <code>generator</code>.
ip_adapter_image &#x2014; (<code>PipelineImageInput</code>, <em>optional</em>):
Optional image input to work with IP Adapters.`,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 generated image. Choose between <code>PIL.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.30.0/en/api/pipelines/stable_diffusion/image_variation#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 calls every <code>callback_steps</code> steps during inference. The function is called with the
following arguments: <code>callback(step: int, timestep: int, latents: torch.Tensor)</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 is called. If not specified, the callback is 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;
If <code>sld_guidance_scale &lt; 1</code>, safety guidance is 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 is only be applied for diffusion steps greater than
<code>sld_warmup_steps</code>.`,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.`,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 is disabled. Momentum is built up during warmup for diffusion steps smaller than
<code>sld_warmup_steps</code>.`,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 is kept. Momentum is built up during warmup for diffusion steps smaller than
<code>sld_warmup_steps</code>.`,name:"sld_mom_beta"}],source:"https://github.com/huggingface/diffusers/blob/v0.30.0/src/diffusers/pipelines/stable_diffusion_safe/pipeline_stable_diffusion_safe.py#L507",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/v0.30.0/en/api/pipelines/stable_diffusion/image_variation#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> is returned,
otherwise a <code>tuple</code> is returned where the first element is a list with the generated images and the
second element is a list of <code>bool</code>s indicating whether the corresponding generated image contains
“not-safe-for-work” (nsfw) content.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/diffusers/v0.30.0/en/api/pipelines/stable_diffusion/image_variation#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),k=new et({props:{anchor:"diffusers.StableDiffusionPipelineSafe.__call__.example",$$slots:{default:[at]},$$scope:{ctx:z}}}),O=new we({props:{title:"StableDiffusionSafePipelineOutput",local:"diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput",headingTag:"h2"}}),H=new ve({props:{name:"class diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput",anchor:"diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput",parameters:[{name:"images",val:": Union"},{name:"nsfw_content_detected",val:": Optional"},{name:"unsafe_images",val:": Union"},{name:"applied_safety_concept",val:": Optional"}],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.30.0/src/diffusers/pipelines/stable_diffusion_safe/pipeline_output.py#L12"}}),E=new ve({props:{name:"__call__",anchor:"diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput.__call__",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}]}}),X=new tt({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/stable_diffusion/stable_diffusion_safe.md"}}),{c(){o=l("meta"),$=i(),c=l("p"),g=i(),h(w.$$.fragment),d=i(),M=l("p"),M.innerHTML=Le,ie=i(),U=l("p"),U.textContent=Je,se=i(),Z=l("p"),Z.innerHTML=Ge,oe=i(),h(C.$$.fragment),le=i(),L=l("p"),L.innerHTML=je,re=i(),h(J.$$.fragment),fe=i(),G=l("p"),G.innerHTML=Ne,de=i(),j=l("p"),j.innerHTML=We,pe=i(),h(N.$$.fragment),ce=i(),h(T.$$.fragment),ue=i(),h(W.$$.fragment),me=i(),p=l("div"),h(V.$$.fragment),Me=i(),A=l("p"),A.innerHTML=Ve,xe=i(),Y=l("p"),Y.innerHTML=Be,$e=i(),q=l("p"),q.textContent=Oe,De=i(),R=l("ul"),R.innerHTML=He,Pe=i(),D=l("div"),h(B.$$.fragment),Te=i(),F=l("p"),F.textContent=Ee,ke=i(),h(k.$$.fragment),ge=i(),h(O.$$.fragment),he=i(),x=l("div"),h(H.$$.fragment),Ie=i(),Q=l("p"),Q.textContent=Xe,Ue=i(),I=l("div"),h(E.$$.fragment),Ze=i(),K=l("p"),K.textContent=ze,_e=i(),h(X.$$.fragment),be=i(),ae=l("p"),this.h()},l(e){const t=Qe("svelte-u9bgzb",document.head);o=r(t,"META",{name:!0,content:!0}),t.forEach(n),$=s(e),c=r(e,"P",{}),te(c).forEach(n),g=s(e),_(w.$$.fragment,e),d=s(e),M=r(e,"P",{"data-svelte-h":!0}),m(M)!=="svelte-pduad"&&(M.innerHTML=Le),ie=s(e),U=r(e,"P",{"data-svelte-h":!0}),m(U)!=="svelte-1cwsb16"&&(U.textContent=Je),se=s(e),Z=r(e,"P",{"data-svelte-h":!0}),m(Z)!=="svelte-esy6y7"&&(Z.innerHTML=Ge),oe=s(e),_(C.$$.fragment,e),le=s(e),L=r(e,"P",{"data-svelte-h":!0}),m(L)!=="svelte-ohtgrc"&&(L.innerHTML=je),re=s(e),_(J.$$.fragment,e),fe=s(e),G=r(e,"P",{"data-svelte-h":!0}),m(G)!=="svelte-nz9egq"&&(G.innerHTML=Ne),de=s(e),j=r(e,"P",{"data-svelte-h":!0}),m(j)!=="svelte-uk0u6e"&&(j.innerHTML=We),pe=s(e),_(N.$$.fragment,e),ce=s(e),_(T.$$.fragment,e),ue=s(e),_(W.$$.fragment,e),me=s(e),p=r(e,"DIV",{class:!0});var u=te(p);_(V.$$.fragment,u),Me=s(u),A=r(u,"P",{"data-svelte-h":!0}),m(A)!=="svelte-excbw8"&&(A.innerHTML=Ve),xe=s(u),Y=r(u,"P",{"data-svelte-h":!0}),m(Y)!=="svelte-1t7z7ym"&&(Y.innerHTML=Be),$e=s(u),q=r(u,"P",{"data-svelte-h":!0}),m(q)!=="svelte-14s6m4u"&&(q.textContent=Oe),De=s(u),R=r(u,"UL",{"data-svelte-h":!0}),m(R)!=="svelte-1nm4s9q"&&(R.innerHTML=He),Pe=s(u),D=r(u,"DIV",{class:!0});var P=te(D);_(B.$$.fragment,P),Te=s(P),F=r(P,"P",{"data-svelte-h":!0}),m(F)!=="svelte-50j04k"&&(F.textContent=Ee),ke=s(P),_(k.$$.fragment,P),P.forEach(n),u.forEach(n),ge=s(e),_(O.$$.fragment,e),he=s(e),x=r(e,"DIV",{class:!0});var ee=te(x);_(H.$$.fragment,ee),Ie=s(ee),Q=r(ee,"P",{"data-svelte-h":!0}),m(Q)!=="svelte-kqc9eg"&&(Q.textContent=Xe),Ue=s(ee),I=r(ee,"DIV",{class:!0});var ye=te(I);_(E.$$.fragment,ye),Ze=s(ye),K=r(ye,"P",{"data-svelte-h":!0}),m(K)!=="svelte-1eed40t"&&(K.textContent=ze),ye.forEach(n),ee.forEach(n),_e=s(e),_(X.$$.fragment,e),be=s(e),ae=r(e,"P",{}),te(ae).forEach(n),this.h()},h(){ne(o,"name","hf:doc:metadata"),ne(o,"content",st),ne(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ne(p,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ne(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ne(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){f(document.head,o),a(e,$,t),a(e,c,t),a(e,g,t),b(w,e,t),a(e,d,t),a(e,M,t),a(e,ie,t),a(e,U,t),a(e,se,t),a(e,Z,t),a(e,oe,t),b(C,e,t),a(e,le,t),a(e,L,t),a(e,re,t),b(J,e,t),a(e,fe,t),a(e,G,t),a(e,de,t),a(e,j,t),a(e,pe,t),b(N,e,t),a(e,ce,t),b(T,e,t),a(e,ue,t),b(W,e,t),a(e,me,t),a(e,p,t),b(V,p,null),f(p,Me),f(p,A),f(p,xe),f(p,Y),f(p,$e),f(p,q),f(p,De),f(p,R),f(p,Pe),f(p,D),b(B,D,null),f(D,Te),f(D,F),f(D,ke),b(k,D,null),a(e,ge,t),b(O,e,t),a(e,he,t),a(e,x,t),b(H,x,null),f(x,Ie),f(x,Q),f(x,Ue),f(x,I),b(E,I,null),f(I,Ze),f(I,K),a(e,_e,t),b(X,e,t),a(e,be,t),a(e,ae,t),Se=!0},p(e,[t]){const u={};t&2&&(u.$$scope={dirty:t,ctx:e}),T.$set(u);const P={};t&2&&(P.$$scope={dirty:t,ctx:e}),k.$set(P)},i(e){Se||(S(w.$$.fragment,e),S(C.$$.fragment,e),S(J.$$.fragment,e),S(N.$$.fragment,e),S(T.$$.fragment,e),S(W.$$.fragment,e),S(V.$$.fragment,e),S(B.$$.fragment,e),S(k.$$.fragment,e),S(O.$$.fragment,e),S(H.$$.fragment,e),S(E.$$.fragment,e),S(X.$$.fragment,e),Se=!0)},o(e){y(w.$$.fragment,e),y(C.$$.fragment,e),y(J.$$.fragment,e),y(N.$$.fragment,e),y(T.$$.fragment,e),y(W.$$.fragment,e),y(V.$$.fragment,e),y(B.$$.fragment,e),y(k.$$.fragment,e),y(O.$$.fragment,e),y(H.$$.fragment,e),y(E.$$.fragment,e),y(X.$$.fragment,e),Se=!1},d(e){e&&(n($),n(c),n(g),n(d),n(M),n(ie),n(U),n(se),n(Z),n(oe),n(le),n(L),n(re),n(fe),n(G),n(de),n(j),n(pe),n(ce),n(ue),n(me),n(p),n(ge),n(he),n(x),n(_e),n(be),n(ae)),n(o),v(w,e),v(C,e),v(J,e),v(N,e),v(T,e),v(W,e),v(V),v(B),v(k),v(O,e),v(H),v(E),v(X,e)}}}const st='{"title":"Safe Stable Diffusion","local":"safe-stable-diffusion","sections":[{"title":"Tips","local":"tips","sections":[],"depth":2},{"title":"StableDiffusionPipelineSafe","local":"diffusers.StableDiffusionPipelineSafe","sections":[],"depth":2},{"title":"StableDiffusionSafePipelineOutput","local":"diffusers.pipelines.stable_diffusion_safe.StableDiffusionSafePipelineOutput","sections":[],"depth":2}],"depth":1}';function ot(z){return qe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class mt extends Re{constructor(o){super(),Fe(this,o,ot,it,Ye,{})}}export{mt as component};
