bes-dev / stable_diffusion.openvino

Apache License 2.0
1.53k stars 208 forks source link

Suggestion: add argument for number of images #36

Open starkraving opened 1 year ago

starkraving commented 1 year ago

If you want to see the same prompt run multiple times with different seed, you have to do it manually right now and remember to change the output file name. With an argument for number of images, it would automatically re-run the same prompt that number of times, automatically adding "_1" etc to the output filename so they don't get overwritten.

ghost commented 1 year ago

I second this, and would love for the tool to be able to generate multiple images automatically with different seed values so we can pick and choose the best ones. This is especially relavant on CPU since I typically leave SD running in the background while it generates and come back to it later.

I'll leave here the quick and dirty bash script I currently use to create multiple iterations (appending the seed to the filename) if anyone's interested.

#! /bin/bash

PROMPT="<prompt>"
STEPS=<inference steps>
GUID=<guidance>
STR=<strength>
INIT="<input image>"
OUTDIR="<output directory>"
ITER=<number of images to generate>

for ((i=0;i<${ITER};i++))
do
    RANNO=$RANDOM
    python demo.py --prompt "${PROMPT}" --seed ${RANNO} --num-inference-steps ${STEPS} --guidance-scale ${GUID} --strength ${STR} --init-image "${INIT}" --output "${OUTDIR}/output_${RANNO}.png"
done
rncar commented 1 year ago

The problem using demo.py is the model needs to be reloaded each time. Would be great to have a way to produce images from the terminal caching the models.

IceChes commented 1 year ago

I wonder if you could put most of the Python script into a loop and make the loop repeat for the amount of images you want.

rncar commented 1 year ago

The web interface does it, so its possible.

Would be great to have some kind of repl to produce images in a interactive way, a command to render an image, other to change params, etc.

In addition to the interactive behavior, you could do a script that send commands to the engine, for example, to produce images with differents inference steps, guiadance scales, outputs names, etc.

Drake53 commented 1 year ago

In my fork it's possible to do multiple prompts without reloading the model every time: https://github.com/Drake53/stable_diffusion.openvino/commit/1862800dc4fc220dd81f1f22d6b2bf1ad36eb9b2 It's not as an argument though so you have run every prompt manually or make your own solution for that part, but it does give more freedom in what arguments to use for every prompt (instead of only having different seeds and output filenames).