-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added working conditional MNIST generation notebook.
- Loading branch information
Showing
10 changed files
with
301 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/venv | ||
docs/.DS_Store | ||
docs/.DS_Store | ||
diffusion-models/notebooks/mnist_data/ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
torch==2.3.0 | ||
torchvision==0.18.0 | ||
matplotlib==3.9.0 | ||
seaborn==0.13.2 | ||
seaborn==0.13.2 | ||
diffusers==0.28.2 | ||
transformers==4.41.2 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
In this section we will introduce a core component of the Diffusers library `UNet2DModel`. This page will closely follow the notebook `hf_diffusers_mnist.ipynb`, so if you're interested in a quick run through and want to play around yourself, then check that out. Here, we will go through the code in more detail and explain the different components of the model, but feel free to refer back to this page. | ||
|
||
|
||
|
||
## `UNet2DModel` | ||
The `UNet2DModel` is a 2D U-Net model that is used for image generation. It abstracts out all of the annoying details of building the model, and allows you to focus on the important parts of your project. | ||
|
||
|
||
``` python | ||
model = UNet2DModel( | ||
sample_size=28, # (1) | ||
in_channels=1, # (2) | ||
out_channels=1, # (3) | ||
layers_per_block=1, # (4) | ||
block_out_channels=(8, 16, 32), # (5) | ||
down_block_types=( | ||
"DownBlock2D", | ||
"DownBlock2D", | ||
"DownBlock2D", | ||
), | ||
up_block_types=( | ||
"UpBlock2D", | ||
"UpBlock2D", | ||
"UpBlock2D", | ||
), | ||
num_class_embeds=10, # (6) | ||
norm_num_groups=1, # (7) | ||
) | ||
``` | ||
|
||
1. The size of the input image. In this case, it is 28x28 pixels | ||
2. The number of channels in the input image. In this case, it is 1, as the images are grayscale, but you would use 3 for RGB images | ||
3. The number of channels in the output image. In this case, it is 1, as the images are grayscale, but you would use 3 for RGB images | ||
4. The number of layers in each block | ||
5. The number of output channels in each block - in a convolutional neural network, the number of channels is the number of filters that are applied to the input image. | ||
6. The number of classes your dataset has if you are doing conditional generation. | ||
7. The number of groups to use for the normalization layer. This is a hyperparameter that you can tune to improve the performance of your model. | ||
|
||
There are a number of additional parameters, but these are the most important ones to understand when you are getting started with the `UNet2DModel`. Let's look at the block types in more detail, and some of the additional paramters | ||
|
||
## Further reading | ||
<div class="grid cards" markdown> | ||
|
||
- :fontawesome-solid-book-open:{ .lg .middle } [__CI/CD - Pre-commit resources__](../resources/references.md#pre-commit) | ||
|
||
--- | ||
Information on GitHub Actions, Black, Flake8, Mypy, Isort, and Git Hooks | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Hugging Face Diffusers | ||
In this section, we make life easy for ourselves and use the Hugging Face Diffusers Library. We will look at two main tasks: image generation and ECG generation. We will start with image generation, and in doing so, we'll walk through most of the building blocks required to understand the second task. | ||
|
||
Let's get started! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters