Updated 21.3.:
Support for multiple input files added
Extended sample range to 10 000 by default
Tool that helps with selecting a random amount of prompts from a file that contains prompts. I am using it when testing the different prompt packages I am uploading. I'll take a big enough sample to generate a few images. Remove and fix obvious maligned prompts, rinse and repeat.
Requirements
pip install gradio
Usage
gradio guitoolkit.pyor use
python guitoolkit.py
How to guide
Download this file / copy the code below into a file called guitoolkit.py (or whatever you want to call it)
Make/use a virtual environment
python -m venv venvActivate environment
venv\Scripts\activateRun the command
pip install gradioto install the gradio library which is required to use thisWhen you have installed that, run either
gradio guitoolkit.pyorpython guitoolkit.pyYou should now have the tool ready to use if you get the following:
gradio .\guitoolkit.pylaunching in reload mode on:http://127.0.0.1:7861 (Press CTRL+C to quit)You can now visit
http://127.0.0.1:7861where the tool is ready to useInput the file(s) you want to shuffle, select how many you want, copy the output, insert it into e.g. Automatic1111
Source code
import gradio as gr
import random
def shuffle_file(file_obj, no_prompts):
prompts = []
for file in file_obj:
with open(file.name) as infile:
in_prompts = infile.readlines()
prompts.extend(list(set(in_prompts)))
prompts = random.sample(prompts, no_prompts)
random.shuffle(prompts)
print(type(prompts))
return "".join(prompts)
demo = gr.Interface(
fn=shuffle_file,
inputs=["files", gr.Slider(5, 10000)],
outputs=["code"],
)
if __name__ == "__main__":
demo.launch(server_port=9800)Description
Initial release
FAQ
Comments (6)
Can't one use wildcards and other already existing tools for this purpose?
Sure you can, this is mostly for supporting quick prompting via the default Script "Prompts from file or textbox" which enables you to copy paste all the prompts into the input box.
I found it easier to handle prompt generation outside of wildcards plugin, but that might be because I ended up building different CLI based tooling outside of automatic1111.
@Automaticism Please continue to work on this, I do not like the way Wildcards is setup I find it difficult to use and manage. I think alternatives are much needed.
@Athos252 is there something specifically you are looking for in a tool?
@Automaticism Yeah, I kinda think something that will pull a random embedding, preferably from a specific folder so say you have a folder of all your female people (celebs) and you want to make like 4 images of 4 different random celebs to test out who would fit into this image. You don't then need to make and maintain a text doc with all your embeddings. Add this to alternate rendering (the [subject|subject] format) and I think it would be a cool tool for making different faces using random people and character creation.
@Athos252 but you can do this with sd dynamic prompts plugin? https://github.com/adieyal/sd-dynamic-prompts


