import{S as Ln,i as Gn,s as On,e as t,k as f,w as W,t as r,M as Nn,c as i,d as n,m as d,a as o,x as V,h as l,b as p,G as s,g as c,y as H,L as zn,q as R,o as K,B as J,v as Un}from"../../../chunks/vendor-hf-doc-builder.js";import{D as Mn}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as Fn}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as dn}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function Bn(un){let m,re,h,y,Q,x,je,X,qe,le,g,v,Y,k,$e,Z,Se,ce,b,Te,I,Ae,Me,pe,O,Le,fe,N,ee,Ge,de,E,ne,Oe,Ne,ue,w,j,ze,z,Ue,Fe,Be,q,We,U,Ve,He,me,$,se,Re,Ke,he,S,Je,F,Qe,ge,T,_e,_,D,te,A,Xe,ie,Ye,ye,u,M,Ze,oe,en,nn,L,sn,B,tn,on,an,C,G,rn,ae,ln,ve;return x=new dn({}),k=new dn({}),T=new Fn({props:{code:`import requests
import torch
from PIL import Image
from io import BytesIO

from diffusers import CycleDiffusionPipeline, DDIMScheduler

# load the pipeline
# make sure you're logged in with \`huggingface-cli login\`
model_id_or_path = "CompVis/stable-diffusion-v1-4"
scheduler = DDIMScheduler.from_pretrained(model_id_or_path, subfolder="scheduler")
pipe = CycleDiffusionPipeline.from_pretrained(model_id_or_path, scheduler=scheduler).to("cuda")

# let's download an initial image
url = "https://raw.githubusercontent.com/ChenWu98/cycle-diffusion/main/data/dalle2/An%20astronaut%20riding%20a%20horse.png"
response = requests.get(url)
init_image = Image.open(BytesIO(response.content)).convert("RGB")
init_image = init_image.resize((512, 512))
init_image.save("horse.png")

# let's specify a prompt
source_prompt = "An astronaut riding a horse"
prompt = "An astronaut riding an elephant"

# call the pipeline
image = pipe(
    prompt=prompt,
    source_prompt=source_prompt,
    image=init_image,
    num_inference_steps=100,
    eta=0.1,
    strength=0.8,
    guidance_scale=2,
    source_guidance_scale=1,
).images[0]

image.save("horse_to_elephant.png")

# let's try another example
# See more samples at the original repo: https://github.com/ChenWu98/cycle-diffusion
url = "https://raw.githubusercontent.com/ChenWu98/cycle-diffusion/main/data/dalle2/A%20black%20colored%20car.png"
response = requests.get(url)
init_image = Image.open(BytesIO(response.content)).convert("RGB")
init_image = init_image.resize((512, 512))
init_image.save("black.png")

source_prompt = "A black colored car"
prompt = "A blue colored car"

# call the pipeline
torch.manual_seed(0)
image = pipe(
    prompt=prompt,
    source_prompt=source_prompt,
    image=init_image,
    num_inference_steps=100,
    eta=0.1,
    strength=0.85,
    guidance_scale=3,
    source_guidance_scale=1,
).images[0]

image.save("black_to_blue.png")`,highlighted:`<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> BytesIO

<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> CycleDiffusionPipeline, DDIMScheduler

<span class="hljs-comment"># load the pipeline</span>
<span class="hljs-comment"># make sure you&#x27;re logged in with \`huggingface-cli login\`</span>
model_id_or_path = <span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
scheduler = DDIMScheduler.from_pretrained(model_id_or_path, subfolder=<span class="hljs-string">&quot;scheduler&quot;</span>)
pipe = CycleDiffusionPipeline.from_pretrained(model_id_or_path, scheduler=scheduler).to(<span class="hljs-string">&quot;cuda&quot;</span>)

<span class="hljs-comment"># let&#x27;s download an initial image</span>
url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/ChenWu98/cycle-diffusion/main/data/dalle2/An%20astronaut%20riding%20a%20horse.png&quot;</span>
response = requests.get(url)
init_image = Image.<span class="hljs-built_in">open</span>(BytesIO(response.content)).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
init_image = init_image.resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))
init_image.save(<span class="hljs-string">&quot;horse.png&quot;</span>)

<span class="hljs-comment"># let&#x27;s specify a prompt</span>
source_prompt = <span class="hljs-string">&quot;An astronaut riding a horse&quot;</span>
prompt = <span class="hljs-string">&quot;An astronaut riding an elephant&quot;</span>

<span class="hljs-comment"># call the pipeline</span>
image = pipe(
    prompt=prompt,
    source_prompt=source_prompt,
    image=init_image,
    num_inference_steps=<span class="hljs-number">100</span>,
    eta=<span class="hljs-number">0.1</span>,
    strength=<span class="hljs-number">0.8</span>,
    guidance_scale=<span class="hljs-number">2</span>,
    source_guidance_scale=<span class="hljs-number">1</span>,
).images[<span class="hljs-number">0</span>]

image.save(<span class="hljs-string">&quot;horse_to_elephant.png&quot;</span>)

<span class="hljs-comment"># let&#x27;s try another example</span>
<span class="hljs-comment"># See more samples at the original repo: https://github.com/ChenWu98/cycle-diffusion</span>
url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/ChenWu98/cycle-diffusion/main/data/dalle2/A%20black%20colored%20car.png&quot;</span>
response = requests.get(url)
init_image = Image.<span class="hljs-built_in">open</span>(BytesIO(response.content)).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
init_image = init_image.resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))
init_image.save(<span class="hljs-string">&quot;black.png&quot;</span>)

source_prompt = <span class="hljs-string">&quot;A black colored car&quot;</span>
prompt = <span class="hljs-string">&quot;A blue colored car&quot;</span>

<span class="hljs-comment"># call the pipeline</span>
torch.manual_seed(<span class="hljs-number">0</span>)
image = pipe(
    prompt=prompt,
    source_prompt=source_prompt,
    image=init_image,
    num_inference_steps=<span class="hljs-number">100</span>,
    eta=<span class="hljs-number">0.1</span>,
    strength=<span class="hljs-number">0.85</span>,
    guidance_scale=<span class="hljs-number">3</span>,
    source_guidance_scale=<span class="hljs-number">1</span>,
).images[<span class="hljs-number">0</span>]

image.save(<span class="hljs-string">&quot;black_to_blue.png&quot;</span>)`}}),A=new dn({}),M=new Mn({props:{name:"class diffusers.CycleDiffusionPipeline",anchor:"diffusers.CycleDiffusionPipeline",parameters:[{name:"vae",val:": AutoencoderKL"},{name:"text_encoder",val:": CLIPTextModel"},{name:"tokenizer",val:": CLIPTokenizer"},{name:"unet",val:": UNet2DConditionModel"},{name:"scheduler",val:": DDIMScheduler"},{name:"safety_checker",val:": StableDiffusionSafetyChecker"},{name:"feature_extractor",val:": CLIPFeatureExtractor"},{name:"requires_safety_checker",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.CycleDiffusionPipeline.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.CycleDiffusionPipeline.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.CycleDiffusionPipeline.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.CycleDiffusionPipeline.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.CycleDiffusionPipeline.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.CycleDiffusionPipeline.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/CompVis/stable-diffusion-v1-4" rel="nofollow">model card</a> for details.`,name:"safety_checker"},{anchor:"diffusers.CycleDiffusionPipeline.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/pipeline_cycle_diffusion.py#L121"}}),G=new Mn({props:{name:"__call__",anchor:"diffusers.CycleDiffusionPipeline.__call__",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]]"},{name:"source_prompt",val:": typing.Union[str, typing.List[str]]"},{name:"image",val:": typing.Union[torch.FloatTensor, PIL.Image.Image] = None"},{name:"strength",val:": float = 0.8"},{name:"num_inference_steps",val:": typing.Optional[int] = 50"},{name:"guidance_scale",val:": typing.Optional[float] = 7.5"},{name:"source_guidance_scale",val:": typing.Optional[float] = 1"},{name:"num_images_per_prompt",val:": typing.Optional[int] = 1"},{name:"eta",val:": typing.Optional[float] = 0.1"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = 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:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.CycleDiffusionPipeline.__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.CycleDiffusionPipeline.__call__.image",description:`<strong>image</strong> (<code>torch.FloatTensor</code> or <code>PIL.Image.Image</code>) &#x2014;
<code>Image</code>, or tensor representing an image batch, that will be used as the starting point for the
process.`,name:"image"},{anchor:"diffusers.CycleDiffusionPipeline.__call__.strength",description:`<strong>strength</strong> (<code>float</code>, <em>optional</em>, defaults to 0.8) &#x2014;
Conceptually, indicates how much to transform the reference <code>image</code>. Must be between 0 and 1. <code>image</code>
will be used as a starting point, adding more noise to it the larger the <code>strength</code>. The number of
denoising steps depends on the amount of noise initially added. When <code>strength</code> is 1, added noise will
be maximum and the denoising process will run for the full number of iterations specified in
<code>num_inference_steps</code>. A value of 1, therefore, essentially ignores <code>image</code>.`,name:"strength"},{anchor:"diffusers.CycleDiffusionPipeline.__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. This parameter will be modulated by <code>strength</code>.`,name:"num_inference_steps"},{anchor:"diffusers.CycleDiffusionPipeline.__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.CycleDiffusionPipeline.__call__.source_guidance_scale",description:`<strong>source_guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 1) &#x2014;
Guidance scale for the source prompt. This is useful to control the amount of influence the source
prompt for encoding.`,name:"source_guidance_scale"},{anchor:"diffusers.CycleDiffusionPipeline.__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.CycleDiffusionPipeline.__call__.eta",description:`<strong>eta</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#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.CycleDiffusionPipeline.__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.CycleDiffusionPipeline.__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.CycleDiffusionPipeline.__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.CycleDiffusionPipeline.__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.CycleDiffusionPipeline.__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"}],source:"https://github.com/huggingface/diffusers/blob/v0.11.0/src/diffusers/pipelines/stable_diffusion/pipeline_cycle_diffusion.py#L493",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>
`}}),{c(){m=t("meta"),re=f(),h=t("h1"),y=t("a"),Q=t("span"),W(x.$$.fragment),je=f(),X=t("span"),qe=r("Cycle Diffusion"),le=f(),g=t("h2"),v=t("a"),Y=t("span"),W(k.$$.fragment),$e=f(),Z=t("span"),Se=r("Overview"),ce=f(),b=t("p"),Te=r("Cycle Diffusion is a Text-Guided Image-to-Image Generation model proposed in "),I=t("a"),Ae=r("Unifying Diffusion Models\u2019 Latent Space, with Applications to CycleDiffusion and Guidance"),Me=r(" by Chen Henry Wu, Fernando De la Torre."),pe=f(),O=t("p"),Le=r("The abstract of the paper is the following:"),fe=f(),N=t("p"),ee=t("em"),Ge=r("Diffusion models have achieved unprecedented performance in generative modeling. The commonly-adopted formulation of the latent code of diffusion models is a sequence of gradually denoised samples, as opposed to the simpler (e.g., Gaussian) latent space of GANs, VAEs, and normalizing flows. This paper provides an alternative, Gaussian formulation of the latent space of various diffusion models, as well as an invertible DPM-Encoder that maps images into the latent space. While our formulation is purely based on the definition of diffusion models, we demonstrate several intriguing consequences. (1) Empirically, we observe that a common latent space emerges from two diffusion models trained independently on related domains. In light of this finding, we propose CycleDiffusion, which uses DPM-Encoder for unpaired image-to-image translation. Furthermore, applying CycleDiffusion to text-to-image diffusion models, we show that large-scale text-to-image diffusion models can be used as zero-shot image-to-image editors. (2) One can guide pre-trained diffusion models and GANs by controlling the latent codes in a unified, plug-and-play formulation based on energy-based models. Using the CLIP model and a face recognition model as guidance, we demonstrate that diffusion models have better coverage of low-density sub-populations and individuals than GANs."),de=f(),E=t("p"),ne=t("em"),Oe=r("Tips"),Ne=r(":"),ue=f(),w=t("ul"),j=t("li"),ze=r("The Cycle Diffusion pipeline is fully compatible with any "),z=t("a"),Ue=r("Stable Diffusion"),Fe=r(" checkpoints"),Be=f(),q=t("li"),We=r("Currently Cycle Diffusion only works with the "),U=t("a"),Ve=r("DDIMScheduler"),He=r("."),me=f(),$=t("p"),se=t("em"),Re=r("Example"),Ke=r(":"),he=f(),S=t("p"),Je=r("In the following we should how to best use the "),F=t("a"),Qe=r("CycleDiffusionPipeline"),ge=f(),W(T.$$.fragment),_e=f(),_=t("h2"),D=t("a"),te=t("span"),W(A.$$.fragment),Xe=f(),ie=t("span"),Ye=r("CycleDiffusionPipeline"),ye=f(),u=t("div"),W(M.$$.fragment),Ze=f(),oe=t("p"),en=r("Pipeline for text-guided image to image generation using Stable Diffusion."),nn=f(),L=t("p"),sn=r("This model inherits from "),B=t("a"),tn=r("DiffusionPipeline"),on=r(`. 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.)`),an=f(),C=t("div"),W(G.$$.fragment),rn=f(),ae=t("p"),ln=r("Function invoked when calling the pipeline for generation."),this.h()},l(e){const a=Nn('[data-svelte="svelte-1phssyn"]',document.head);m=i(a,"META",{name:!0,content:!0}),a.forEach(n),re=d(e),h=i(e,"H1",{class:!0});var be=o(h);y=i(be,"A",{id:!0,class:!0,href:!0});var mn=o(y);Q=i(mn,"SPAN",{});var hn=o(Q);V(x.$$.fragment,hn),hn.forEach(n),mn.forEach(n),je=d(be),X=i(be,"SPAN",{});var gn=o(X);qe=l(gn,"Cycle Diffusion"),gn.forEach(n),be.forEach(n),le=d(e),g=i(e,"H2",{class:!0});var we=o(g);v=i(we,"A",{id:!0,class:!0,href:!0});var _n=o(v);Y=i(_n,"SPAN",{});var yn=o(Y);V(k.$$.fragment,yn),yn.forEach(n),_n.forEach(n),$e=d(we),Z=i(we,"SPAN",{});var vn=o(Z);Se=l(vn,"Overview"),vn.forEach(n),we.forEach(n),ce=d(e),b=i(e,"P",{});var De=o(b);Te=l(De,"Cycle Diffusion is a Text-Guided Image-to-Image Generation model proposed in "),I=i(De,"A",{href:!0,rel:!0});var bn=o(I);Ae=l(bn,"Unifying Diffusion Models\u2019 Latent Space, with Applications to CycleDiffusion and Guidance"),bn.forEach(n),Me=l(De," by Chen Henry Wu, Fernando De la Torre."),De.forEach(n),pe=d(e),O=i(e,"P",{});var wn=o(O);Le=l(wn,"The abstract of the paper is the following:"),wn.forEach(n),fe=d(e),N=i(e,"P",{});var Dn=o(N);ee=i(Dn,"EM",{});var Cn=o(ee);Ge=l(Cn,"Diffusion models have achieved unprecedented performance in generative modeling. The commonly-adopted formulation of the latent code of diffusion models is a sequence of gradually denoised samples, as opposed to the simpler (e.g., Gaussian) latent space of GANs, VAEs, and normalizing flows. This paper provides an alternative, Gaussian formulation of the latent space of various diffusion models, as well as an invertible DPM-Encoder that maps images into the latent space. While our formulation is purely based on the definition of diffusion models, we demonstrate several intriguing consequences. (1) Empirically, we observe that a common latent space emerges from two diffusion models trained independently on related domains. In light of this finding, we propose CycleDiffusion, which uses DPM-Encoder for unpaired image-to-image translation. Furthermore, applying CycleDiffusion to text-to-image diffusion models, we show that large-scale text-to-image diffusion models can be used as zero-shot image-to-image editors. (2) One can guide pre-trained diffusion models and GANs by controlling the latent codes in a unified, plug-and-play formulation based on energy-based models. Using the CLIP model and a face recognition model as guidance, we demonstrate that diffusion models have better coverage of low-density sub-populations and individuals than GANs."),Cn.forEach(n),Dn.forEach(n),de=d(e),E=i(e,"P",{});var cn=o(E);ne=i(cn,"EM",{});var Pn=o(ne);Oe=l(Pn,"Tips"),Pn.forEach(n),Ne=l(cn,":"),cn.forEach(n),ue=d(e),w=i(e,"UL",{});var Ce=o(w);j=i(Ce,"LI",{});var Pe=o(j);ze=l(Pe,"The Cycle Diffusion pipeline is fully compatible with any "),z=i(Pe,"A",{href:!0});var xn=o(z);Ue=l(xn,"Stable Diffusion"),xn.forEach(n),Fe=l(Pe," checkpoints"),Pe.forEach(n),Be=d(Ce),q=i(Ce,"LI",{});var xe=o(q);We=l(xe,"Currently Cycle Diffusion only works with the "),U=i(xe,"A",{href:!0});var kn=o(U);Ve=l(kn,"DDIMScheduler"),kn.forEach(n),He=l(xe,"."),xe.forEach(n),Ce.forEach(n),me=d(e),$=i(e,"P",{});var pn=o($);se=i(pn,"EM",{});var In=o(se);Re=l(In,"Example"),In.forEach(n),Ke=l(pn,":"),pn.forEach(n),he=d(e),S=i(e,"P",{});var fn=o(S);Je=l(fn,"In the following we should how to best use the "),F=i(fn,"A",{href:!0});var En=o(F);Qe=l(En,"CycleDiffusionPipeline"),En.forEach(n),fn.forEach(n),ge=d(e),V(T.$$.fragment,e),_e=d(e),_=i(e,"H2",{class:!0});var ke=o(_);D=i(ke,"A",{id:!0,class:!0,href:!0});var jn=o(D);te=i(jn,"SPAN",{});var qn=o(te);V(A.$$.fragment,qn),qn.forEach(n),jn.forEach(n),Xe=d(ke),ie=i(ke,"SPAN",{});var $n=o(ie);Ye=l($n,"CycleDiffusionPipeline"),$n.forEach(n),ke.forEach(n),ye=d(e),u=i(e,"DIV",{class:!0});var P=o(u);V(M.$$.fragment,P),Ze=d(P),oe=i(P,"P",{});var Sn=o(oe);en=l(Sn,"Pipeline for text-guided image to image generation using Stable Diffusion."),Sn.forEach(n),nn=d(P),L=i(P,"P",{});var Ie=o(L);sn=l(Ie,"This model inherits from "),B=i(Ie,"A",{href:!0});var Tn=o(B);tn=l(Tn,"DiffusionPipeline"),Tn.forEach(n),on=l(Ie,`. 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.)`),Ie.forEach(n),an=d(P),C=i(P,"DIV",{class:!0});var Ee=o(C);V(G.$$.fragment,Ee),rn=d(Ee),ae=i(Ee,"P",{});var An=o(ae);ln=l(An,"Function invoked when calling the pipeline for generation."),An.forEach(n),Ee.forEach(n),P.forEach(n),this.h()},h(){p(m,"name","hf:doc:metadata"),p(m,"content",JSON.stringify(Wn)),p(y,"id","cycle-diffusion"),p(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"),p(y,"href","#cycle-diffusion"),p(h,"class","relative group"),p(v,"id","overview"),p(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"),p(v,"href","#overview"),p(g,"class","relative group"),p(I,"href","https://arxiv.org/abs/2210.05559"),p(I,"rel","nofollow"),p(z,"href","./stable_diffusion"),p(U,"href","/docs/diffusers/v0.11.0/en/api/schedulers/ddim#diffusers.DDIMScheduler"),p(F,"href","/docs/diffusers/v0.11.0/en/api/pipelines/cycle_diffusion#diffusers.CycleDiffusionPipeline"),p(D,"id","diffusers.CycleDiffusionPipeline"),p(D,"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"),p(D,"href","#diffusers.CycleDiffusionPipeline"),p(_,"class","relative group"),p(B,"href","/docs/diffusers/v0.11.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),p(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(u,"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,a){s(document.head,m),c(e,re,a),c(e,h,a),s(h,y),s(y,Q),H(x,Q,null),s(h,je),s(h,X),s(X,qe),c(e,le,a),c(e,g,a),s(g,v),s(v,Y),H(k,Y,null),s(g,$e),s(g,Z),s(Z,Se),c(e,ce,a),c(e,b,a),s(b,Te),s(b,I),s(I,Ae),s(b,Me),c(e,pe,a),c(e,O,a),s(O,Le),c(e,fe,a),c(e,N,a),s(N,ee),s(ee,Ge),c(e,de,a),c(e,E,a),s(E,ne),s(ne,Oe),s(E,Ne),c(e,ue,a),c(e,w,a),s(w,j),s(j,ze),s(j,z),s(z,Ue),s(j,Fe),s(w,Be),s(w,q),s(q,We),s(q,U),s(U,Ve),s(q,He),c(e,me,a),c(e,$,a),s($,se),s(se,Re),s($,Ke),c(e,he,a),c(e,S,a),s(S,Je),s(S,F),s(F,Qe),c(e,ge,a),H(T,e,a),c(e,_e,a),c(e,_,a),s(_,D),s(D,te),H(A,te,null),s(_,Xe),s(_,ie),s(ie,Ye),c(e,ye,a),c(e,u,a),H(M,u,null),s(u,Ze),s(u,oe),s(oe,en),s(u,nn),s(u,L),s(L,sn),s(L,B),s(B,tn),s(L,on),s(u,an),s(u,C),H(G,C,null),s(C,rn),s(C,ae),s(ae,ln),ve=!0},p:zn,i(e){ve||(R(x.$$.fragment,e),R(k.$$.fragment,e),R(T.$$.fragment,e),R(A.$$.fragment,e),R(M.$$.fragment,e),R(G.$$.fragment,e),ve=!0)},o(e){K(x.$$.fragment,e),K(k.$$.fragment,e),K(T.$$.fragment,e),K(A.$$.fragment,e),K(M.$$.fragment,e),K(G.$$.fragment,e),ve=!1},d(e){n(m),e&&n(re),e&&n(h),J(x),e&&n(le),e&&n(g),J(k),e&&n(ce),e&&n(b),e&&n(pe),e&&n(O),e&&n(fe),e&&n(N),e&&n(de),e&&n(E),e&&n(ue),e&&n(w),e&&n(me),e&&n($),e&&n(he),e&&n(S),e&&n(ge),J(T,e),e&&n(_e),e&&n(_),J(A),e&&n(ye),e&&n(u),J(M),J(G)}}}const Wn={local:"cycle-diffusion",sections:[{local:"overview",title:"Overview"},{local:"diffusers.CycleDiffusionPipeline",title:"CycleDiffusionPipeline"}],title:"Cycle Diffusion"};function Vn(un){return Un(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Qn extends Ln{constructor(m){super();Gn(this,m,Vn,Bn,On,{})}}export{Qn as default,Wn as metadata};
