Skip to content

A Stable Diffusion-based command-line image generator for *nix.

Notifications You must be signed in to change notification settings

8vasu/sg-diffusion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sg-diffusion

A Stable Diffusion-based command-line image generator for *nix.

Requirements and setup

  1. NVIDIA GPU with CUDA Compute Capability 6.1 or higher and minimum 6 GB VRAM.

  2. We are assuming that we are working in an operating system with a POSIX-compliant shell sh in the PATH environment variable.

  3. Install a suitable NVIDIA driver for your GPU.

  4. Install Git and add it to PATH.

  5. Install Docker and add it to PATH.

  6. Install the NVIDIA Container Toolkit.

  7. Clone this repository and cd to the (root of the) cloned directory:

$ git clone https://github.com/8vasu/sg-diffusion.git
$ cd sg-diffusion
  1. Run build.sh to build the Docker image:
$ ./build.sh
  1. After Docker has successfully built the sg-diffusion image, download a Stable Diffusion checkpoint model, say, from Hugging Face. For example, for low VRAM graphics cards like mine, Stable Diffusion 1.4 is good. Create a directory named models in the root of the cloned directory sg-diffusion, and place the model there so that the directory structure of models is this:
models
└── stable-diffusion-v1-4
    ├── feature_extractor
    │   └── preprocessor_config.json
    ├── model_index.json
    ├── safety_checker
    │   ├── config.json
    │   └── model.fp16.safetensors
    ├── scheduler
    │   └── scheduler_config.json
    ├── text_encoder
    │   ├── config.json
    │   └── model.fp16.safetensors
    ├── tokenizer
    │   ├── merges.txt
    │   ├── special_tokens_map.json
    │   ├── tokenizer_config.json
    │   └── vocab.json
    ├── unet
    │   ├── config.json
    │   └── diffusion_pytorch_model.fp16.safetensors
    └── vae
        ├── config.json
        └── diffusion_pytorch_model.fp16.safetensors
  1. Run test.sh to test:
$ ./test.sh
  1. Add the following alias to the shell profile ~/.profile of your POSIX-compliant shell (or some similar shell such as bash):
alias sgimg='docker run -it --rm --gpus=all --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 -v /home/8vasu/sg-diffusion:/app -v "$PWD":/work sg-diffusion python /app/sg-diffusion.py'

Replace /home/8vasu/sg-diffusion with the path to the (root of the) cloned directory.

  1. Test the above alias:
$ sgimg -o garden.png "a beautiful garden"
  1. Check the help message for more options:
sgimg -h

NVIDIA NGC PyTorch Docker images

About

A Stable Diffusion-based command-line image generator for *nix.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors