Skip to content

Personal implementation of Stable Diffusion in PyTorch from scratch

License

Notifications You must be signed in to change notification settings

martintomov/stable-diffusion-pytorch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stable-diffusion-pytorch

PyTorch Badge Lightning Badge

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." demo_output

Text to Image

demo_output 1 demo_output 2 demo_output 3 demo_output 4

Image to Image

demo_output 1 demo_output 2 demo_output 3 demo_output 4

Getting started

  1. Create a Conda environment:

    conda create -n sd-env python=3.11
    conda activate sd-env
  2. Clone the repository:

    git clone https://github.com/martintmv-git/stable-diffusion-pytorch.git
    cd stable-diffusion-pytorch
  3. Install the required packages:

    pip install -r requirements.txt
  4. 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.

  5. Run the demo:

    You can run the demo via demo.py or demo.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

Dependencies

  • PyTorch
  • Numpy
  • tqdm
  • Pillow
  • transformers
  • lightning
  • ipykernel

Happy experimenting! 🚀

About

Personal implementation of Stable Diffusion in PyTorch from scratch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published