Skip to content

Instantly share code, notes, and snippets.

@RamenJunkie
Created October 30, 2022 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RamenJunkie/6c63f679f6f6e452eaea32fdaf750da9 to your computer and use it in GitHub Desktop.
Save RamenJunkie/6c63f679f6f6e452eaea32fdaf750da9 to your computer and use it in GitHub Desktop.
Stable Diffusion Prompt Iterator
#!/bin/usr/env bash
# Bash Script to iterate over a list of prompts n number of times each in Stable Diffusion.
# Usage - "bash .sd-iterator.sh FILENAME where FILENAME is a plaintext file of prompts
# File and prompts file should be placed in root SD directory
# Prompts should be enclosed in "" quotes, one per line
# By default, n below is set to 1 but you can iterate as many times per prompt as you want.
# Generates a random seed from 1-1000 for each iteration
input="$1"
n=1 #number of cycles for each image, each cycle makes 2 images per seed
while IFS= read -r prompt
do
for (( i=1 ; i<=$n ; i++ ));
do
q=$[RANDOM%1000+1] #Random seed generator 1-1000
python scripts/txt2img.py --W 448 --H 448 --plms --ckpt sd-v1-4.ckpt --skip_grid --n_samples 1 --prompt "$prompt" --seed $q
done
done < "$input"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment