0% found this document useful (0 votes)
13 views

kaist_cs492d_fall_2024_assignment_1

The document outlines Assignment 1 for the CS492D course on Diffusion Models, focusing on implementing key components of Denoising Diffusion Probabilistic Models (DDPMs). Students are required to complete two tasks involving modeling and image generation, with specific programming functions to implement and deadlines for submission. Grading criteria are provided, with points awarded based on performance metrics such as Chamfer Distance and FID scores.

Uploaded by

raphaelvon28
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

kaist_cs492d_fall_2024_assignment_1

The document outlines Assignment 1 for the CS492D course on Diffusion Models, focusing on implementing key components of Denoising Diffusion Probabilistic Models (DDPMs). Students are required to complete two tasks involving modeling and image generation, with specific programming functions to implement and deadlines for submission. Grading criteria are provided, with points awarded based on performance metrics such as Chamfer Distance and FID scores.

Uploaded by

raphaelvon28
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

CS492D: Diffusion Models and Their

Applications
Assignment 1 Session

SEUNGWOO YOO

Fall 2024
KAIST

CS492(D): Diffusion Models and Their Applications (Fall 2024)


Introduction
In Assignment 1, you will implement the key components of
Denoising Diffusion Probabilistic Models (DDPMs).

Denoising Diffusion Probabilistic Models, Ho et al., NeurIPS 2020

CS492(D): Diffusion Models and Their Applications (Fall 2024) 2


Introduction
The skeleton code and instructions are available at:
https://github.com/KAIST-Visual-AI-Group/Diffusion-Assignment1-DDPM

CS492(D): Diffusion Models and Their Applications (Fall 2024) 3


Introduction
• All programming assignments are due two weeks after the assignment
session.

• Late submission will incur 20% penalty for each late day!

• Please carefully check the README of each assignment.

CS492(D): Diffusion Models and Their Applications (Fall 2024) 4


What to Do: Overview
You need to implement three major components of DDPMs:

