Code Monkey home page Code Monkey logo

stablediffusion's Introduction

StableDiffusion

StableDiffusion from scratch (pytorch lightning)


Untitled{: width="50%" height="60%"}


Repository Directory

├── StableDiffusion
        ├── data
        ├── Attention.py
        ├── CLIP.py
        ├── DDPM.py
        ├── Decoder.py
        ├── Diffusion.py
        ├── Encoder.py
        ├── Inference.py
        ├── ModelConverter.py
        ├── ModelLoader.py
        ├── Pipeline.py
        ├── requirments.txt
        └── README.md
  • data : Model Weights, CLIP Toknizer
  • DDPM.py : DDPM Sampler
  • Encoder/Decoder : VAE Encoder/Decoder
  • ModelConverter.py : load from standard weights
  • ModelLoader.py : Construct StableDiffusion
  • diffusion.py : Diffusion Forward/Backward Process
  • Pipeline.py : Generating Pipeline

Tutoral

Clone repo and install model and depenency

Download vocab.json and merges.txt from https://huggingface.co/runwayml/stable-diffusion-v1-5/tree/main/tokenizer and save them in the data folder
Download v1-5-pruned-emaonly.ckpt from https://huggingface.co/runwayml/stable-diffusion-v1-5/tree/main and save it in the data folder

# Clone this repo and install dependency
git clone https://github.com/inhopp/StableDiffusion.git
pip install -r "StableDiffusion/requirments.txt"

Inference.py

# Text to Image
prompt = "a dog, fullmetal, robotic, mechanical parts, highly detailed, ultra sharp, cinematic, 100mm lens, 8k resolution."
uncond_prompt = ""  # Also known as negative prompt
do_cfg = True
cfg_scale = 8  # min: 1, max: 14

# Image to Image
input_image = None
image_path = "./images/dog.jpg"
strength = 0.9

sampler = "ddpm"
num_inference_steps = 50
seed = 42

Main Reference

https://github.com/hkproj/pytorch-stable-diffusion

stablediffusion's People

Contributors

inhopp avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.