This post goes over how to perform AI image generation with diffused CLI.
Prerequisites
Install Python:
brew install python
Install pipx:
brew install pipx
CLI
Install the CLI:
pipx install diffused
diffused segmind/tiny-sd "red apple"
diffused OFA-Sys/small-stable-diffusion-v0 "cat wizard" --image=https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png
diffused kandinsky-community/kandinsky-2-2-decoder-inpaint "black cat" --image=https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png --mask-image=https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint_mask.png
Show the help message and exit:
diffused --help # diffused -h
Script
Create a virtual environment:
python3 -m venv .venv
Activate the virtual environment:
source .venv/bin/activate
Install the package:
pip install diffused
Generate an image with model and prompt:
# script.py
from diffused import generate
images = generate(model="segmind/tiny-sd", prompt="red apple")
images[0].save("apple.png")
Run the script:
python script.py
Open the image:
open apple.png
See the API documentation.
Resources
- For more models, see Hugging Face.
- The package is open source and on GitHub.