Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/main/diffusers/wildcard_stable_diffusion.ipynb
Views: 2535
Wildcard Stable Diffusion
Following examples from the GitHub repositories ( https://github.com/jtkelm2/stable-diffusion-webui-1/blob/master/scripts/wildcards.py) and (https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Custom-Scripts#wildcards) , this implementation allows users to add "wildcards" (denoted by wildcard) to prompts as placeholders for randomly sampled values from either a dictionary or a .txt file.
For instance, given a prompt like animal sitting on a object wearing a clothing, possible values for animal, object, and clothing can be specified in corresponding .txt files or combined in a dictionary like {"animal":["dog", "cat", "mouse"]}.
The pipeline functions similarly to the StableDiffusionPipeline, with the call method taking in wildcard_files (list of file paths for wildcard replacement), wildcard_option_dict (dictionary with wildcard keys and list of possible replacements), and num_prompt_samples (number of prompts to sample, uniformly sampling wildcards).
For example, creating animal.txt with dog, cat, mouse and object.txt with chair, sofa, bench would provide the necessary values for the wildcards in the prompt. This script was contributed by Shyam Sudhakaran and the notebook byParagEkbote.