• Forward Process: 𝑞(𝒙! |𝒙" )

• Reverse Process: 𝑝# (𝒙!$% |𝒙! )

'
• Training Objective: 𝝐 − 𝝐𝜽 (𝒙! , 𝑡)

Is it really that simple…?

CS492(D): Diffusion Models and Their Applications (Fall 2024) 5


What to Do: Overview
Yes! Even cutting-edge diffusion models are built this way.

By understanding this basic structure, you can begin exploring more


advanced models.

Diffusers, HuggingFace Stable Diffusion 3, StabilityAI

CS492(D): Diffusion Models and Their Applications (Fall 2024) 6


What to Do: Task 1
Let’s begin by modeling a simple distribution of 2D points (“Swiss Roll”).

CS492(D): Diffusion Models and Their Applications (Fall 2024) 7


What to Do: Task 1
Design a network that takes

• Noisy data 𝒙! ;

• Current diffusion timestep 𝑡.

Hint: Use the TimeLinear class.

2d_plot_diffusion_todo/network.py

CS492(D): Diffusion Models and Their Applications (Fall 2024) 8


What to Do: Task 1
Implement functions

• q_sample;

• p_sample;

• p_sample_loop;

• compute_loss.
2d_plot_diffusion_todo/ddpm.py

CS492(D): Diffusion Models and Their Applications (Fall 2024) 9


What to Do: Task 1
Check your implementation of q_sample!

2d_plot_diffusion_todo/ddpm_tutorial.ipynb

CS492(D): Diffusion Models and Their Applications (Fall 2024) 10


What to Do: Task 1
Implement functions

• q_sample;

• p_sample;

• p_sample_loop;

• compute_loss.
2d_plot_diffusion_todo/ddpm.py

CS492(D): Diffusion Models and Their Applications (Fall 2024) 11


What to Do: Task 1
Implement functions

• q_sample;

• p_sample;

• p_sample_loop;

• compute_loss.
2d_plot_diffusion_todo/ddpm.py

CS492(D): Diffusion Models and Their Applications (Fall 2024) 12


What to Do: Task 1
Implement functions

• q_sample;

• p_sample;

• p_sample_loop;

• compute_loss.
2d_plot_diffusion_todo/ddpm.py

CS492(D): Diffusion Models and Their Applications (Fall 2024) 13


What to Do: Task 1
Train your model and observe how the generated samples and the loss
curve evolve over time.

CS492(D): Diffusion Models and Their Applications (Fall 2024) 14


What to Do: Task 2
We will now move on to a more interesting example: image generation.

Samples from our model trained using the AFHQ dataset.

CS492(D): Diffusion Models and Their Applications (Fall 2024) 15


What to Do: Task 2 Ugh…
Time to write more code…

Samples from our model trained using the AFHQ dataset.

CS492(D): Diffusion Models and Their Applications (Fall 2024) 16


What to Do: Task 2
Bring your codes from Task 1!

The code needs to be modified, but the changes should be kept minimal.

• q_sample à add_noise;

• p_sample à step;

• compute_loss à get_loss.

CS492(D): Diffusion Models and Their Applications (Fall 2024) 17


What to Do: Task 2

2d_plot_diffusion_todo/ddpm.py image_diffusion_todo/scheduler.py

CS492(D): Diffusion Models and Their Applications (Fall 2024) 18


What to Do: Task 2

2d_plot_diffusion_todo/ddpm.py image_diffusion_todo/scheduler.py

CS492(D): Diffusion Models and Their Applications (Fall 2024) 19


What to Do: Task 2

2d_plot_diffusion_todo/ddpm.py image_diffusion_todo/scheduler.py

CS492(D): Diffusion Models and Their Applications (Fall 2024) 20


What to Do: Task 2
After implementing the functions, start training the model by running

python train.py

The results will be saved under results directory.

Step 0 Step 1K Step 25K Step 50K Step 100K


Images logged during training.

CS492(D): Diffusion Models and Their Applications (Fall 2024) 21


What to Do: Task 2
Generate the images using the trained model by running

python sampling.py \

--ckpt_path {CKPT} --save_dir {SAVE}

CS492(D): Diffusion Models and Their Applications (Fall 2024) 22


What to Do: Task 2
Generate the images using the trained model by running

python sampling.py \

--ckpt_path {CKPT} --save_dir {SAVE}

Samples generated using our model.

CS492(D): Diffusion Models and Their Applications (Fall 2024) 23


What to Do: Task 2
Prepare the data for evaluation by running

python dataset.py (Only once!)

This will create the eval directory under data/afhq.

Do NOT forget to run this. Otherwise, you will get incorrect FIDs!

😱 FID scores across different test sets using the same generated samples.
🤩
CS492(D): Diffusion Models and Their Applications (Fall 2024) 24
What to Submit
Compile the following items into a PDF file: {NAME}_{ID}.pdf.
Task 1
• A screenshot of the loss curve;
• A screenshot of the Chamfer Distance;
• A visualization of samples generated using your DDPM.
Task 2
• A screenshot of the computed FID;
• At least 8 images generated using your DDPM.

CS492(D): Diffusion Models and Their Applications (Fall 2024) 25


What to Submit
Create a single ZIP file {NAME}_{ID}.zip including:

• The PDF file formatted following the guideline;

• Your code without checkpoints for DDPMs and the Inception Network

Your score will be deducted by 10% for each missing item.


Please check carefully!

CS492(D): Diffusion Models and Their Applications (Fall 2024) 26


Grading
You will receive up to 20 points from this assignment.

Task 1

• 10 points: Achieve CD lower than 20.

• 5 points: Achieve CD greater, or equal to 20 and less than 40.

• 0 point: Otherwise.

CS492(D): Diffusion Models and Their Applications (Fall 2024) 27


Grading
You will receive up to 20 points from this assignment.

Task 2

• 10 points: Achieve FID lower than 20.

• 5 points: Achieve FID greater, or equal to 20 and less than 40.

• 0 point: Otherwise.

CS492(D): Diffusion Models and Their Applications (Fall 2024) 28


Demo

CS492(D): Diffusion Models and Their Applications (Fall 2024) 29


Thank You

CS492(D): Diffusion Models and Their Applications (Fall 2024) 30

You might also like