Skip to content

Instantly share code, notes, and snippets.

@mokurin000
Last active December 4, 2022 07:17
Show Gist options
  • Select an option

  • Save mokurin000/d5790c2fad8c359eab196e3b0f69e0d4 to your computer and use it in GitHub Desktop.

Select an option

Save mokurin000/d5790c2fad8c359eab196e3b0f69e0d4 to your computer and use it in GitHub Desktop.
naifu_launcher.py

Naifu Launcher

simple launcher for Naifu

You can download models from StableDiffusion_CN_WIKI

Features (in plan)

  • scan models/custom/*, and show menu to select one

Directory Structure

~/naifu > tree models/custom                                                                         12:13:59
models/custom
├── kedamaa
│   ├── config.yaml
│   ├── model.ckpt
│   └── name
├── Kujou_Danbo
│   ├── config.yaml
│   ├── model.ckpt
│   └── name
├── NachoNeko
│   ├── config.yaml
│   └── model.ckpt 
├── NekohaShizuku
│   ├── config.yaml
│   ├── model.ckpt
│   └── name
└── shiratama
    ├── config.yaml
    ├── model.ckpt
    └── name

If model/custom not exists or not assecible, we will use official model instead directy. Otherwise, you need to select the model to use.

#!/usr/bin/python3
from os import environ, path, listdir, system
# default model
environ["MODEL_PATH"] = "models/animefull-final-pruned"
map = {
"Novel AI": "models/animefull-final-pruned",
}
models = listdir('models/custom')
for model in models:
model_path = "models/custom/" + model
name = model
if path.exists(model_path + "/name"):
with open(model_path + "/name", "r") as name_file:
name = name_file.read()
map[name] = model_path
options = sorted(map.keys())
for i, name in enumerate(options):
print(str(i) + ")", name)
option = int(input("Select the model to load: "))
environ["MODEL_PATH"] = map[options[option]]
system("./start.sh")
#!/bin/bash
# UNCOMMENT if you want the backend to automatically save files for you
export SAVE_FILES="1"
export DTYPE="float16"
export CLIP_CONTEXTS=3
export AMP="1"
export MODEL="stable-diffusion"
export DEV="True"
#these aren't actually used by the site
#export MODULE_PATH="models/modules"
#unclear if these are used either
#export PRIOR_PATH="models/vector_adjust_v2.pt"
export ENABLE_EMA="1"
export VAE_PATH="models/animevae.pt"
export PENULTIMATE="1"
export PYTHONDONTWRITEBYTECODE=1
if [[ -f venv/bin/python ]]; then
PYTHON=venv/bin/python
else
PYTHON=python
fi
$PYTHON -m uvicorn --host 0.0.0.0 --port=6969 main:app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment