The script text2image_cli.py <demo>
accepts an optional argument (demo
) to run with a default configuration.
# Login to linux distro
proot-distro login debian --shared-tmp
# Load python venv
source .venv/bin/activate
# Run script
cd mobile-stable-diffusion
python text2image_cli.py demo
This is the configuration used for this example.
{
"modelName": "meinamix_meinaV9",
"prompt": "(masterpiece, best quality, high quality, highresolution:1.4), ambient soft lighting, 4K, 1girl,cute,huge breasts,close-up,long hair,pink hair,black hairband,pink eyes, well defined nose, happy, close-up,((gradient hair))",
"negativePrompt": "easynegative, badhandv4, (worst quality, low quality, normal quality), bad-artist, blurry, ugly, ((bad anatomy)),((bad hands)),((bad proportions)),((duplicate limbs)),((fused limbs)),((interlocking fingers)),((poorly drawn face)),clothes,logo,watermark,muscles:1.3,elf,elf ears,headphones,",
"width": 320,
"height": 320,
"seed": 78583
}
Some outputs with different steps.
Steps | DPMSolverMultistepScheduler | EulerDiscreteScheduler |
---|---|---|
20 | ||
32 | ||
64 |
See other results and configurations here.
To use stable diffusion you'll need Termux, this app allows you to use a linux distro in your mobile phone.
You'll also need a model to work with. In this case I'll be MeinaMix a model hosted in Civitai and HuggingFace.
I usually generate the model form a .safetensors file or download the files directly from a HuggingFace repo.
The model should be placed inside the Models folder and have the following structure:
Models/meinamix_meinaV9
├── feature_extractor
│ └── preprocessor_config.json
├── model_index.json
├── safety_checker
│ ├── config.json
│ └── pytorch_model.bin
├── scheduler
│ └── scheduler_config.json
├── text_encoder
│ ├── config.json
│ └── pytorch_model.bin
├── tokenizer
│ ├── merges.txt
│ ├── special_tokens_map.json
│ ├── tokenizer_config.json
│ └── vocab.json
├── unet
│ ├── config.json
│ └── diffusion_pytorch_model.bin
└── vae
├── config.json
└── diffusion_pytorch_model.bin
Download Termux and install it on your phone.
pkg install proot
pkg install proot-debian
pkg install proot-distro
proot-distro install debian
Note that the distro will be located at /data/data/com.termux/files/usr/var/lib/proot-distro/installed-rootfs/debian/root
.
proot-distro login debian --shared-tmp
apt update
apt install git git-lfs vim python3 python3-pip python3-venv
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade diffusers transformers accelerate ftfy xformers
pip install pytorch
pip install torch
git clone https://github.com/zehr0s/mobile-stable-diffusion
cd mobile-stable-diffusion
Download the model and place it inside the folder Models
.
python text2image_cli.py