Personal implementation of Stable Diffusion in PyTorch from scratch. Educational and research purposes only.
prompt = "A cat under the snow with blue eyes, covered by snow, highly detailed, realistic, ultra sharp, cinematic, 100mm lens, 8k resolution." |
-
Create a Conda environment:
conda create -n sd-env python=3.11 conda activate sd-env
-
Clone the repository:
git clone https://github.com/martintmv-git/stable-diffusion-pytorch.git cd stable-diffusion-pytorch
-
Install the required packages:
pip install -r requirements.txt
-
Download weights:
Download
v1-5-pruned-emaonly.ckpt
(4.27 GB) from RunwayML on Hugging Face and save it in the/data
folder. Feel free to download any other weights you like. -
Run the demo:
You can run the demo via
demo.py
ordemo.ipynb
notebook by your preference. Both demo scripts are configured to use a MPS GPU device, which can be easily adjusted at the start of the code file.# To run the demo script python demo.py # Or open and run the Jupyter notebook jupyter notebook demo.ipynb
- PyTorch
- Numpy
- tqdm
- Pillow
- transformers
- lightning
- ipykernel