import{s as ni,o as pi,n as xt}from"../chunks/scheduler.8c3d61f6.js";import{S as oi,i as ri,g as n,s as a,r as M,A as Mi,h as p,f as l,c as i,j as ii,u as m,x as o,k as Wt,y as mi,a as s,v as c,d,t as u,w as h}from"../chunks/index.da70eac4.js";import{T as Gt}from"../chunks/Tip.1d9b8c37.js";import{C as J}from"../chunks/CodeBlock.a9c4becf.js";import{H as Bt,E as ci}from"../chunks/getInferenceSnippets.33773fa8.js";function di(b){let r,T=`This document has now grown outdated given the emergence of existing evaluation frameworks for diffusion models for image generation. Please check
out works like <a href="https://crfm.stanford.edu/helm/heim/latest/" rel="nofollow">HEIM</a>, <a href="https://huggingface.co/papers/2307.06350" rel="nofollow">T2I-Compbench</a>,
<a href="https://huggingface.co/papers/2310.11513" rel="nofollow">GenEval</a>.`;return{c(){r=n("p"),r.innerHTML=T},l(f){r=p(f,"P",{"data-svelte-h":!0}),o(r)!=="svelte-divoyp"&&(r.innerHTML=T)},m(f,w){s(f,r,w)},p:xt,d(f){f&&l(r)}}}function ui(b){let r,T=`It is useful to look at some inference samples while a model is training to measure the
training progress. In our <a href="https://github.com/huggingface/diffusers/tree/main/examples/" rel="nofollow">training scripts</a>, we support this utility with additional support for
logging to TensorBoard and Weights &amp; Biases.`;return{c(){r=n("p"),r.innerHTML=T},l(f){r=p(f,"P",{"data-svelte-h":!0}),o(r)!=="svelte-1yulmeg"&&(r.innerHTML=T)},m(f,w){s(f,r,w)},p:xt,d(f){f&&l(r)}}}function hi(b){let r,T=`By construction, there are some limitations in this score. The captions in the training dataset
were crawled from the web and extracted from <code>alt</code> and similar tags associated an image on the internet.
They are not necessarily representative of what a human being would use to describe an image. Hence we
had to “engineer” some prompts here.`;return{c(){r=n("p"),r.innerHTML=T},l(f){r=p(f,"P",{"data-svelte-h":!0}),o(r)!=="svelte-17jek1b"&&(r.innerHTML=T)},m(f,w){s(f,r,w)},p:xt,d(f){f&&l(r)}}}function fi(b){let r,T="Both CLIP score and CLIP direction similarity rely on the CLIP model, which can make the evaluations biased.";return{c(){r=n("p"),r.textContent=T},l(f){r=p(f,"P",{"data-svelte-h":!0}),o(r)!=="svelte-1jj27lk"&&(r.textContent=T)},m(f,w){s(f,r,w)},p:xt,d(f){f&&l(r)}}}function yi(b){let r,T="FID results tend to be fragile as they depend on a lot of factors:",f,w,g="<li>The specific Inception model used during computation.</li> <li>The implementation accuracy of the computation.</li> <li>The image format (not the same if we start from PNGs vs JPGs).</li>",C,j,vt=`Keeping that in mind, FID is often most useful when comparing similar runs, but it is
hard to reproduce paper results unless the authors carefully disclose the FID
measurement code.`,Z,U,k="These points apply to other related metrics too, such as KID and IS.";return{c(){r=n("p"),r.textContent=T,f=a(),w=n("ul"),w.innerHTML=g,C=a(),j=n("p"),j.textContent=vt,Z=a(),U=n("p"),U.textContent=k},l(y){r=p(y,"P",{"data-svelte-h":!0}),o(r)!=="svelte-nu8das"&&(r.textContent=T),f=i(y),w=p(y,"UL",{"data-svelte-h":!0}),o(w)!=="svelte-1u7ggn4"&&(w.innerHTML=g),C=i(y),j=p(y,"P",{"data-svelte-h":!0}),o(j)!=="svelte-tbdsq8"&&(j.textContent=vt),Z=i(y),U=p(y,"P",{"data-svelte-h":!0}),o(U)!=="svelte-11vfq1v"&&(U.textContent=k)},m(y,I){s(y,r,I),s(y,f,I),s(y,w,I),s(y,C,I),s(y,j,I),s(y,Z,I),s(y,U,I)},p:xt,d(y){y&&(l(r),l(f),l(w),l(C),l(j),l(Z),l(U))}}}function Ji(b){let r,T,f,w,g,C,j,vt='<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>',Z,U,k,y,I='Evaluation of generative models like <a href="https://huggingface.co/docs/diffusers/stable_diffusion" rel="nofollow">Stable Diffusion</a> is subjective in nature. But as practitioners and researchers, we often have to make careful choices amongst many different possibilities. So, when working with different generative models (like GANs, Diffusion, etc.), how do we choose one over the other?',kt,X,Xs=`Qualitative evaluation of such models can be error-prone and might incorrectly influence a decision.
However, quantitative metrics don’t necessarily correspond to image quality. So, usually, a combination
of both qualitative and quantitative evaluations provides a stronger signal when choosing one model
over the other.`,Xt,V,Vs="In this document, we provide a non-exhaustive overview of qualitative and quantitative methods to evaluate Diffusion models. For quantitative methods, we specifically focus on how to implement them alongside <code>diffusers</code>.",Vt,R,Rs='The methods shown in this document can also be used to evaluate different <a href="https://huggingface.co/docs/diffusers/main/en/api/schedulers/overview" rel="nofollow">noise schedulers</a> keeping the underlying generation model fixed.',Rt,H,Ht,F,Hs="We cover Diffusion models with the following pipelines:",Ft,$,Fs='<li>Text-guided image generation (such as the <a href="https://huggingface.co/docs/diffusers/main/en/api/pipelines/stable_diffusion/text2img" rel="nofollow"><code>StableDiffusionPipeline</code></a>).</li> <li>Text-guided image generation, additionally conditioned on an input image (such as the <a href="https://huggingface.co/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img" rel="nofollow"><code>StableDiffusionImg2ImgPipeline</code></a> and <a href="https://huggingface.co/docs/diffusers/main/en/api/pipelines/pix2pix" rel="nofollow"><code>StableDiffusionInstructPix2PixPipeline</code></a>).</li> <li>Class-conditioned image generation models (such as the <a href="https://huggingface.co/docs/diffusers/main/en/api/pipelines/dit" rel="nofollow"><code>DiTPipeline</code></a>).</li>',$t,N,Nt,E,$s=`Qualitative evaluation typically involves human assessment of generated images. Quality is measured across aspects such as compositionality, image-text alignment, and spatial relations. Common prompts provide a degree of uniformity for subjective metrics.
DrawBench and PartiPrompts are prompt datasets used for qualitative benchmarking. DrawBench and PartiPrompts were introduced by <a href="https://imagen.research.google/" rel="nofollow">Imagen</a> and <a href="https://parti.research.google/" rel="nofollow">Parti</a> respectively.`,Et,Y,Ns='From the <a href="https://parti.research.google/" rel="nofollow">official Parti website</a>:',Yt,Q,Es="<p>PartiPrompts (P2) is a rich set of over 1600 prompts in English that we release as part of this work. P2 can be used to measure model capabilities across various categories and challenge aspects.</p>",Qt,A,Ys='<img src="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/evaluation_diffusion_models/parti-prompts.png" alt="parti-prompts"/>',At,z,Qs="PartiPrompts has the following columns:",zt,S,As="<li>Prompt</li> <li>Category of the prompt (such as “Abstract”, “World Knowledge”, etc.)</li> <li>Challenge reflecting the difficulty (such as “Basic”, “Complex”, “Writing &amp; Symbols”, etc.)</li>",St,L,zs="These benchmarks allow for side-by-side human evaluation of different image generation models.",Lt,P,Ss="For this, the 🧨 Diffusers team has built <strong>Open Parti Prompts</strong>, which is a community-driven qualitative benchmark based on Parti Prompts to compare state-of-the-art open-source diffusion models:",Pt,q,Ls='<li><a href="https://huggingface.co/spaces/OpenGenAI/open-parti-prompts" rel="nofollow">Open Parti Prompts Game</a>: For 10 parti prompts, 4 generated images are shown and the user selects the image that suits the prompt best.</li> <li><a href="https://huggingface.co/spaces/OpenGenAI/parti-prompts-leaderboard" rel="nofollow">Open Parti Prompts Leaderboard</a>: The leaderboard comparing the currently best open-sourced diffusion models to each other.</li>',qt,D,Ps="To manually compare images, let’s see how we can use <code>diffusers</code> on a couple of PartiPrompts.",Dt,K,qs='Below we show some prompts sampled across different challenges: Basic, Complex, Linguistic Structures, Imagination, and Writing &amp; Symbols. Here we are using PartiPrompts as a <a href="https://huggingface.co/datasets/nateraw/parti-prompts" rel="nofollow">dataset</a>.',Kt,O,Ot,ee,Ds='Now we can use these prompts to generate some images using Stable Diffusion (<a href="https://huggingface.co/CompVis/stable-diffusion-v1-4" rel="nofollow">v1-4 checkpoint</a>):',el,te,tl,le,Ks='<img src="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/evaluation_diffusion_models/parti-prompts-14.png" alt="parti-prompts-14"/>',ll,se,Os='We can also set <code>num_images_per_prompt</code> accordingly to compare different images for the same prompt. Running the same pipeline but with a different checkpoint (<a href="https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5" rel="nofollow">v1-5</a>), yields:',sl,ae,ea='<img src="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/evaluation_diffusion_models/parti-prompts-15.png" alt="parti-prompts-15"/>',al,ie,ta=`Once several images are generated from all the prompts using multiple models (under evaluation), these results are presented to human evaluators for scoring. For
more details on the DrawBench and PartiPrompts benchmarks, refer to their respective papers.`,il,B,nl,ne,pl,pe,la="In this section, we will walk you through how to evaluate three different diffusion pipelines using:",ol,oe,sa="<li>CLIP score</li> <li>CLIP directional similarity</li> <li>FID</li>",rl,re,Ml,Me,aa='<a href="https://huggingface.co/papers/2104.08718" rel="nofollow">CLIP score</a> measures the compatibility of image-caption pairs. Higher CLIP scores imply higher compatibility 🔼. The CLIP score is a quantitative measurement of the qualitative concept “compatibility”. Image-caption pair compatibility can also be thought of as the semantic similarity between the image and the caption. CLIP score was found to have high correlation with human judgement.',ml,me,ia='Let’s first load a <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline">StableDiffusionPipeline</a>:',cl,ce,dl,de,na="Generate some images with multiple prompts:",ul,ue,hl,he,pa="And then, we calculate the CLIP score.",fl,fe,yl,ye,oa="In the above example, we generated one image per prompt. If we generated multiple images per prompt, we would have to take the average score from the generated images per prompt.",Jl,Je,ra=`Now, if we wanted to compare two checkpoints compatible with the <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline">StableDiffusionPipeline</a> we should pass a generator while calling the pipeline. First, we generate images with a
fixed seed with the <a href="https://huggingface.co/CompVis/stable-diffusion-v1-4" rel="nofollow">v1-4 Stable Diffusion checkpoint</a>:`,wl,we,Tl,Te,Ma='Then we load the <a href="https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5" rel="nofollow">v1-5 checkpoint</a> to generate images:',jl,je,Ul,Ue,ma="And finally, we compare their CLIP scores:",bl,be,gl,ge,ca='It seems like the <a href="https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5" rel="nofollow">v1-5</a> checkpoint performs better than its predecessor. Note, however, that the number of prompts we used to compute the CLIP scores is quite low. For a more practical evaluation, this number should be way higher, and the prompts should be diverse.',Il,W,Cl,Ie,Zl,Ce,da='In this case, we condition the generation pipeline with an input image as well as a text prompt. Let’s take the <a href="/docs/diffusers/main/en/api/pipelines/pix2pix#diffusers.StableDiffusionInstructPix2PixPipeline">StableDiffusionInstructPix2PixPipeline</a>, as an example. It takes an edit instruction as an input prompt and an input image to be edited.',Bl,Ze,ua="Here is one example:",Wl,Be,ha='<img src="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/evaluation_diffusion_models/edit-instruction.png" alt="edit-instruction"/>',vl,We,fa='One strategy to evaluate such a model is to measure the consistency of the change between the two images (in <a href="https://huggingface.co/docs/transformers/model_doc/clip" rel="nofollow">CLIP</a> space) with the change between the two image captions (as shown in <a href="https://huggingface.co/papers/2108.00946" rel="nofollow">CLIP-Guided Domain Adaptation of Image Generators</a>). This is referred to as the ”<strong>CLIP directional similarity</strong>“.',_l,ve,ya="<li>Caption 1 corresponds to the input image (image 1) that is to be edited.</li> <li>Caption 2 corresponds to the edited image (image 2). It should reflect the edit instruction.</li>",Gl,_e,Ja="Following is a pictorial overview:",xl,Ge,wa='<img src="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/evaluation_diffusion_models/edit-consistency.png" alt="edit-consistency"/>',kl,xe,Ta="We have prepared a mini dataset to implement this metric. Let’s first load the dataset.",Xl,ke,Vl,Xe,Rl,Ve,ja="Here we have:",Hl,Re,Ua="<li><code>input</code> is a caption corresponding to the <code>image</code>.</li> <li><code>edit</code> denotes the edit instruction.</li> <li><code>output</code> denotes the modified caption reflecting the <code>edit</code> instruction.</li>",Fl,He,ba="Let’s take a look at a sample.",$l,Fe,Nl,$e,El,Ne,ga="And here is the image:",Yl,Ee,Ql,Ye,Ia='<img src="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/evaluation_diffusion_models/edit-dataset.png" alt="edit-dataset"/>',Al,Qe,Ca="We will first edit the images of our dataset with the edit instruction and compute the directional similarity.",zl,Ae,Za='Let’s first load the <a href="/docs/diffusers/main/en/api/pipelines/pix2pix#diffusers.StableDiffusionInstructPix2PixPipeline">StableDiffusionInstructPix2PixPipeline</a>:',Sl,ze,Ll,Se,Ba="Now, we perform the edits:",Pl,Le,ql,Pe,Wa="To measure the directional similarity, we first load CLIP’s image and text encoders:",Dl,qe,Kl,De,va='Notice that we are using a particular CLIP checkpoint, i.e., <code>openai/clip-vit-large-patch14</code>. This is because the Stable Diffusion pre-training was performed with this CLIP variant. For more details, refer to the <a href="https://huggingface.co/docs/transformers/model_doc/clip" rel="nofollow">documentation</a>.',Ol,Ke,_a="Next, we prepare a PyTorch <code>nn.Module</code> to compute directional similarity:",es,Oe,ts,et,Ga="Let’s put <code>DirectionalSimilarity</code> to use now.",ls,tt,ss,lt,xa="Like the CLIP Score, the higher the CLIP directional similarity, the better it is.",as,st,ka="It should be noted that the <code>StableDiffusionInstructPix2PixPipeline</code> exposes two arguments, namely, <code>image_guidance_scale</code> and <code>guidance_scale</code> that let you control the quality of the final edited image. We encourage you to experiment with these two arguments and see the impact of that on the directional similarity.",is,at,Xa="We can extend the idea of this metric to measure how similar the original image and edited version are. To do that, we can just do <code>F.cosine_similarity(img_feat_two, img_feat_one)</code>. For these kinds of edits, we would still want the primary semantics of the images to be preserved as much as possible, i.e., a high similarity score.",ns,it,Va='We can use these metrics for similar pipelines such as the <a href="https://huggingface.co/docs/diffusers/main/en/api/pipelines/pix2pix_zero#diffusers.StableDiffusionPix2PixZeroPipeline" rel="nofollow"><code>StableDiffusionPix2PixZeroPipeline</code></a>.',ps,v,os,nt,Ra='<strong><em>Extending metrics like IS, FID (discussed later), or KID can be difficult</em></strong> when the model under evaluation was pre-trained on a large image-captioning dataset (such as the <a href="https://laion.ai/blog/laion-5b/" rel="nofollow">LAION-5B dataset</a>). This is because underlying these metrics is an InceptionNet (pre-trained on the ImageNet-1k dataset) used for extracting intermediate image features. The pre-training dataset of Stable Diffusion may have limited overlap with the pre-training dataset of InceptionNet, so it is not a good candidate here for feature extraction.',rs,pt,Ha='<strong><em>Using the above metrics helps evaluate models that are class-conditioned. For example, <a href="https://huggingface.co/docs/diffusers/main/en/api/pipelines/dit" rel="nofollow">DiT</a>. It was pre-trained being conditioned on the ImageNet-1k classes.</em></strong>',Ms,ot,ms,rt,Fa='Class-conditioned generative models are usually pre-trained on a class-labeled dataset such as <a href="https://huggingface.co/datasets/imagenet-1k" rel="nofollow">ImageNet-1k</a>. Popular metrics for evaluating these models include Fréchet Inception Distance (FID), Kernel Inception Distance (KID), and Inception Score (IS). In this document, we focus on FID (<a href="https://huggingface.co/papers/1706.08500" rel="nofollow">Heusel et al.</a>). We show how to compute it with the <a href="https://huggingface.co/docs/diffusers/api/pipelines/dit" rel="nofollow"><code>DiTPipeline</code></a>, which uses the <a href="https://huggingface.co/papers/2212.09748" rel="nofollow">DiT model</a> under the hood.',cs,Mt,$a='FID aims to measure how similar are two datasets of images. As per <a href="https://mmgeneration.readthedocs.io/en/latest/quick_run.html#fid" rel="nofollow">this resource</a>:',ds,mt,Na="<p>Fréchet Inception Distance is a measure of similarity between two datasets of images. It was shown to correlate well with the human judgment of visual quality and is most often used to evaluate the quality of samples of Generative Adversarial Networks. FID is calculated by computing the Fréchet distance between two Gaussians fitted to feature representations of the Inception network.</p>",us,ct,Ea="These two datasets are essentially the dataset of real images and the dataset of fake images (generated images in our case). FID is usually calculated with two large datasets. However, for this document, we will work with two mini datasets.",hs,dt,Ya="Let’s first download a few images from the ImageNet-1k training set:",fs,ut,ys,ht,Js,ft,Qa="These are 10 images from the following ImageNet-1k classes: “cassette_player”, “chain_saw” (x2), “church”, “gas_pump” (x3), “parachute” (x2), and “tench”.",ws,_,Aa='<img src="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/evaluation_diffusion_models/real-images.png" alt="real-images"/><br/> <em>Real images.</em>',Ts,yt,za="Now that the images are loaded, let’s apply some lightweight pre-processing on them to use them for FID calculation.",js,Jt,Us,wt,Sa='We now load the <a href="https://huggingface.co/docs/diffusers/api/pipelines/dit" rel="nofollow"><code>DiTPipeline</code></a> to generate images conditioned on the above-mentioned classes.',bs,Tt,gs,jt,La='Now, we can compute the FID using <a href="https://torchmetrics.readthedocs.io/" rel="nofollow"><code>torchmetrics</code></a>.',Is,Ut,Cs,bt,Pa="The lower the FID, the better it is. Several things can influence FID here:",Zs,gt,qa="<li>Number of images (both real and fake)</li> <li>Randomness induced in the diffusion process</li> <li>Number of inference steps in the diffusion process</li> <li>The scheduler being used in the diffusion process</li>",Bs,It,Da="For the last two points, it is, therefore, a good practice to run the evaluation across different seeds and inference steps, and then report an average result.",Ws,G,vs,Ct,Ka="As a final step, let’s visually inspect the <code>fake_images</code>.",_s,x,Oa='<img src="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/evaluation_diffusion_models/fake-images.png" alt="fake-images"/><br/> <em>Fake images.</em>',Gs,Zt,xs,_t,ks;return g=new Bt({props:{title:"Evaluating Diffusion Models",local:"evaluating-diffusion-models",headingTag:"h1"}}),U=new Gt({props:{warning:!1,$$slots:{default:[di]},$$scope:{ctx:b}}}),H=new Bt({props:{title:"Scenarios",local:"scenarios",headingTag:"h2"}}),N=new Bt({props:{title:"Qualitative Evaluation",local:"qualitative-evaluation",headingTag:"h2"}}),O=new J({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBJTIzJTIwcHJvbXB0cyUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJuYXRlcmF3JTJGcGFydGktcHJvbXB0cyUyMiUyQyUyMHNwbGl0JTNEJTIydHJhaW4lMjIpJTBBJTIzJTIwcHJvbXB0cyUyMCUzRCUyMHByb21wdHMuc2h1ZmZsZSgpJTBBJTIzJTIwc2FtcGxlX3Byb21wdHMlMjAlM0QlMjAlNUJwcm9tcHRzJTVCaSU1RCU1QiUyMlByb21wdCUyMiU1RCUyMGZvciUyMGklMjBpbiUyMHJhbmdlKDUpJTVEJTBBJTBBJTIzJTIwRml4aW5nJTIwdGhlc2UlMjBzYW1wbGUlMjBwcm9tcHRzJTIwaW4lMjB0aGUlMjBpbnRlcmVzdCUyMG9mJTIwcmVwcm9kdWNpYmlsaXR5LiUwQXNhbXBsZV9wcm9tcHRzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIyYSUyMGNvcmdpJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyYSUyMGhvdCUyMGFpciUyMGJhbGxvb24lMjB3aXRoJTIwYSUyMHlpbi15YW5nJTIwc3ltYm9sJTJDJTIwd2l0aCUyMHRoZSUyMG1vb24lMjB2aXNpYmxlJTIwaW4lMjB0aGUlMjBkYXl0aW1lJTIwc2t5JTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyYSUyMGNhciUyMHdpdGglMjBubyUyMHdpbmRvd3MlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJhJTIwY3ViZSUyMG1hZGUlMjBvZiUyMHBvcmN1cGluZSUyMiUyQyUwQSUyMCUyMCUyMCUyMCdUaGUlMjBzYXlpbmclMjAlMjJCRSUyMEVYQ0VMTEVOVCUyMFRPJTIwRUFDSCUyME9USEVSJTIyJTIwd3JpdHRlbiUyMG9uJTIwYSUyMHJlZCUyMGJyaWNrJTIwd2FsbCUyMHdpdGglMjBhJTIwZ3JhZmZpdGklMjBpbWFnZSUyMG9mJTIwYSUyMGdyZWVuJTIwYWxpZW4lMjB3ZWFyaW5nJTIwYSUyMHR1eGVkby4lMjBBJTIweWVsbG93JTIwZmlyZSUyMGh5ZHJhbnQlMjBpcyUyMG9uJTIwYSUyMHNpZGV3YWxrJTIwaW4lMjB0aGUlMjBmb3JlZ3JvdW5kLiclMkMlMEElNUQ=",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-comment"># prompts = load_dataset(&quot;nateraw/parti-prompts&quot;, split=&quot;train&quot;)</span>
<span class="hljs-comment"># prompts = prompts.shuffle()</span>
<span class="hljs-comment"># sample_prompts = [prompts[i][&quot;Prompt&quot;] for i in range(5)]</span>

<span class="hljs-comment"># Fixing these sample prompts in the interest of reproducibility.</span>
sample_prompts = [
    <span class="hljs-string">&quot;a corgi&quot;</span>,
    <span class="hljs-string">&quot;a hot air balloon with a yin-yang symbol, with the moon visible in the daytime sky&quot;</span>,
    <span class="hljs-string">&quot;a car with no windows&quot;</span>,
    <span class="hljs-string">&quot;a cube made of porcupine&quot;</span>,
    <span class="hljs-string">&#x27;The saying &quot;BE EXCELLENT TO EACH OTHER&quot; written on a red brick wall with a graffiti image of a green alien wearing a tuxedo. A yellow fire hydrant is on a sidewalk in the foreground.&#x27;</span>,
]`,wrap:!1}}),te=new J({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFzZWVkJTIwJTNEJTIwMCUwQWdlbmVyYXRvciUyMCUzRCUyMHRvcmNoLm1hbnVhbF9zZWVkKHNlZWQpJTBBJTBBaW1hZ2VzJTIwJTNEJTIwc2RfcGlwZWxpbmUoc2FtcGxlX3Byb21wdHMlMkMlMjBudW1faW1hZ2VzX3Blcl9wcm9tcHQlM0QxJTJDJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yKS5pbWFnZXM=",highlighted:`<span class="hljs-keyword">import</span> torch

seed = <span class="hljs-number">0</span>
generator = torch.manual_seed(seed)

images = sd_pipeline(sample_prompts, num_images_per_prompt=<span class="hljs-number">1</span>, generator=generator).images`,wrap:!1}}),B=new Gt({props:{$$slots:{default:[ui]},$$scope:{ctx:b}}}),ne=new Bt({props:{title:"Quantitative Evaluation",local:"quantitative-evaluation",headingTag:"h2"}}),re=new Bt({props:{title:"Text-guided image generation",local:"text-guided-image-generation",headingTag:"h3"}}),ce=new J({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMEElMEFtb2RlbF9ja3B0JTIwJTNEJTIwJTIyQ29tcFZpcyUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNCUyMiUwQXNkX3BpcGVsaW5lJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2NrcHQlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpLnRvKCUyMmN1ZGElMjIp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline
<span class="hljs-keyword">import</span> torch

model_ckpt = <span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
sd_pipeline = StableDiffusionPipeline.from_pretrained(model_ckpt, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),ue=new J({props:{code:"cHJvbXB0cyUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMmElMjBwaG90byUyMG9mJTIwYW4lMjBhc3Ryb25hdXQlMjByaWRpbmclMjBhJTIwaG9yc2UlMjBvbiUyMG1hcnMlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJBJTIwaGlnaCUyMHRlY2glMjBzb2xhcnB1bmslMjB1dG9waWElMjBpbiUyMHRoZSUyMEFtYXpvbiUyMHJhaW5mb3Jlc3QlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJBJTIwcGlrYWNodSUyMGZpbmUlMjBkaW5pbmclMjB3aXRoJTIwYSUyMHZpZXclMjB0byUyMHRoZSUyMEVpZmZlbCUyMFRvd2VyJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyQSUyMG1lY2hhJTIwcm9ib3QlMjBpbiUyMGElMjBmYXZlbGElMjBpbiUyMGV4cHJlc3Npb25pc3QlMjBzdHlsZSUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMmFuJTIwaW5zZWN0JTIwcm9ib3QlMjBwcmVwYXJpbmclMjBhJTIwZGVsaWNpb3VzJTIwbWVhbCUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMkElMjBzbWFsbCUyMGNhYmluJTIwb24lMjB0b3AlMjBvZiUyMGElMjBzbm93eSUyMG1vdW50YWluJTIwaW4lMjB0aGUlMjBzdHlsZSUyMG9mJTIwRGlzbmV5JTJDJTIwYXJ0c3RhdGlvbiUyMiUyQyUwQSU1RCUwQSUwQWltYWdlcyUyMCUzRCUyMHNkX3BpcGVsaW5lKHByb21wdHMlMkMlMjBudW1faW1hZ2VzX3Blcl9wcm9tcHQlM0QxJTJDJTIwb3V0cHV0X3R5cGUlM0QlMjJucCUyMikuaW1hZ2VzJTBBJTBBcHJpbnQoaW1hZ2VzLnNoYXBlKSUwQSUyMyUyMCg2JTJDJTIwNTEyJTJDJTIwNTEyJTJDJTIwMyk=",highlighted:`prompts = [
    <span class="hljs-string">&quot;a photo of an astronaut riding a horse on mars&quot;</span>,
    <span class="hljs-string">&quot;A high tech solarpunk utopia in the Amazon rainforest&quot;</span>,
    <span class="hljs-string">&quot;A pikachu fine dining with a view to the Eiffel Tower&quot;</span>,
    <span class="hljs-string">&quot;A mecha robot in a favela in expressionist style&quot;</span>,
    <span class="hljs-string">&quot;an insect robot preparing a delicious meal&quot;</span>,
    <span class="hljs-string">&quot;A small cabin on top of a snowy mountain in the style of Disney, artstation&quot;</span>,
]

images = sd_pipeline(prompts, num_images_per_prompt=<span class="hljs-number">1</span>, output_type=<span class="hljs-string">&quot;np&quot;</span>).images

<span class="hljs-built_in">print</span>(images.shape)
<span class="hljs-comment"># (6, 512, 512, 3)</span>`,wrap:!1}}),fe=new J({props:{code:"ZnJvbSUyMHRvcmNobWV0cmljcy5mdW5jdGlvbmFsLm11bHRpbW9kYWwlMjBpbXBvcnQlMjBjbGlwX3Njb3JlJTBBZnJvbSUyMGZ1bmN0b29scyUyMGltcG9ydCUyMHBhcnRpYWwlMEElMEFjbGlwX3Njb3JlX2ZuJTIwJTNEJTIwcGFydGlhbChjbGlwX3Njb3JlJTJDJTIwbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTIyb3BlbmFpJTJGY2xpcC12aXQtYmFzZS1wYXRjaDE2JTIyKSUwQSUwQWRlZiUyMGNhbGN1bGF0ZV9jbGlwX3Njb3JlKGltYWdlcyUyQyUyMHByb21wdHMpJTNBJTBBJTIwJTIwJTIwJTIwaW1hZ2VzX2ludCUyMCUzRCUyMChpbWFnZXMlMjAqJTIwMjU1KS5hc3R5cGUoJTIydWludDglMjIpJTBBJTIwJTIwJTIwJTIwY2xpcF9zY29yZSUyMCUzRCUyMGNsaXBfc2NvcmVfZm4odG9yY2guZnJvbV9udW1weShpbWFnZXNfaW50KS5wZXJtdXRlKDAlMkMlMjAzJTJDJTIwMSUyQyUyMDIpJTJDJTIwcHJvbXB0cykuZGV0YWNoKCklMEElMjAlMjAlMjAlMjByZXR1cm4lMjByb3VuZChmbG9hdChjbGlwX3Njb3JlKSUyQyUyMDQpJTBBJTBBc2RfY2xpcF9zY29yZSUyMCUzRCUyMGNhbGN1bGF0ZV9jbGlwX3Njb3JlKGltYWdlcyUyQyUyMHByb21wdHMpJTBBcHJpbnQoZiUyMkNMSVAlMjBzY29yZSUzQSUyMCU3QnNkX2NsaXBfc2NvcmUlN0QlMjIpJTBBJTIzJTIwQ0xJUCUyMHNjb3JlJTNBJTIwMzUuNzAzOA==",highlighted:`<span class="hljs-keyword">from</span> torchmetrics.functional.multimodal <span class="hljs-keyword">import</span> clip_score
<span class="hljs-keyword">from</span> functools <span class="hljs-keyword">import</span> partial

clip_score_fn = partial(clip_score, model_name_or_path=<span class="hljs-string">&quot;openai/clip-vit-base-patch16&quot;</span>)

<span class="hljs-keyword">def</span> <span class="hljs-title function_">calculate_clip_score</span>(<span class="hljs-params">images, prompts</span>):
    images_int = (images * <span class="hljs-number">255</span>).astype(<span class="hljs-string">&quot;uint8&quot;</span>)
    clip_score = clip_score_fn(torch.from_numpy(images_int).permute(<span class="hljs-number">0</span>, <span class="hljs-number">3</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>), prompts).detach()
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">round</span>(<span class="hljs-built_in">float</span>(clip_score), <span class="hljs-number">4</span>)

sd_clip_score = calculate_clip_score(images, prompts)
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;CLIP score: <span class="hljs-subst">{sd_clip_score}</span>&quot;</span>)
<span class="hljs-comment"># CLIP score: 35.7038</span>`,wrap:!1}}),we=new J({props:{code:"c2VlZCUyMCUzRCUyMDAlMEFnZW5lcmF0b3IlMjAlM0QlMjB0b3JjaC5tYW51YWxfc2VlZChzZWVkKSUwQSUwQWltYWdlcyUyMCUzRCUyMHNkX3BpcGVsaW5lKHByb21wdHMlMkMlMjBudW1faW1hZ2VzX3Blcl9wcm9tcHQlM0QxJTJDJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yJTJDJTIwb3V0cHV0X3R5cGUlM0QlMjJucCUyMikuaW1hZ2Vz",highlighted:`seed = <span class="hljs-number">0</span>
generator = torch.manual_seed(seed)

images = sd_pipeline(prompts, num_images_per_prompt=<span class="hljs-number">1</span>, generator=generator, output_type=<span class="hljs-string">&quot;np&quot;</span>).images`,wrap:!1}}),je=new J({props:{code:"bW9kZWxfY2twdF8xXzUlMjAlM0QlMjAlMjJzdGFibGUtZGlmZnVzaW9uLXYxLTUlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMEFzZF9waXBlbGluZV8xXzUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQobW9kZWxfY2twdF8xXzUlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpLnRvKCUyMmN1ZGElMjIpJTBBJTBBaW1hZ2VzXzFfNSUyMCUzRCUyMHNkX3BpcGVsaW5lXzFfNShwcm9tcHRzJTJDJTIwbnVtX2ltYWdlc19wZXJfcHJvbXB0JTNEMSUyQyUyMGdlbmVyYXRvciUzRGdlbmVyYXRvciUyQyUyMG91dHB1dF90eXBlJTNEJTIybnAlMjIpLmltYWdlcw==",highlighted:`model_ckpt_1_5 = <span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>
sd_pipeline_1_5 = StableDiffusionPipeline.from_pretrained(model_ckpt_1_5, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)

images_1_5 = sd_pipeline_1_5(prompts, num_images_per_prompt=<span class="hljs-number">1</span>, generator=generator, output_type=<span class="hljs-string">&quot;np&quot;</span>).images`,wrap:!1}}),be=new J({props:{code:"c2RfY2xpcF9zY29yZV8xXzQlMjAlM0QlMjBjYWxjdWxhdGVfY2xpcF9zY29yZShpbWFnZXMlMkMlMjBwcm9tcHRzKSUwQXByaW50KGYlMjJDTElQJTIwU2NvcmUlMjB3aXRoJTIwdi0xLTQlM0ElMjAlN0JzZF9jbGlwX3Njb3JlXzFfNCU3RCUyMiklMEElMjMlMjBDTElQJTIwU2NvcmUlMjB3aXRoJTIwdi0xLTQlM0ElMjAzNC45MTAyJTBBJTBBc2RfY2xpcF9zY29yZV8xXzUlMjAlM0QlMjBjYWxjdWxhdGVfY2xpcF9zY29yZShpbWFnZXNfMV81JTJDJTIwcHJvbXB0cyklMEFwcmludChmJTIyQ0xJUCUyMFNjb3JlJTIwd2l0aCUyMHYtMS01JTNBJTIwJTdCc2RfY2xpcF9zY29yZV8xXzUlN0QlMjIpJTBBJTIzJTIwQ0xJUCUyMFNjb3JlJTIwd2l0aCUyMHYtMS01JTNBJTIwMzYuMjEzNw==",highlighted:`sd_clip_score_1_4 = calculate_clip_score(images, prompts)
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;CLIP Score with v-1-4: <span class="hljs-subst">{sd_clip_score_1_4}</span>&quot;</span>)
<span class="hljs-comment"># CLIP Score with v-1-4: 34.9102</span>

sd_clip_score_1_5 = calculate_clip_score(images_1_5, prompts)
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;CLIP Score with v-1-5: <span class="hljs-subst">{sd_clip_score_1_5}</span>&quot;</span>)
<span class="hljs-comment"># CLIP Score with v-1-5: 36.2137</span>`,wrap:!1}}),W=new Gt({props:{warning:!0,$$slots:{default:[hi]},$$scope:{ctx:b}}}),Ie=new Bt({props:{title:"Image-conditioned text-to-image generation",local:"image-conditioned-text-to-image-generation",headingTag:"h3"}}),ke=new J({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJzYXlha3BhdWwlMkZpbnN0cnVjdHBpeDJwaXgtZGVtbyUyMiUyQyUyMHNwbGl0JTNEJTIydHJhaW4lMjIpJTBBZGF0YXNldC5mZWF0dXJlcw==",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

dataset = load_dataset(<span class="hljs-string">&quot;sayakpaul/instructpix2pix-demo&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)
dataset.features`,wrap:!1}}),Xe=new J({props:{code:"JTdCJ2lucHV0JyUzQSUyMFZhbHVlKGR0eXBlJTNEJ3N0cmluZyclMkMlMjBpZCUzRE5vbmUpJTJDJTBBJTIwJ2VkaXQnJTNBJTIwVmFsdWUoZHR5cGUlM0Qnc3RyaW5nJyUyQyUyMGlkJTNETm9uZSklMkMlMEElMjAnb3V0cHV0JyUzQSUyMFZhbHVlKGR0eXBlJTNEJ3N0cmluZyclMkMlMjBpZCUzRE5vbmUpJTJDJTBBJTIwJ2ltYWdlJyUzQSUyMEltYWdlKGRlY29kZSUzRFRydWUlMkMlMjBpZCUzRE5vbmUpJTdE",highlighted:`{<span class="hljs-string">&#x27;input&#x27;</span>: Value(dtype=<span class="hljs-string">&#x27;string&#x27;</span>, <span class="hljs-built_in">id</span>=None),
 <span class="hljs-string">&#x27;edit&#x27;</span>: Value(dtype=<span class="hljs-string">&#x27;string&#x27;</span>, <span class="hljs-built_in">id</span>=None),
 <span class="hljs-string">&#x27;output&#x27;</span>: Value(dtype=<span class="hljs-string">&#x27;string&#x27;</span>, <span class="hljs-built_in">id</span>=None),
 <span class="hljs-string">&#x27;image&#x27;</span>: Image(decode=True, <span class="hljs-built_in">id</span>=None)}`,wrap:!1}}),Fe=new J({props:{code:"aWR4JTIwJTNEJTIwMCUwQXByaW50KGYlMjJPcmlnaW5hbCUyMGNhcHRpb24lM0ElMjAlN0JkYXRhc2V0JTVCaWR4JTVEJTVCJ2lucHV0JyU1RCU3RCUyMiklMEFwcmludChmJTIyRWRpdCUyMGluc3RydWN0aW9uJTNBJTIwJTdCZGF0YXNldCU1QmlkeCU1RCU1QidlZGl0JyU1RCU3RCUyMiklMEFwcmludChmJTIyTW9kaWZpZWQlMjBjYXB0aW9uJTNBJTIwJTdCZGF0YXNldCU1QmlkeCU1RCU1QidvdXRwdXQnJTVEJTdEJTIyKQ==",highlighted:`idx = <span class="hljs-number">0</span>
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Original caption: <span class="hljs-subst">{dataset[idx][<span class="hljs-string">&#x27;input&#x27;</span>]}</span>&quot;</span>)
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Edit instruction: <span class="hljs-subst">{dataset[idx][<span class="hljs-string">&#x27;edit&#x27;</span>]}</span>&quot;</span>)
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Modified caption: <span class="hljs-subst">{dataset[idx][<span class="hljs-string">&#x27;output&#x27;</span>]}</span>&quot;</span>)`,wrap:!1}}),$e=new J({props:{code:"T3JpZ2luYWwlMjBjYXB0aW9uJTNBJTIwMi4lMjBGQVJPRSUyMElTTEFORFMlM0ElMjBBbiUyMGFyY2hpcGVsYWdvJTIwb2YlMjAxOCUyMG1vdW50YWlub3VzJTIwaXNsZXMlMjBpbiUyMHRoZSUyME5vcnRoJTIwQXRsYW50aWMlMjBPY2VhbiUyMGJldHdlZW4lMjBOb3J3YXklMjBhbmQlMjBJY2VsYW5kJTJDJTIwdGhlJTIwRmFyb2UlMjBJc2xhbmRzJTIwaGFzJTIwJ2V2ZXJ5dGhpbmclMjB5b3UlMjBjb3VsZCUyMGhvcGUlMjBmb3InJTJDJTIwYWNjb3JkaW5nJTIwdG8lMjBCaWclMjA3JTIwVHJhdmVsLiUyMEl0JTIwYm9hc3RzJTIwJ2NyeXN0YWwlMjBjbGVhciUyMHdhdGVyZmFsbHMlMkMlMjByb2NreSUyMGNsaWZmcyUyMHRoYXQlMjBzZWVtJTIwdG8lMjBqdXQlMjBvdXQlMjBvZiUyMG5vd2hlcmUlMjBhbmQlMjB2ZWx2ZXR5JTIwZ3JlZW4lMjBoaWxscyclMEFFZGl0JTIwaW5zdHJ1Y3Rpb24lM0ElMjBtYWtlJTIwdGhlJTIwaXNsZXMlMjBhbGwlMjB3aGl0ZSUyMG1hcmJsZSUwQU1vZGlmaWVkJTIwY2FwdGlvbiUzQSUyMDIuJTIwV0hJVEUlMjBNQVJCTEUlMjBJU0xBTkRTJTNBJTIwQW4lMjBhcmNoaXBlbGFnbyUyMG9mJTIwMTglMjBtb3VudGFpbm91cyUyMHdoaXRlJTIwbWFyYmxlJTIwaXNsZXMlMjBpbiUyMHRoZSUyME5vcnRoJTIwQXRsYW50aWMlMjBPY2VhbiUyMGJldHdlZW4lMjBOb3J3YXklMjBhbmQlMjBJY2VsYW5kJTJDJTIwdGhlJTIwV2hpdGUlMjBNYXJibGUlMjBJc2xhbmRzJTIwaGFzJTIwJ2V2ZXJ5dGhpbmclMjB5b3UlMjBjb3VsZCUyMGhvcGUlMjBmb3InJTJDJTIwYWNjb3JkaW5nJTIwdG8lMjBCaWclMjA3JTIwVHJhdmVsLiUyMEl0JTIwYm9hc3RzJTIwJ2NyeXN0YWwlMjBjbGVhciUyMHdhdGVyZmFsbHMlMkMlMjByb2NreSUyMGNsaWZmcyUyMHRoYXQlMjBzZWVtJTIwdG8lMjBqdXQlMjBvdXQlMjBvZiUyMG5vd2hlcmUlMjBhbmQlMjB2ZWx2ZXR5JTIwZ3JlZW4lMjBoaWxscyc=",highlighted:`Original caption: 2. FAROE ISLANDS: An archipelago of 18 mountainous isles <span class="hljs-keyword">in</span> the North Atlantic Ocean between Norway and Iceland, the Faroe Islands has <span class="hljs-string">&#x27;everything you could hope for&#x27;</span>, according to Big 7 Travel. It boasts <span class="hljs-string">&#x27;crystal clear waterfalls, rocky cliffs that seem to jut out of nowhere and velvety green hills&#x27;</span>
Edit instruction: make the isles all white marble
Modified caption: 2. WHITE MARBLE ISLANDS: An archipelago of 18 mountainous white marble isles <span class="hljs-keyword">in</span> the North Atlantic Ocean between Norway and Iceland, the White Marble Islands has <span class="hljs-string">&#x27;everything you could hope for&#x27;</span>, according to Big 7 Travel. It boasts <span class="hljs-string">&#x27;crystal clear waterfalls, rocky cliffs that seem to jut out of nowhere and velvety green hills&#x27;</span>`,wrap:!1}}),Ee=new J({props:{code:"ZGF0YXNldCU1QmlkeCU1RCU1QiUyMmltYWdlJTIyJTVE",highlighted:'dataset[idx][<span class="hljs-string">&quot;image&quot;</span>]',wrap:!1}}),ze=new J({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvbkluc3RydWN0UGl4MlBpeFBpcGVsaW5lJTBBJTBBaW5zdHJ1Y3RfcGl4MnBpeF9waXBlbGluZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvbkluc3RydWN0UGl4MlBpeFBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJ0aW1icm9va3MlMkZpbnN0cnVjdC1waXgycGl4JTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionInstructPix2PixPipeline

instruct_pix2pix_pipeline = StableDiffusionInstructPix2PixPipeline.from_pretrained(
    <span class="hljs-string">&quot;timbrooks/instruct-pix2pix&quot;</span>, torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),Le=new J({props:{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBJTBBJTBBZGVmJTIwZWRpdF9pbWFnZShpbnB1dF9pbWFnZSUyQyUyMGluc3RydWN0aW9uKSUzQSUwQSUyMCUyMCUyMCUyMGltYWdlJTIwJTNEJTIwaW5zdHJ1Y3RfcGl4MnBpeF9waXBlbGluZSglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpbnN0cnVjdGlvbiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGltYWdlJTNEaW5wdXRfaW1hZ2UlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRwdXRfdHlwZSUzRCUyMm5wJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yJTJDJTBBJTIwJTIwJTIwJTIwKS5pbWFnZXMlNUIwJTVEJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwaW1hZ2UlMEElMEFpbnB1dF9pbWFnZXMlMjAlM0QlMjAlNUIlNUQlMEFvcmlnaW5hbF9jYXB0aW9ucyUyMCUzRCUyMCU1QiU1RCUwQW1vZGlmaWVkX2NhcHRpb25zJTIwJTNEJTIwJTVCJTVEJTBBZWRpdGVkX2ltYWdlcyUyMCUzRCUyMCU1QiU1RCUwQSUwQWZvciUyMGlkeCUyMGluJTIwcmFuZ2UobGVuKGRhdGFzZXQpKSUzQSUwQSUyMCUyMCUyMCUyMGlucHV0X2ltYWdlJTIwJTNEJTIwZGF0YXNldCU1QmlkeCU1RCU1QiUyMmltYWdlJTIyJTVEJTBBJTIwJTIwJTIwJTIwZWRpdF9pbnN0cnVjdGlvbiUyMCUzRCUyMGRhdGFzZXQlNUJpZHglNUQlNUIlMjJlZGl0JTIyJTVEJTBBJTIwJTIwJTIwJTIwZWRpdGVkX2ltYWdlJTIwJTNEJTIwZWRpdF9pbWFnZShpbnB1dF9pbWFnZSUyQyUyMGVkaXRfaW5zdHJ1Y3Rpb24pJTBBJTBBJTIwJTIwJTIwJTIwaW5wdXRfaW1hZ2VzLmFwcGVuZChucC5hcnJheShpbnB1dF9pbWFnZSkpJTBBJTIwJTIwJTIwJTIwb3JpZ2luYWxfY2FwdGlvbnMuYXBwZW5kKGRhdGFzZXQlNUJpZHglNUQlNUIlMjJpbnB1dCUyMiU1RCklMEElMjAlMjAlMjAlMjBtb2RpZmllZF9jYXB0aW9ucy5hcHBlbmQoZGF0YXNldCU1QmlkeCU1RCU1QiUyMm91dHB1dCUyMiU1RCklMEElMjAlMjAlMjAlMjBlZGl0ZWRfaW1hZ2VzLmFwcGVuZChlZGl0ZWRfaW1hZ2Up",highlighted:`<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np


<span class="hljs-keyword">def</span> <span class="hljs-title function_">edit_image</span>(<span class="hljs-params">input_image, instruction</span>):
    image = instruct_pix2pix_pipeline(
        instruction,
        image=input_image,
        output_type=<span class="hljs-string">&quot;np&quot;</span>,
        generator=generator,
    ).images[<span class="hljs-number">0</span>]
    <span class="hljs-keyword">return</span> image

input_images = []
original_captions = []
modified_captions = []
edited_images = []

<span class="hljs-keyword">for</span> idx <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-built_in">len</span>(dataset)):
    input_image = dataset[idx][<span class="hljs-string">&quot;image&quot;</span>]
    edit_instruction = dataset[idx][<span class="hljs-string">&quot;edit&quot;</span>]
    edited_image = edit_image(input_image, edit_instruction)

    input_images.append(np.array(input_image))
    original_captions.append(dataset[idx][<span class="hljs-string">&quot;input&quot;</span>])
    modified_captions.append(dataset[idx][<span class="hljs-string">&quot;output&quot;</span>])
    edited_images.append(edited_image)`,wrap:!1}}),qe=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMCglMEElMjAlMjAlMjAlMjBDTElQVG9rZW5pemVyJTJDJTBBJTIwJTIwJTIwJTIwQ0xJUFRleHRNb2RlbFdpdGhQcm9qZWN0aW9uJTJDJTBBJTIwJTIwJTIwJTIwQ0xJUFZpc2lvbk1vZGVsV2l0aFByb2plY3Rpb24lMkMlMEElMjAlMjAlMjAlMjBDTElQSW1hZ2VQcm9jZXNzb3IlMkMlMEEpJTBBJTBBY2xpcF9pZCUyMCUzRCUyMCUyMm9wZW5haSUyRmNsaXAtdml0LWxhcmdlLXBhdGNoMTQlMjIlMEF0b2tlbml6ZXIlMjAlM0QlMjBDTElQVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChjbGlwX2lkKSUwQXRleHRfZW5jb2RlciUyMCUzRCUyMENMSVBUZXh0TW9kZWxXaXRoUHJvamVjdGlvbi5mcm9tX3ByZXRyYWluZWQoY2xpcF9pZCkudG8oJTIyY3VkYSUyMiklMEFpbWFnZV9wcm9jZXNzb3IlMjAlM0QlMjBDTElQSW1hZ2VQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKGNsaXBfaWQpJTBBaW1hZ2VfZW5jb2RlciUyMCUzRCUyMENMSVBWaXNpb25Nb2RlbFdpdGhQcm9qZWN0aW9uLmZyb21fcHJldHJhaW5lZChjbGlwX2lkKS50byglMjJjdWRhJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> (
    CLIPTokenizer,
    CLIPTextModelWithProjection,
    CLIPVisionModelWithProjection,
    CLIPImageProcessor,
)

clip_id = <span class="hljs-string">&quot;openai/clip-vit-large-patch14&quot;</span>
tokenizer = CLIPTokenizer.from_pretrained(clip_id)
text_encoder = CLIPTextModelWithProjection.from_pretrained(clip_id).to(<span class="hljs-string">&quot;cuda&quot;</span>)
image_processor = CLIPImageProcessor.from_pretrained(clip_id)
image_encoder = CLIPVisionModelWithProjection.from_pretrained(clip_id).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),Oe=new J({props:{code:" ",highlighted:`<span class="hljs-keyword">import</span> torch.nn <span class="hljs-keyword">as</span> nn
<span class="hljs-keyword">import</span> torch.nn.functional <span class="hljs-keyword">as</span> F


<span class="hljs-keyword">class</span> <span class="hljs-title class_">DirectionalSimilarity</span>(nn.Module):
    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self, tokenizer, text_encoder, image_processor, image_encoder</span>):
        <span class="hljs-built_in">super</span>().__init__()
        self.tokenizer = tokenizer
        self.text_encoder = text_encoder
        self.image_processor = image_processor
        self.image_encoder = image_encoder

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_image</span>(<span class="hljs-params">self, image</span>):
        image = self.image_processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)[<span class="hljs-string">&quot;pixel_values&quot;</span>]
        <span class="hljs-keyword">return</span> {<span class="hljs-string">&quot;pixel_values&quot;</span>: image.to(<span class="hljs-string">&quot;cuda&quot;</span>)}

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">tokenize_text</span>(<span class="hljs-params">self, text</span>):
        inputs = self.tokenizer(
            text,
            max_length=self.tokenizer.model_max_length,
            padding=<span class="hljs-string">&quot;max_length&quot;</span>,
            truncation=<span class="hljs-literal">True</span>,
            return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
        )
        <span class="hljs-keyword">return</span> {<span class="hljs-string">&quot;input_ids&quot;</span>: inputs.input_ids.to(<span class="hljs-string">&quot;cuda&quot;</span>)}

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">encode_image</span>(<span class="hljs-params">self, image</span>):
        preprocessed_image = self.preprocess_image(image)
        image_features = self.image_encoder(**preprocessed_image).image_embeds
        image_features = image_features / image_features.norm(dim=<span class="hljs-number">1</span>, keepdim=<span class="hljs-literal">True</span>)
        <span class="hljs-keyword">return</span> image_features

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">encode_text</span>(<span class="hljs-params">self, text</span>):
        tokenized_text = self.tokenize_text(text)
        text_features = self.text_encoder(**tokenized_text).text_embeds
        text_features = text_features / text_features.norm(dim=<span class="hljs-number">1</span>, keepdim=<span class="hljs-literal">True</span>)
        <span class="hljs-keyword">return</span> text_features

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_directional_similarity</span>(<span class="hljs-params">self, img_feat_one, img_feat_two, text_feat_one, text_feat_two</span>):
        sim_direction = F.cosine_similarity(img_feat_two - img_feat_one, text_feat_two - text_feat_one)
        <span class="hljs-keyword">return</span> sim_direction

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, image_one, image_two, caption_one, caption_two</span>):
        img_feat_one = self.encode_image(image_one)
        img_feat_two = self.encode_image(image_two)
        text_feat_one = self.encode_text(caption_one)
        text_feat_two = self.encode_text(caption_two)
        directional_similarity = self.compute_directional_similarity(
            img_feat_one, img_feat_two, text_feat_one, text_feat_two
        )
        <span class="hljs-keyword">return</span> directional_similarity`,wrap:!1}}),tt=new J({props:{code:"ZGlyX3NpbWlsYXJpdHklMjAlM0QlMjBEaXJlY3Rpb25hbFNpbWlsYXJpdHkodG9rZW5pemVyJTJDJTIwdGV4dF9lbmNvZGVyJTJDJTIwaW1hZ2VfcHJvY2Vzc29yJTJDJTIwaW1hZ2VfZW5jb2RlciklMEFzY29yZXMlMjAlM0QlMjAlNUIlNUQlMEElMEFmb3IlMjBpJTIwaW4lMjByYW5nZShsZW4oaW5wdXRfaW1hZ2VzKSklM0ElMEElMjAlMjAlMjAlMjBvcmlnaW5hbF9pbWFnZSUyMCUzRCUyMGlucHV0X2ltYWdlcyU1QmklNUQlMEElMjAlMjAlMjAlMjBvcmlnaW5hbF9jYXB0aW9uJTIwJTNEJTIwb3JpZ2luYWxfY2FwdGlvbnMlNUJpJTVEJTBBJTIwJTIwJTIwJTIwZWRpdGVkX2ltYWdlJTIwJTNEJTIwZWRpdGVkX2ltYWdlcyU1QmklNUQlMEElMjAlMjAlMjAlMjBtb2RpZmllZF9jYXB0aW9uJTIwJTNEJTIwbW9kaWZpZWRfY2FwdGlvbnMlNUJpJTVEJTBBJTBBJTIwJTIwJTIwJTIwc2ltaWxhcml0eV9zY29yZSUyMCUzRCUyMGRpcl9zaW1pbGFyaXR5KG9yaWdpbmFsX2ltYWdlJTJDJTIwZWRpdGVkX2ltYWdlJTJDJTIwb3JpZ2luYWxfY2FwdGlvbiUyQyUyMG1vZGlmaWVkX2NhcHRpb24pJTBBJTIwJTIwJTIwJTIwc2NvcmVzLmFwcGVuZChmbG9hdChzaW1pbGFyaXR5X3Njb3JlLmRldGFjaCgpLmNwdSgpKSklMEElMEFwcmludChmJTIyQ0xJUCUyMGRpcmVjdGlvbmFsJTIwc2ltaWxhcml0eSUzQSUyMCU3Qm5wLm1lYW4oc2NvcmVzKSU3RCUyMiklMEElMjMlMjBDTElQJTIwZGlyZWN0aW9uYWwlMjBzaW1pbGFyaXR5JTNBJTIwMC4wNzk3OTc2NTUzNDQwMDk0",highlighted:`dir_similarity = DirectionalSimilarity(tokenizer, text_encoder, image_processor, image_encoder)
scores = []

<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-built_in">len</span>(input_images)):
    original_image = input_images[i]
    original_caption = original_captions[i]
    edited_image = edited_images[i]
    modified_caption = modified_captions[i]

    similarity_score = dir_similarity(original_image, edited_image, original_caption, modified_caption)
    scores.append(<span class="hljs-built_in">float</span>(similarity_score.detach().cpu()))

<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;CLIP directional similarity: <span class="hljs-subst">{np.mean(scores)}</span>&quot;</span>)
<span class="hljs-comment"># CLIP directional similarity: 0.0797976553440094</span>`,wrap:!1}}),v=new Gt({props:{$$slots:{default:[fi]},$$scope:{ctx:b}}}),ot=new Bt({props:{title:"Class-conditioned image generation",local:"class-conditioned-image-generation",headingTag:"h3"}}),ut=new J({props:{code:"ZnJvbSUyMHppcGZpbGUlMjBpbXBvcnQlMjBaaXBGaWxlJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEElMEElMEFkZWYlMjBkb3dubG9hZCh1cmwlMkMlMjBsb2NhbF9maWxlcGF0aCklM0ElMEElMjAlMjAlMjAlMjByJTIwJTNEJTIwcmVxdWVzdHMuZ2V0KHVybCklMEElMjAlMjAlMjAlMjB3aXRoJTIwb3Blbihsb2NhbF9maWxlcGF0aCUyQyUyMCUyMndiJTIyKSUyMGFzJTIwZiUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGYud3JpdGUoci5jb250ZW50KSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMGxvY2FsX2ZpbGVwYXRoJTBBJTBBZHVtbXlfZGF0YXNldF91cmwlMjAlM0QlMjAlMjJodHRwcyUzQSUyRiUyRmhmLmNvJTJGZGF0YXNldHMlMkZzYXlha3BhdWwlMkZzYW1wbGUtZGF0YXNldHMlMkZyZXNvbHZlJTJGbWFpbiUyRnNhbXBsZS1pbWFnZW5ldC1pbWFnZXMuemlwJTIyJTBBbG9jYWxfZmlsZXBhdGglMjAlM0QlMjBkb3dubG9hZChkdW1teV9kYXRhc2V0X3VybCUyQyUyMGR1bW15X2RhdGFzZXRfdXJsLnNwbGl0KCUyMiUyRiUyMiklNUItMSU1RCklMEElMEF3aXRoJTIwWmlwRmlsZShsb2NhbF9maWxlcGF0aCUyQyUyMCUyMnIlMjIpJTIwYXMlMjB6aXBwZXIlM0ElMEElMjAlMjAlMjAlMjB6aXBwZXIuZXh0cmFjdGFsbCglMjIuJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> zipfile <span class="hljs-keyword">import</span> ZipFile
<span class="hljs-keyword">import</span> requests


<span class="hljs-keyword">def</span> <span class="hljs-title function_">download</span>(<span class="hljs-params">url, local_filepath</span>):
    r = requests.get(url)
    <span class="hljs-keyword">with</span> <span class="hljs-built_in">open</span>(local_filepath, <span class="hljs-string">&quot;wb&quot;</span>) <span class="hljs-keyword">as</span> f:
        f.write(r.content)
    <span class="hljs-keyword">return</span> local_filepath

dummy_dataset_url = <span class="hljs-string">&quot;https://hf.co/datasets/sayakpaul/sample-datasets/resolve/main/sample-imagenet-images.zip&quot;</span>
local_filepath = download(dummy_dataset_url, dummy_dataset_url.split(<span class="hljs-string">&quot;/&quot;</span>)[-<span class="hljs-number">1</span>])

<span class="hljs-keyword">with</span> ZipFile(local_filepath, <span class="hljs-string">&quot;r&quot;</span>) <span class="hljs-keyword">as</span> zipper:
    zipper.extractall(<span class="hljs-string">&quot;.&quot;</span>)`,wrap:!1}}),ht=new J({props:{code:"ZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBaW1wb3J0JTIwb3MlMEFpbXBvcnQlMjBudW1weSUyMGFzJTIwbnAlMEElMEFkYXRhc2V0X3BhdGglMjAlM0QlMjAlMjJzYW1wbGUtaW1hZ2VuZXQtaW1hZ2VzJTIyJTBBaW1hZ2VfcGF0aHMlMjAlM0QlMjBzb3J0ZWQoJTVCb3MucGF0aC5qb2luKGRhdGFzZXRfcGF0aCUyQyUyMHgpJTIwZm9yJTIweCUyMGluJTIwb3MubGlzdGRpcihkYXRhc2V0X3BhdGgpJTVEKSUwQSUwQXJlYWxfaW1hZ2VzJTIwJTNEJTIwJTVCbnAuYXJyYXkoSW1hZ2Uub3BlbihwYXRoKS5jb252ZXJ0KCUyMlJHQiUyMikpJTIwZm9yJTIwcGF0aCUyMGluJTIwaW1hZ2VfcGF0aHMlNUQ=",highlighted:`<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">import</span> os
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np

dataset_path = <span class="hljs-string">&quot;sample-imagenet-images&quot;</span>
image_paths = <span class="hljs-built_in">sorted</span>([os.path.join(dataset_path, x) <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> os.listdir(dataset_path)])

real_images = [np.array(Image.<span class="hljs-built_in">open</span>(path).convert(<span class="hljs-string">&quot;RGB&quot;</span>)) <span class="hljs-keyword">for</span> path <span class="hljs-keyword">in</span> image_paths]`,wrap:!1}}),Jt=new J({props:{code:"ZnJvbSUyMHRvcmNodmlzaW9uLnRyYW5zZm9ybXMlMjBpbXBvcnQlMjBmdW5jdGlvbmFsJTIwYXMlMjBGJTBBaW1wb3J0JTIwdG9yY2glMEElMEElMEFkZWYlMjBwcmVwcm9jZXNzX2ltYWdlKGltYWdlKSUzQSUwQSUyMCUyMCUyMCUyMGltYWdlJTIwJTNEJTIwdG9yY2gudGVuc29yKGltYWdlKS51bnNxdWVlemUoMCklMEElMjAlMjAlMjAlMjBpbWFnZSUyMCUzRCUyMGltYWdlLnBlcm11dGUoMCUyQyUyMDMlMkMlMjAxJTJDJTIwMiklMjAlMkYlMjAyNTUuMCUwQSUyMCUyMCUyMCUyMHJldHVybiUyMEYuY2VudGVyX2Nyb3AoaW1hZ2UlMkMlMjAoMjU2JTJDJTIwMjU2KSklMEElMEFyZWFsX2ltYWdlcyUyMCUzRCUyMHRvcmNoLmNhdCglNUJwcmVwcm9jZXNzX2ltYWdlKGltYWdlKSUyMGZvciUyMGltYWdlJTIwaW4lMjByZWFsX2ltYWdlcyU1RCklMEFwcmludChyZWFsX2ltYWdlcy5zaGFwZSklMEElMjMlMjB0b3JjaC5TaXplKCU1QjEwJTJDJTIwMyUyQyUyMDI1NiUyQyUyMDI1NiU1RCk=",highlighted:`<span class="hljs-keyword">from</span> torchvision.transforms <span class="hljs-keyword">import</span> functional <span class="hljs-keyword">as</span> F
<span class="hljs-keyword">import</span> torch


<span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_image</span>(<span class="hljs-params">image</span>):
    image = torch.tensor(image).unsqueeze(<span class="hljs-number">0</span>)
    image = image.permute(<span class="hljs-number">0</span>, <span class="hljs-number">3</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>) / <span class="hljs-number">255.0</span>
    <span class="hljs-keyword">return</span> F.center_crop(image, (<span class="hljs-number">256</span>, <span class="hljs-number">256</span>))

real_images = torch.cat([preprocess_image(image) <span class="hljs-keyword">for</span> image <span class="hljs-keyword">in</span> real_images])
<span class="hljs-built_in">print</span>(real_images.shape)
<span class="hljs-comment"># torch.Size([10, 3, 256, 256])</span>`,wrap:!1}}),Tt=new J({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpVFBpcGVsaW5lJTJDJTIwRFBNU29sdmVyTXVsdGlzdGVwU2NoZWR1bGVyJTBBJTBBZGl0X3BpcGVsaW5lJTIwJTNEJTIwRGlUUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGRGlULVhMLTItMjU2JTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KSUwQWRpdF9waXBlbGluZS5zY2hlZHVsZXIlMjAlM0QlMjBEUE1Tb2x2ZXJNdWx0aXN0ZXBTY2hlZHVsZXIuZnJvbV9jb25maWcoZGl0X3BpcGVsaW5lLnNjaGVkdWxlci5jb25maWcpJTBBZGl0X3BpcGVsaW5lJTIwJTNEJTIwZGl0X3BpcGVsaW5lLnRvKCUyMmN1ZGElMjIpJTBBJTBBc2VlZCUyMCUzRCUyMDAlMEFnZW5lcmF0b3IlMjAlM0QlMjB0b3JjaC5tYW51YWxfc2VlZChzZWVkKSUwQSUwQSUwQXdvcmRzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIyY2Fzc2V0dGUlMjBwbGF5ZXIlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJjaGFpbnNhdyUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMmNoYWluc2F3JTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyY2h1cmNoJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyZ2FzJTIwcHVtcCUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMmdhcyUyMHB1bXAlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJnYXMlMjBwdW1wJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIycGFyYWNodXRlJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIycGFyYWNodXRlJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIydGVuY2glMjIlMkMlMEElNUQlMEElMEFjbGFzc19pZHMlMjAlM0QlMjBkaXRfcGlwZWxpbmUuZ2V0X2xhYmVsX2lkcyh3b3JkcyklMEFvdXRwdXQlMjAlM0QlMjBkaXRfcGlwZWxpbmUoY2xhc3NfbGFiZWxzJTNEY2xhc3NfaWRzJTJDJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yJTJDJTIwb3V0cHV0X3R5cGUlM0QlMjJucCUyMiklMEElMEFmYWtlX2ltYWdlcyUyMCUzRCUyMG91dHB1dC5pbWFnZXMlMEFmYWtlX2ltYWdlcyUyMCUzRCUyMHRvcmNoLnRlbnNvcihmYWtlX2ltYWdlcyklMEFmYWtlX2ltYWdlcyUyMCUzRCUyMGZha2VfaW1hZ2VzLnBlcm11dGUoMCUyQyUyMDMlMkMlMjAxJTJDJTIwMiklMEFwcmludChmYWtlX2ltYWdlcy5zaGFwZSklMEElMjMlMjB0b3JjaC5TaXplKCU1QjEwJTJDJTIwMyUyQyUyMDI1NiUyQyUyMDI1NiU1RCk=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiTPipeline, DPMSolverMultistepScheduler

dit_pipeline = DiTPipeline.from_pretrained(<span class="hljs-string">&quot;facebook/DiT-XL-2-256&quot;</span>, torch_dtype=torch.float16)
dit_pipeline.scheduler = DPMSolverMultistepScheduler.from_config(dit_pipeline.scheduler.config)
dit_pipeline = dit_pipeline.to(<span class="hljs-string">&quot;cuda&quot;</span>)

seed = <span class="hljs-number">0</span>
generator = torch.manual_seed(seed)


words = [
    <span class="hljs-string">&quot;cassette player&quot;</span>,
    <span class="hljs-string">&quot;chainsaw&quot;</span>,
    <span class="hljs-string">&quot;chainsaw&quot;</span>,
    <span class="hljs-string">&quot;church&quot;</span>,
    <span class="hljs-string">&quot;gas pump&quot;</span>,
    <span class="hljs-string">&quot;gas pump&quot;</span>,
    <span class="hljs-string">&quot;gas pump&quot;</span>,
    <span class="hljs-string">&quot;parachute&quot;</span>,
    <span class="hljs-string">&quot;parachute&quot;</span>,
    <span class="hljs-string">&quot;tench&quot;</span>,
]

class_ids = dit_pipeline.get_label_ids(words)
output = dit_pipeline(class_labels=class_ids, generator=generator, output_type=<span class="hljs-string">&quot;np&quot;</span>)

fake_images = output.images
fake_images = torch.tensor(fake_images)
fake_images = fake_images.permute(<span class="hljs-number">0</span>, <span class="hljs-number">3</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>)
<span class="hljs-built_in">print</span>(fake_images.shape)
<span class="hljs-comment"># torch.Size([10, 3, 256, 256])</span>`,wrap:!1}}),Ut=new J({props:{code:"ZnJvbSUyMHRvcmNobWV0cmljcy5pbWFnZS5maWQlMjBpbXBvcnQlMjBGcmVjaGV0SW5jZXB0aW9uRGlzdGFuY2UlMEElMEFmaWQlMjAlM0QlMjBGcmVjaGV0SW5jZXB0aW9uRGlzdGFuY2Uobm9ybWFsaXplJTNEVHJ1ZSklMEFmaWQudXBkYXRlKHJlYWxfaW1hZ2VzJTJDJTIwcmVhbCUzRFRydWUpJTBBZmlkLnVwZGF0ZShmYWtlX2ltYWdlcyUyQyUyMHJlYWwlM0RGYWxzZSklMEElMEFwcmludChmJTIyRklEJTNBJTIwJTdCZmxvYXQoZmlkLmNvbXB1dGUoKSklN0QlMjIpJTBBJTIzJTIwRklEJTNBJTIwMTc3LjcxNDcyMTY3OTY4NzU=",highlighted:`<span class="hljs-keyword">from</span> torchmetrics.image.fid <span class="hljs-keyword">import</span> FrechetInceptionDistance

fid = FrechetInceptionDistance(normalize=<span class="hljs-literal">True</span>)
fid.update(real_images, real=<span class="hljs-literal">True</span>)
fid.update(fake_images, real=<span class="hljs-literal">False</span>)

<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;FID: <span class="hljs-subst">{<span class="hljs-built_in">float</span>(fid.compute())}</span>&quot;</span>)
<span class="hljs-comment"># FID: 177.7147216796875</span>`,wrap:!1}}),G=new Gt({props:{warning:!0,$$slots:{default:[yi]},$$scope:{ctx:b}}}),Zt=new ci({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/conceptual/evaluation.md"}}),{c(){r=n("meta"),T=a(),f=n("p"),w=a(),M(g.$$.fragment),C=a(),j=n("a"),j.innerHTML=vt,Z=a(),M(U.$$.fragment),k=a(),y=n("p"),y.innerHTML=I,kt=a(),X=n("p"),X.textContent=Xs,Xt=a(),V=n("p"),V.innerHTML=Vs,Vt=a(),R=n("p"),R.innerHTML=Rs,Rt=a(),M(H.$$.fragment),Ht=a(),F=n("p"),F.textContent=Hs,Ft=a(),$=n("ul"),$.innerHTML=Fs,$t=a(),M(N.$$.fragment),Nt=a(),E=n("p"),E.innerHTML=$s,Et=a(),Y=n("p"),Y.innerHTML=Ns,Yt=a(),Q=n("blockquote"),Q.innerHTML=Es,Qt=a(),A=n("p"),A.innerHTML=Ys,At=a(),z=n("p"),z.textContent=Qs,zt=a(),S=n("ul"),S.innerHTML=As,St=a(),L=n("p"),L.textContent=zs,Lt=a(),P=n("p"),P.innerHTML=Ss,Pt=a(),q=n("ul"),q.innerHTML=Ls,qt=a(),D=n("p"),D.innerHTML=Ps,Dt=a(),K=n("p"),K.innerHTML=qs,Kt=a(),M(O.$$.fragment),Ot=a(),ee=n("p"),ee.innerHTML=Ds,el=a(),M(te.$$.fragment),tl=a(),le=n("p"),le.innerHTML=Ks,ll=a(),se=n("p"),se.innerHTML=Os,sl=a(),ae=n("p"),ae.innerHTML=ea,al=a(),ie=n("p"),ie.textContent=ta,il=a(),M(B.$$.fragment),nl=a(),M(ne.$$.fragment),pl=a(),pe=n("p"),pe.textContent=la,ol=a(),oe=n("ul"),oe.innerHTML=sa,rl=a(),M(re.$$.fragment),Ml=a(),Me=n("p"),Me.innerHTML=aa,ml=a(),me=n("p"),me.innerHTML=ia,cl=a(),M(ce.$$.fragment),dl=a(),de=n("p"),de.textContent=na,ul=a(),M(ue.$$.fragment),hl=a(),he=n("p"),he.textContent=pa,fl=a(),M(fe.$$.fragment),yl=a(),ye=n("p"),ye.textContent=oa,Jl=a(),Je=n("p"),Je.innerHTML=ra,wl=a(),M(we.$$.fragment),Tl=a(),Te=n("p"),Te.innerHTML=Ma,jl=a(),M(je.$$.fragment),Ul=a(),Ue=n("p"),Ue.textContent=ma,bl=a(),M(be.$$.fragment),gl=a(),ge=n("p"),ge.innerHTML=ca,Il=a(),M(W.$$.fragment),Cl=a(),M(Ie.$$.fragment),Zl=a(),Ce=n("p"),Ce.innerHTML=da,Bl=a(),Ze=n("p"),Ze.textContent=ua,Wl=a(),Be=n("p"),Be.innerHTML=ha,vl=a(),We=n("p"),We.innerHTML=fa,_l=a(),ve=n("ul"),ve.innerHTML=ya,Gl=a(),_e=n("p"),_e.textContent=Ja,xl=a(),Ge=n("p"),Ge.innerHTML=wa,kl=a(),xe=n("p"),xe.textContent=Ta,Xl=a(),M(ke.$$.fragment),Vl=a(),M(Xe.$$.fragment),Rl=a(),Ve=n("p"),Ve.textContent=ja,Hl=a(),Re=n("ul"),Re.innerHTML=Ua,Fl=a(),He=n("p"),He.textContent=ba,$l=a(),M(Fe.$$.fragment),Nl=a(),M($e.$$.fragment),El=a(),Ne=n("p"),Ne.textContent=ga,Yl=a(),M(Ee.$$.fragment),Ql=a(),Ye=n("p"),Ye.innerHTML=Ia,Al=a(),Qe=n("p"),Qe.textContent=Ca,zl=a(),Ae=n("p"),Ae.innerHTML=Za,Sl=a(),M(ze.$$.fragment),Ll=a(),Se=n("p"),Se.textContent=Ba,Pl=a(),M(Le.$$.fragment),ql=a(),Pe=n("p"),Pe.textContent=Wa,Dl=a(),M(qe.$$.fragment),Kl=a(),De=n("p"),De.innerHTML=va,Ol=a(),Ke=n("p"),Ke.innerHTML=_a,es=a(),M(Oe.$$.fragment),ts=a(),et=n("p"),et.innerHTML=Ga,ls=a(),M(tt.$$.fragment),ss=a(),lt=n("p"),lt.textContent=xa,as=a(),st=n("p"),st.innerHTML=ka,is=a(),at=n("p"),at.innerHTML=Xa,ns=a(),it=n("p"),it.innerHTML=Va,ps=a(),M(v.$$.fragment),os=a(),nt=n("p"),nt.innerHTML=Ra,rs=a(),pt=n("p"),pt.innerHTML=Ha,Ms=a(),M(ot.$$.fragment),ms=a(),rt=n("p"),rt.innerHTML=Fa,cs=a(),Mt=n("p"),Mt.innerHTML=$a,ds=a(),mt=n("blockquote"),mt.innerHTML=Na,us=a(),ct=n("p"),ct.textContent=Ea,hs=a(),dt=n("p"),dt.textContent=Ya,fs=a(),M(ut.$$.fragment),ys=a(),M(ht.$$.fragment),Js=a(),ft=n("p"),ft.textContent=Qa,ws=a(),_=n("p"),_.innerHTML=Aa,Ts=a(),yt=n("p"),yt.textContent=za,js=a(),M(Jt.$$.fragment),Us=a(),wt=n("p"),wt.innerHTML=Sa,bs=a(),M(Tt.$$.fragment),gs=a(),jt=n("p"),jt.innerHTML=La,Is=a(),M(Ut.$$.fragment),Cs=a(),bt=n("p"),bt.textContent=Pa,Zs=a(),gt=n("ul"),gt.innerHTML=qa,Bs=a(),It=n("p"),It.textContent=Da,Ws=a(),M(G.$$.fragment),vs=a(),Ct=n("p"),Ct.innerHTML=Ka,_s=a(),x=n("p"),x.innerHTML=Oa,Gs=a(),M(Zt.$$.fragment),xs=a(),_t=n("p"),this.h()},l(e){const t=Mi("svelte-u9bgzb",document.head);r=p(t,"META",{name:!0,content:!0}),t.forEach(l),T=i(e),f=p(e,"P",{}),ii(f).forEach(l),w=i(e),m(g.$$.fragment,e),C=i(e),j=p(e,"A",{target:!0,href:!0,"data-svelte-h":!0}),o(j)!=="svelte-1fn2wis"&&(j.innerHTML=vt),Z=i(e),m(U.$$.fragment,e),k=i(e),y=p(e,"P",{"data-svelte-h":!0}),o(y)!=="svelte-z81vpv"&&(y.innerHTML=I),kt=i(e),X=p(e,"P",{"data-svelte-h":!0}),o(X)!=="svelte-14o42r"&&(X.textContent=Xs),Xt=i(e),V=p(e,"P",{"data-svelte-h":!0}),o(V)!=="svelte-tqblgl"&&(V.innerHTML=Vs),Vt=i(e),R=p(e,"P",{"data-svelte-h":!0}),o(R)!=="svelte-1on511i"&&(R.innerHTML=Rs),Rt=i(e),m(H.$$.fragment,e),Ht=i(e),F=p(e,"P",{"data-svelte-h":!0}),o(F)!=="svelte-cqau2t"&&(F.textContent=Hs),Ft=i(e),$=p(e,"UL",{"data-svelte-h":!0}),o($)!=="svelte-1izcxm8"&&($.innerHTML=Fs),$t=i(e),m(N.$$.fragment,e),Nt=i(e),E=p(e,"P",{"data-svelte-h":!0}),o(E)!=="svelte-cad463"&&(E.innerHTML=$s),Et=i(e),Y=p(e,"P",{"data-svelte-h":!0}),o(Y)!=="svelte-15hirvk"&&(Y.innerHTML=Ns),Yt=i(e),Q=p(e,"BLOCKQUOTE",{"data-svelte-h":!0}),o(Q)!=="svelte-191e550"&&(Q.innerHTML=Es),Qt=i(e),A=p(e,"P",{"data-svelte-h":!0}),o(A)!=="svelte-19xz367"&&(A.innerHTML=Ys),At=i(e),z=p(e,"P",{"data-svelte-h":!0}),o(z)!=="svelte-76ujpq"&&(z.textContent=Qs),zt=i(e),S=p(e,"UL",{"data-svelte-h":!0}),o(S)!=="svelte-umnjz5"&&(S.innerHTML=As),St=i(e),L=p(e,"P",{"data-svelte-h":!0}),o(L)!=="svelte-ybl15o"&&(L.textContent=zs),Lt=i(e),P=p(e,"P",{"data-svelte-h":!0}),o(P)!=="svelte-f7spg1"&&(P.innerHTML=Ss),Pt=i(e),q=p(e,"UL",{"data-svelte-h":!0}),o(q)!=="svelte-18glkk1"&&(q.innerHTML=Ls),qt=i(e),D=p(e,"P",{"data-svelte-h":!0}),o(D)!=="svelte-e5mnz8"&&(D.innerHTML=Ps),Dt=i(e),K=p(e,"P",{"data-svelte-h":!0}),o(K)!=="svelte-304bv6"&&(K.innerHTML=qs),Kt=i(e),m(O.$$.fragment,e),Ot=i(e),ee=p(e,"P",{"data-svelte-h":!0}),o(ee)!=="svelte-tpmlzv"&&(ee.innerHTML=Ds),el=i(e),m(te.$$.fragment,e),tl=i(e),le=p(e,"P",{"data-svelte-h":!0}),o(le)!=="svelte-4i7yd5"&&(le.innerHTML=Ks),ll=i(e),se=p(e,"P",{"data-svelte-h":!0}),o(se)!=="svelte-a4b9f"&&(se.innerHTML=Os),sl=i(e),ae=p(e,"P",{"data-svelte-h":!0}),o(ae)!=="svelte-gipltn"&&(ae.innerHTML=ea),al=i(e),ie=p(e,"P",{"data-svelte-h":!0}),o(ie)!=="svelte-1vqr9z3"&&(ie.textContent=ta),il=i(e),m(B.$$.fragment,e),nl=i(e),m(ne.$$.fragment,e),pl=i(e),pe=p(e,"P",{"data-svelte-h":!0}),o(pe)!=="svelte-6557l0"&&(pe.textContent=la),ol=i(e),oe=p(e,"UL",{"data-svelte-h":!0}),o(oe)!=="svelte-dg8xrl"&&(oe.innerHTML=sa),rl=i(e),m(re.$$.fragment,e),Ml=i(e),Me=p(e,"P",{"data-svelte-h":!0}),o(Me)!=="svelte-1i7u4ia"&&(Me.innerHTML=aa),ml=i(e),me=p(e,"P",{"data-svelte-h":!0}),o(me)!=="svelte-7rr7b3"&&(me.innerHTML=ia),cl=i(e),m(ce.$$.fragment,e),dl=i(e),de=p(e,"P",{"data-svelte-h":!0}),o(de)!=="svelte-6rdsa0"&&(de.textContent=na),ul=i(e),m(ue.$$.fragment,e),hl=i(e),he=p(e,"P",{"data-svelte-h":!0}),o(he)!=="svelte-1iembt3"&&(he.textContent=pa),fl=i(e),m(fe.$$.fragment,e),yl=i(e),ye=p(e,"P",{"data-svelte-h":!0}),o(ye)!=="svelte-1a3tn0d"&&(ye.textContent=oa),Jl=i(e),Je=p(e,"P",{"data-svelte-h":!0}),o(Je)!=="svelte-1ibhx6s"&&(Je.innerHTML=ra),wl=i(e),m(we.$$.fragment,e),Tl=i(e),Te=p(e,"P",{"data-svelte-h":!0}),o(Te)!=="svelte-1uab86h"&&(Te.innerHTML=Ma),jl=i(e),m(je.$$.fragment,e),Ul=i(e),Ue=p(e,"P",{"data-svelte-h":!0}),o(Ue)!=="svelte-ni3sdy"&&(Ue.textContent=ma),bl=i(e),m(be.$$.fragment,e),gl=i(e),ge=p(e,"P",{"data-svelte-h":!0}),o(ge)!=="svelte-1kq1w3v"&&(ge.innerHTML=ca),Il=i(e),m(W.$$.fragment,e),Cl=i(e),m(Ie.$$.fragment,e),Zl=i(e),Ce=p(e,"P",{"data-svelte-h":!0}),o(Ce)!=="svelte-18ubjo5"&&(Ce.innerHTML=da),Bl=i(e),Ze=p(e,"P",{"data-svelte-h":!0}),o(Ze)!=="svelte-r4qmx2"&&(Ze.textContent=ua),Wl=i(e),Be=p(e,"P",{"data-svelte-h":!0}),o(Be)!=="svelte-tnn31f"&&(Be.innerHTML=ha),vl=i(e),We=p(e,"P",{"data-svelte-h":!0}),o(We)!=="svelte-lwbe5g"&&(We.innerHTML=fa),_l=i(e),ve=p(e,"UL",{"data-svelte-h":!0}),o(ve)!=="svelte-yda35x"&&(ve.innerHTML=ya),Gl=i(e),_e=p(e,"P",{"data-svelte-h":!0}),o(_e)!=="svelte-1bn7xvw"&&(_e.textContent=Ja),xl=i(e),Ge=p(e,"P",{"data-svelte-h":!0}),o(Ge)!=="svelte-fs1abj"&&(Ge.innerHTML=wa),kl=i(e),xe=p(e,"P",{"data-svelte-h":!0}),o(xe)!=="svelte-1t03m2p"&&(xe.textContent=Ta),Xl=i(e),m(ke.$$.fragment,e),Vl=i(e),m(Xe.$$.fragment,e),Rl=i(e),Ve=p(e,"P",{"data-svelte-h":!0}),o(Ve)!=="svelte-1q1xt9i"&&(Ve.textContent=ja),Hl=i(e),Re=p(e,"UL",{"data-svelte-h":!0}),o(Re)!=="svelte-mhcjab"&&(Re.innerHTML=Ua),Fl=i(e),He=p(e,"P",{"data-svelte-h":!0}),o(He)!=="svelte-9q1iss"&&(He.textContent=ba),$l=i(e),m(Fe.$$.fragment,e),Nl=i(e),m($e.$$.fragment,e),El=i(e),Ne=p(e,"P",{"data-svelte-h":!0}),o(Ne)!=="svelte-5rwzaj"&&(Ne.textContent=ga),Yl=i(e),m(Ee.$$.fragment,e),Ql=i(e),Ye=p(e,"P",{"data-svelte-h":!0}),o(Ye)!=="svelte-1r4pb3b"&&(Ye.innerHTML=Ia),Al=i(e),Qe=p(e,"P",{"data-svelte-h":!0}),o(Qe)!=="svelte-1n3s9hn"&&(Qe.textContent=Ca),zl=i(e),Ae=p(e,"P",{"data-svelte-h":!0}),o(Ae)!=="svelte-ss3jc3"&&(Ae.innerHTML=Za),Sl=i(e),m(ze.$$.fragment,e),Ll=i(e),Se=p(e,"P",{"data-svelte-h":!0}),o(Se)!=="svelte-pfw8ud"&&(Se.textContent=Ba),Pl=i(e),m(Le.$$.fragment,e),ql=i(e),Pe=p(e,"P",{"data-svelte-h":!0}),o(Pe)!=="svelte-1nzzrqn"&&(Pe.textContent=Wa),Dl=i(e),m(qe.$$.fragment,e),Kl=i(e),De=p(e,"P",{"data-svelte-h":!0}),o(De)!=="svelte-1c659ih"&&(De.innerHTML=va),Ol=i(e),Ke=p(e,"P",{"data-svelte-h":!0}),o(Ke)!=="svelte-k3cp0u"&&(Ke.innerHTML=_a),es=i(e),m(Oe.$$.fragment,e),ts=i(e),et=p(e,"P",{"data-svelte-h":!0}),o(et)!=="svelte-1tdcjay"&&(et.innerHTML=Ga),ls=i(e),m(tt.$$.fragment,e),ss=i(e),lt=p(e,"P",{"data-svelte-h":!0}),o(lt)!=="svelte-14mrga2"&&(lt.textContent=xa),as=i(e),st=p(e,"P",{"data-svelte-h":!0}),o(st)!=="svelte-vck7qn"&&(st.innerHTML=ka),is=i(e),at=p(e,"P",{"data-svelte-h":!0}),o(at)!=="svelte-nbfdj7"&&(at.innerHTML=Xa),ns=i(e),it=p(e,"P",{"data-svelte-h":!0}),o(it)!=="svelte-9ga2iu"&&(it.innerHTML=Va),ps=i(e),m(v.$$.fragment,e),os=i(e),nt=p(e,"P",{"data-svelte-h":!0}),o(nt)!=="svelte-7qwtg3"&&(nt.innerHTML=Ra),rs=i(e),pt=p(e,"P",{"data-svelte-h":!0}),o(pt)!=="svelte-hcc15s"&&(pt.innerHTML=Ha),Ms=i(e),m(ot.$$.fragment,e),ms=i(e),rt=p(e,"P",{"data-svelte-h":!0}),o(rt)!=="svelte-1tzk2c3"&&(rt.innerHTML=Fa),cs=i(e),Mt=p(e,"P",{"data-svelte-h":!0}),o(Mt)!=="svelte-1rk18fl"&&(Mt.innerHTML=$a),ds=i(e),mt=p(e,"BLOCKQUOTE",{"data-svelte-h":!0}),o(mt)!=="svelte-7e4j74"&&(mt.innerHTML=Na),us=i(e),ct=p(e,"P",{"data-svelte-h":!0}),o(ct)!=="svelte-simh2d"&&(ct.textContent=Ea),hs=i(e),dt=p(e,"P",{"data-svelte-h":!0}),o(dt)!=="svelte-1h659dy"&&(dt.textContent=Ya),fs=i(e),m(ut.$$.fragment,e),ys=i(e),m(ht.$$.fragment,e),Js=i(e),ft=p(e,"P",{"data-svelte-h":!0}),o(ft)!=="svelte-1jd4ltz"&&(ft.textContent=Qa),ws=i(e),_=p(e,"P",{align:!0,"data-svelte-h":!0}),o(_)!=="svelte-94lw7t"&&(_.innerHTML=Aa),Ts=i(e),yt=p(e,"P",{"data-svelte-h":!0}),o(yt)!=="svelte-iw90qp"&&(yt.textContent=za),js=i(e),m(Jt.$$.fragment,e),Us=i(e),wt=p(e,"P",{"data-svelte-h":!0}),o(wt)!=="svelte-a40j2v"&&(wt.innerHTML=Sa),bs=i(e),m(Tt.$$.fragment,e),gs=i(e),jt=p(e,"P",{"data-svelte-h":!0}),o(jt)!=="svelte-1nlt7gv"&&(jt.innerHTML=La),Is=i(e),m(Ut.$$.fragment,e),Cs=i(e),bt=p(e,"P",{"data-svelte-h":!0}),o(bt)!=="svelte-17lmdw3"&&(bt.textContent=Pa),Zs=i(e),gt=p(e,"UL",{"data-svelte-h":!0}),o(gt)!=="svelte-16n90lm"&&(gt.innerHTML=qa),Bs=i(e),It=p(e,"P",{"data-svelte-h":!0}),o(It)!=="svelte-1evgdla"&&(It.textContent=Da),Ws=i(e),m(G.$$.fragment,e),vs=i(e),Ct=p(e,"P",{"data-svelte-h":!0}),o(Ct)!=="svelte-ptrlon"&&(Ct.innerHTML=Ka),_s=i(e),x=p(e,"P",{align:!0,"data-svelte-h":!0}),o(x)!=="svelte-16e5oh4"&&(x.innerHTML=Oa),Gs=i(e),m(Zt.$$.fragment,e),xs=i(e),_t=p(e,"P",{}),ii(_t).forEach(l),this.h()},h(){Wt(r,"name","hf:doc:metadata"),Wt(r,"content",wi),Wt(j,"target","_blank"),Wt(j,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/evaluation.ipynb"),Wt(_,"align","center"),Wt(x,"align","center")},m(e,t){mi(document.head,r),s(e,T,t),s(e,f,t),s(e,w,t),c(g,e,t),s(e,C,t),s(e,j,t),s(e,Z,t),c(U,e,t),s(e,k,t),s(e,y,t),s(e,kt,t),s(e,X,t),s(e,Xt,t),s(e,V,t),s(e,Vt,t),s(e,R,t),s(e,Rt,t),c(H,e,t),s(e,Ht,t),s(e,F,t),s(e,Ft,t),s(e,$,t),s(e,$t,t),c(N,e,t),s(e,Nt,t),s(e,E,t),s(e,Et,t),s(e,Y,t),s(e,Yt,t),s(e,Q,t),s(e,Qt,t),s(e,A,t),s(e,At,t),s(e,z,t),s(e,zt,t),s(e,S,t),s(e,St,t),s(e,L,t),s(e,Lt,t),s(e,P,t),s(e,Pt,t),s(e,q,t),s(e,qt,t),s(e,D,t),s(e,Dt,t),s(e,K,t),s(e,Kt,t),c(O,e,t),s(e,Ot,t),s(e,ee,t),s(e,el,t),c(te,e,t),s(e,tl,t),s(e,le,t),s(e,ll,t),s(e,se,t),s(e,sl,t),s(e,ae,t),s(e,al,t),s(e,ie,t),s(e,il,t),c(B,e,t),s(e,nl,t),c(ne,e,t),s(e,pl,t),s(e,pe,t),s(e,ol,t),s(e,oe,t),s(e,rl,t),c(re,e,t),s(e,Ml,t),s(e,Me,t),s(e,ml,t),s(e,me,t),s(e,cl,t),c(ce,e,t),s(e,dl,t),s(e,de,t),s(e,ul,t),c(ue,e,t),s(e,hl,t),s(e,he,t),s(e,fl,t),c(fe,e,t),s(e,yl,t),s(e,ye,t),s(e,Jl,t),s(e,Je,t),s(e,wl,t),c(we,e,t),s(e,Tl,t),s(e,Te,t),s(e,jl,t),c(je,e,t),s(e,Ul,t),s(e,Ue,t),s(e,bl,t),c(be,e,t),s(e,gl,t),s(e,ge,t),s(e,Il,t),c(W,e,t),s(e,Cl,t),c(Ie,e,t),s(e,Zl,t),s(e,Ce,t),s(e,Bl,t),s(e,Ze,t),s(e,Wl,t),s(e,Be,t),s(e,vl,t),s(e,We,t),s(e,_l,t),s(e,ve,t),s(e,Gl,t),s(e,_e,t),s(e,xl,t),s(e,Ge,t),s(e,kl,t),s(e,xe,t),s(e,Xl,t),c(ke,e,t),s(e,Vl,t),c(Xe,e,t),s(e,Rl,t),s(e,Ve,t),s(e,Hl,t),s(e,Re,t),s(e,Fl,t),s(e,He,t),s(e,$l,t),c(Fe,e,t),s(e,Nl,t),c($e,e,t),s(e,El,t),s(e,Ne,t),s(e,Yl,t),c(Ee,e,t),s(e,Ql,t),s(e,Ye,t),s(e,Al,t),s(e,Qe,t),s(e,zl,t),s(e,Ae,t),s(e,Sl,t),c(ze,e,t),s(e,Ll,t),s(e,Se,t),s(e,Pl,t),c(Le,e,t),s(e,ql,t),s(e,Pe,t),s(e,Dl,t),c(qe,e,t),s(e,Kl,t),s(e,De,t),s(e,Ol,t),s(e,Ke,t),s(e,es,t),c(Oe,e,t),s(e,ts,t),s(e,et,t),s(e,ls,t),c(tt,e,t),s(e,ss,t),s(e,lt,t),s(e,as,t),s(e,st,t),s(e,is,t),s(e,at,t),s(e,ns,t),s(e,it,t),s(e,ps,t),c(v,e,t),s(e,os,t),s(e,nt,t),s(e,rs,t),s(e,pt,t),s(e,Ms,t),c(ot,e,t),s(e,ms,t),s(e,rt,t),s(e,cs,t),s(e,Mt,t),s(e,ds,t),s(e,mt,t),s(e,us,t),s(e,ct,t),s(e,hs,t),s(e,dt,t),s(e,fs,t),c(ut,e,t),s(e,ys,t),c(ht,e,t),s(e,Js,t),s(e,ft,t),s(e,ws,t),s(e,_,t),s(e,Ts,t),s(e,yt,t),s(e,js,t),c(Jt,e,t),s(e,Us,t),s(e,wt,t),s(e,bs,t),c(Tt,e,t),s(e,gs,t),s(e,jt,t),s(e,Is,t),c(Ut,e,t),s(e,Cs,t),s(e,bt,t),s(e,Zs,t),s(e,gt,t),s(e,Bs,t),s(e,It,t),s(e,Ws,t),c(G,e,t),s(e,vs,t),s(e,Ct,t),s(e,_s,t),s(e,x,t),s(e,Gs,t),c(Zt,e,t),s(e,xs,t),s(e,_t,t),ks=!0},p(e,[t]){const ei={};t&2&&(ei.$$scope={dirty:t,ctx:e}),U.$set(ei);const ti={};t&2&&(ti.$$scope={dirty:t,ctx:e}),B.$set(ti);const li={};t&2&&(li.$$scope={dirty:t,ctx:e}),W.$set(li);const si={};t&2&&(si.$$scope={dirty:t,ctx:e}),v.$set(si);const ai={};t&2&&(ai.$$scope={dirty:t,ctx:e}),G.$set(ai)},i(e){ks||(d(g.$$.fragment,e),d(U.$$.fragment,e),d(H.$$.fragment,e),d(N.$$.fragment,e),d(O.$$.fragment,e),d(te.$$.fragment,e),d(B.$$.fragment,e),d(ne.$$.fragment,e),d(re.$$.fragment,e),d(ce.$$.fragment,e),d(ue.$$.fragment,e),d(fe.$$.fragment,e),d(we.$$.fragment,e),d(je.$$.fragment,e),d(be.$$.fragment,e),d(W.$$.fragment,e),d(Ie.$$.fragment,e),d(ke.$$.fragment,e),d(Xe.$$.fragment,e),d(Fe.$$.fragment,e),d($e.$$.fragment,e),d(Ee.$$.fragment,e),d(ze.$$.fragment,e),d(Le.$$.fragment,e),d(qe.$$.fragment,e),d(Oe.$$.fragment,e),d(tt.$$.fragment,e),d(v.$$.fragment,e),d(ot.$$.fragment,e),d(ut.$$.fragment,e),d(ht.$$.fragment,e),d(Jt.$$.fragment,e),d(Tt.$$.fragment,e),d(Ut.$$.fragment,e),d(G.$$.fragment,e),d(Zt.$$.fragment,e),ks=!0)},o(e){u(g.$$.fragment,e),u(U.$$.fragment,e),u(H.$$.fragment,e),u(N.$$.fragment,e),u(O.$$.fragment,e),u(te.$$.fragment,e),u(B.$$.fragment,e),u(ne.$$.fragment,e),u(re.$$.fragment,e),u(ce.$$.fragment,e),u(ue.$$.fragment,e),u(fe.$$.fragment,e),u(we.$$.fragment,e),u(je.$$.fragment,e),u(be.$$.fragment,e),u(W.$$.fragment,e),u(Ie.$$.fragment,e),u(ke.$$.fragment,e),u(Xe.$$.fragment,e),u(Fe.$$.fragment,e),u($e.$$.fragment,e),u(Ee.$$.fragment,e),u(ze.$$.fragment,e),u(Le.$$.fragment,e),u(qe.$$.fragment,e),u(Oe.$$.fragment,e),u(tt.$$.fragment,e),u(v.$$.fragment,e),u(ot.$$.fragment,e),u(ut.$$.fragment,e),u(ht.$$.fragment,e),u(Jt.$$.fragment,e),u(Tt.$$.fragment,e),u(Ut.$$.fragment,e),u(G.$$.fragment,e),u(Zt.$$.fragment,e),ks=!1},d(e){e&&(l(T),l(f),l(w),l(C),l(j),l(Z),l(k),l(y),l(kt),l(X),l(Xt),l(V),l(Vt),l(R),l(Rt),l(Ht),l(F),l(Ft),l($),l($t),l(Nt),l(E),l(Et),l(Y),l(Yt),l(Q),l(Qt),l(A),l(At),l(z),l(zt),l(S),l(St),l(L),l(Lt),l(P),l(Pt),l(q),l(qt),l(D),l(Dt),l(K),l(Kt),l(Ot),l(ee),l(el),l(tl),l(le),l(ll),l(se),l(sl),l(ae),l(al),l(ie),l(il),l(nl),l(pl),l(pe),l(ol),l(oe),l(rl),l(Ml),l(Me),l(ml),l(me),l(cl),l(dl),l(de),l(ul),l(hl),l(he),l(fl),l(yl),l(ye),l(Jl),l(Je),l(wl),l(Tl),l(Te),l(jl),l(Ul),l(Ue),l(bl),l(gl),l(ge),l(Il),l(Cl),l(Zl),l(Ce),l(Bl),l(Ze),l(Wl),l(Be),l(vl),l(We),l(_l),l(ve),l(Gl),l(_e),l(xl),l(Ge),l(kl),l(xe),l(Xl),l(Vl),l(Rl),l(Ve),l(Hl),l(Re),l(Fl),l(He),l($l),l(Nl),l(El),l(Ne),l(Yl),l(Ql),l(Ye),l(Al),l(Qe),l(zl),l(Ae),l(Sl),l(Ll),l(Se),l(Pl),l(ql),l(Pe),l(Dl),l(Kl),l(De),l(Ol),l(Ke),l(es),l(ts),l(et),l(ls),l(ss),l(lt),l(as),l(st),l(is),l(at),l(ns),l(it),l(ps),l(os),l(nt),l(rs),l(pt),l(Ms),l(ms),l(rt),l(cs),l(Mt),l(ds),l(mt),l(us),l(ct),l(hs),l(dt),l(fs),l(ys),l(Js),l(ft),l(ws),l(_),l(Ts),l(yt),l(js),l(Us),l(wt),l(bs),l(gs),l(jt),l(Is),l(Cs),l(bt),l(Zs),l(gt),l(Bs),l(It),l(Ws),l(vs),l(Ct),l(_s),l(x),l(Gs),l(xs),l(_t)),l(r),h(g,e),h(U,e),h(H,e),h(N,e),h(O,e),h(te,e),h(B,e),h(ne,e),h(re,e),h(ce,e),h(ue,e),h(fe,e),h(we,e),h(je,e),h(be,e),h(W,e),h(Ie,e),h(ke,e),h(Xe,e),h(Fe,e),h($e,e),h(Ee,e),h(ze,e),h(Le,e),h(qe,e),h(Oe,e),h(tt,e),h(v,e),h(ot,e),h(ut,e),h(ht,e),h(Jt,e),h(Tt,e),h(Ut,e),h(G,e),h(Zt,e)}}}const wi='{"title":"Evaluating Diffusion Models","local":"evaluating-diffusion-models","sections":[{"title":"Scenarios","local":"scenarios","sections":[],"depth":2},{"title":"Qualitative Evaluation","local":"qualitative-evaluation","sections":[],"depth":2},{"title":"Quantitative Evaluation","local":"quantitative-evaluation","sections":[{"title":"Text-guided image generation","local":"text-guided-image-generation","sections":[],"depth":3},{"title":"Image-conditioned text-to-image generation","local":"image-conditioned-text-to-image-generation","sections":[],"depth":3},{"title":"Class-conditioned image generation","local":"class-conditioned-image-generation","sections":[],"depth":3}],"depth":2}],"depth":1}';function Ti(b){return pi(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ci extends oi{constructor(r){super(),ri(this,r,Ti,Ji,ni,{})}}export{Ci as component};
