Skip to content

vluz/SDNano

Repository files navigation

SD Nano

Update: Please use sdnanorv.py for any generation.

It includes a very good all-purpose model, a vae, optimizations, deafault negative prompt,
control over other main generation variables, saves image file and prompt, displays results,
and includes a demonstration prompt. It's very light on resources.

The remaining implementations are reference and of smaller size for teaching purposes.


Very small implementation of Stable Diffusion that is still useful

Memory effecient and compact, can run decent SD models

Implements xformers, attention slicing, and sequential cpu offloading

disables safety_checker, be careful replacing the model

Can run inside ~1.2 GB of VRAM (sdnanorv.py)

Tested with Python 3.10.6 https://www.python.org/downloads/release/python-3106/

Uses Azure ttk dark theme (https://github.com/rdbende/Azure-ttk-theme)


➡️Requires Hugging Face Security token in file authtoken.py, can be gotten freely, details at:
https://huggingface.co/docs/hub/security-tokens

Open a command prompt and cd to a new directory of your choosing:

(optional; recommended) Create a virtual environment with:

python -m venv "venv"
venv\Scripts\activate

To install do:

git clone https://github.com/vluz/sdnano.git
cd SDNano
pip install -r requirements.txt

On first run it will download several models from Hugging Face.
It will take quite some time, both on reqs above and on first run.
Please allow it time to finish.
All runs after the first are then faster to load.

To run do:
➡️**python sdnanorv.py for the fully functional cli version**

or
python sdnano.py for the reference cli version
or
python sdnanotk.py for the reference TK version
or
streamlit run sdnanoweb.py for the reference streamlit version


RV stands for Realistic_Vision_V2.0 (https://huggingface.co/SG161222/Realistic_Vision_V2.0)

With RV and this example prompt from the model developper:
RAW photo, a close up portrait photo of 26 y.o woman in wastelander clothes, long haircut, pale skin, slim body, background is city ruins, (high detailed skin:1.2), 8k uhd, dslr, soft lighting, high quality, film grain, Fujifilm XT3
Result:
Generation result

Not fully tested, use in production at your own risk.

About

Very small implementation of Stable Diffusion

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published