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
Add SDXL long weighted prompt pipeline (replace pr:4629) (#4661)
* Add SDXL long weighted prompt pipeline
* Add SDXL long weighted prompt pipeline usage sample in the readme document
* Add SDXL long weighted prompt pipeline usage sample in the readme document, add result image
| Zero1to3 Pipeline | Implementation of [Zero-1-to-3: Zero-shot One Image to 3D Object](https://arxiv.org/abs/2303.11328) | [Zero1to3 Pipeline](#Zero1to3-pipeline) | - | [Xin Kong](https://github.com/kxhit)
42
+
| Zero1to3 Pipeline | Implementation of [Zero-1-to-3: Zero-shot One Image to 3D Object](https://arxiv.org/abs/2303.11328)|[Zero1to3 Pipeline](#Zero1to3-pipeline)| - |[Xin Kong](https://github.com/kxhit)|
43
+
Stable Diffusion XL Long Weighted Prompt Pipeline | A pipeline support unlimited length of prompt and negative prompt, use A1111 style of prompt weighting | [Stable Diffusion XL Long Weighted Prompt Pipeline](#stable-diffusion-xl-long-weighted-prompt-pipeline) | - | [Andrew Zhu](https://xhinker.medium.com/) |
43
44
44
45
45
46
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.
@@ -1529,6 +1530,44 @@ CLIP guided stable diffusion images mixing pipline allows to combine two images
1529
1530
This approach is using (optional) CoCa model to avoid writing image description.
### Stable Diffusion XL Long Weighted Prompt Pipeline
1535
+
1536
+
This SDXL pipeline support unlimted length prompt and negative prompt, compatible with A1111 prompt weighted style.
1537
+
1538
+
You can provide both `prompt` and `prompt_2`. if only one prompt is provided, `prompt_2` will be a copy of the provided `prompt`. Here is a sample code to use this pipeline.
1539
+
1540
+
```python
1541
+
from diffusers import DiffusionPipeline
1542
+
import torch
1543
+
1544
+
pipe = DiffusionPipeline.from_pretrained(
1545
+
"stabilityai/stable-diffusion-xl-base-1.0"
1546
+
, torch_dtype= torch.float16
1547
+
, use_safetensors=True
1548
+
, variant="fp16"
1549
+
, custom_pipeline="lpw_stable_diffusion_xl",
1550
+
)
1551
+
1552
+
prompt ="photo of a cute (white) cat running on the grass"*20
1553
+
prompt2 ="chasing (birds:1.5)"*20
1554
+
prompt =f"{prompt},{prompt2}"
1555
+
neg_prompt ="blur, low quality, carton, animate"
1556
+
1557
+
pipe.to("cuda")
1558
+
images = pipe(
1559
+
prompt= prompt
1560
+
, negative_prompt= neg_prompt
1561
+
).images[0]
1562
+
1563
+
pipe.to("cpu")
1564
+
torch.cuda.empty_cache()
1565
+
images
1566
+
```
1567
+
1568
+
In the above code, the `prompt2` is appended to the `prompt`, which is more than 77 tokens. "birds" are showing up in the result.
1569
+

0 commit comments