meadbee's picture
Update README.md
1a997d0 verified
|
Raw History Blame Contribute Delete
5.59 kB
---
library_name: diffusers
pipeline_tag: text-to-image
tags:
- diffusion
- anime
- from-scratch
- portfolio
- custom-pipeline
- safetensors
language:
- en
---
## Training progress video
<video controls playsinline preload="metadata" width="450" src="https://huggingface.co/meadbee/yshtola-from-scratch-diffusion/resolve/main/assets/training-progress.mp4"></video>
[Download the training progress video](assets/training-progress.mp4).
# Yshtola Diffusion
**Learning diffusion from scratch on a single RTX 3090.**
I built this project to understand how diffusion models learn and to explore what an individual could train at home on their own GPU. Over the course of one week, I trained a text-conditioned diffusion UNet from scratch using a dataset of more than one million anime images. The denoising UNet was trained entirely from randomly initialized weights on a consumer GPU, using frozen pretrained CLIP and VAE components.
This page documents that process: the early outputs, the improvements over time, and the lessons I learned along the way.
| Project | Details |
| --- | --- |
| Hardware | One NVIDIA GeForce RTX 3090 |
| Training duration | Approximately one week |
| Dataset size | 1 million+ images |
| Training approach | UNet trained from scratch with frozen pretrained CLIP and VAE components |
| Tools | Python, PyTorch, Hugging Face Diffusers, Transformers |
| Current checkpoint | 512 FINAL, EMA weights |
## From noise to recognizable images
The following images are snapshots of the project's progression. The elapsed times are approximate. Training and sampling choices evolved during the week, so the images reflect both the model's development and what I was learning about generating samples.
### 1 hour: the starting point
![Model outputs after approximately one hour of training](assets/sample-01.png)
The first samples were mostly fragmented colors and textures. This was the starting point for watching a randomly initialized UNet learn to denoise images.
### 12 hours: recognizable structure begins to emerge
![Model outputs after approximately twelve hours of training](assets/sample-02.png)
Faces, hair, and larger areas of color started to become recognizable, even though the images were still heavily distorted.
### 3 days: more coherent characters and composition
![Model outputs after approximately three days of training](assets/sample-03.png)
By this point, the outputs showed more coherent poses, clothing, and overall composition. The improvement was visible, while texture artifacts and inconsistent details remained.
### 5 days: learning how much samplers matter
![Model output after approximately five days of training](assets/sample-04.png)
Around this stage, I started learning about samplers and how dramatically they can affect the final image. Choosing how to turn the model's noise predictions into an image became an important part of the project.
That changed how I evaluated progress: I needed to understand both the trained model and the sampling process to make sense of the results I was seeing.
### 1 week: current results
![Current model outputs after approximately one week of training](assets/sample-05.png)
![Additional current model output after approximately one week of training](assets/sample-06.png)
These are the current results after roughly one week on the 3090. The images show clearer faces, more consistent character structure, and more developed clothing and color choices than the early samples. There are still visible artifacts and details to improve.
## Training loss
![Diffusion training loss across approximately 408,000 optimizer steps](assets/training_loss.png)
The recorded loss drops quickly at the beginning, then improves more gradually across roughly 408,000 optimizer steps. I used the loss curve alongside generated samples to follow training progress; the sample timeline shows changes that a single loss value cannot capture.
## What I learned
- **The diffusion training loop:** adding noise at different timesteps and training a UNet to predict it.
- **Text conditioning and latent space:** connecting CLIP text embeddings, a denoising UNet, and a VAE that encodes and decodes images.
- **Training on a single GPU:** preparing image data, caching latents, and working with resolution buckets to make training practical on my hardware.
- **Sampling and evaluation:** seeing how much sampler choices affect output and comparing visual progress alongside training loss.
- **Saving and sharing a model:** working with checkpoints, exponential moving average (EMA) weights, and a packaged Diffusers export.
## Technical scope
The component trained from scratch is the denoising UNet. The project uses the `UNet2DConditionModel` implementation from Diffusers, a frozen pretrained [CLIP text encoder](https://huggingface.co/openai/clip-vit-large-patch14), and a frozen pretrained [VAE from Waifu Diffusion](https://huggingface.co/hakurei/waifu-diffusion).
The training objective is noise prediction in latent space. The released checkpoint contains EMA weights at global step **407,914**, with a nominal training resolution of **512 pixels**. It includes the model components, a DDIM scheduler, and the project's custom `YunaDiffusionPipeline` implementation.
## Dataset and attribution
The dataset used for this project consisted of **1 million+ open-source anime images**.
Pretrained component sources are linked above. A license for the project-trained weights has not yet been specified; pretrained components retain their respective license terms.