You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Initial Wildcard Stable Diffusion Pipeline
* Added some additional example usage
* style
* Added links in README and additional documentation
* Initial Wildcard Stable Diffusion Pipeline
* Added some additional example usage
* style
* Added links in README and additional documentation
* cleanup readme again
* Apply suggestions from code review
Co-authored-by: Patrick von Platen <[email protected]>
Copy file name to clipboardExpand all lines: examples/community/README.md
+58Lines changed: 58 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,7 @@ If a community doesn't work as expected, please open an issue and ping the autho
14
14
| Stable Diffusion Mega |**One** Stable Diffusion Pipeline with all functionalities of [Text2Image](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py), [Image2Image](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py) and [Inpainting](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py)|[Stable Diffusion Mega](#stable-diffusion-mega)| - |[Patrick von Platen](https://github.com/patrickvonplaten/)|
15
15
| Long Prompt Weighting Stable Diffusion |**One** Stable Diffusion Pipeline without tokens length limit, and support parsing weighting in prompt. |[Long Prompt Weighting Stable Diffusion](#long-prompt-weighting-stable-diffusion)| - |[SkyTNT](https://github.com/SkyTNT)|
16
16
| Speech to Image | Using automatic-speech-recognition to transcribe text and Stable Diffusion to generate images | [Speech to Image](#speech-to-image) | - | [Mikail Duzenli](https://github.com/MikailINTech)
17
+
| Wild Card Stable Diffusion | Stable Diffusion Pipeline that supports prompts that contain wildcard terms (indicated by surrounding double underscores), with values instantiated randomly from a corresponding txt file or a dictionary of possible values |[Wildcard Stable Diffusion](#wildcard-stable-diffusion)| - |[Shyam Sudhakaran](https://github.com/shyamsn97)|
17
18
18
19
To load a custom pipeline you just need to pass the `custom_pipeline` argument to `DiffusionPipeline`, as one of the files in `diffusers/examples/community`. Feel free to send a PR with your own pipelines, we will merge them quickly.
Following the great examples from 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, here's a minimal implementation that allows for users to add "wildcards", denoted by `__wildcard__` to prompts that are used as placeholders for randomly sampled values given by either a dictionary or a `.txt` file. For example:
271
+
272
+
Say we have a prompt:
273
+
274
+
```
275
+
prompt = "__animal__ sitting on a __object__ wearing a __clothing__"
276
+
```
277
+
278
+
We can then define possible values to be sampled for `animal`, `object`, and `clothing`. These can either be from a `.txt` with the same name as the category.
279
+
280
+
The possible values can also be defined / combined by using a dictionary like: `{"animal":["dog", "cat", mouse"]}`.
281
+
282
+
The actual pipeline works just like `StableDiffusionPipeline`, except the `__call__` method takes in:
283
+
284
+
`wildcard_files`: list of file paths for wild card replacement
285
+
`wildcard_option_dict`: dict with key as `wildcard` and values as a list of possible replacements
286
+
`num_prompt_samples`: number of prompts to sample, uniformly sampling wildcards
287
+
288
+
A full example:
289
+
290
+
create `animal.txt`, with contents like:
291
+
292
+
```
293
+
dog
294
+
cat
295
+
mouse
296
+
```
297
+
298
+
create `object.txt`, with contents like:
299
+
300
+
```
301
+
chair
302
+
sofa
303
+
bench
304
+
```
305
+
306
+
```python
307
+
from diffusers import DiffusionPipeline
308
+
import torch
309
+
310
+
pipe = DiffusionPipeline.from_pretrained(
311
+
"CompVis/stable-diffusion-v1-4",
312
+
custom_pipeline="wildcard_stable_diffusion",
313
+
revision="fp16",
314
+
torch_dtype=torch.float16,
315
+
)
316
+
prompt ="__animal__ sitting on a __object__ wearing a __clothing__"
0 commit comments