Skip to content

Commit 4def458

Browse files
committed
pipelines
1 parent 9d50f7e commit 4def458

File tree

5 files changed

+290
-338
lines changed

5 files changed

+290
-338
lines changed

docs/source/en/_toctree.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@
2424
title: Tutorials
2525
- sections:
2626
- sections:
27-
- local: using-diffusers/loading_overview
28-
title: Overview
2927
- local: using-diffusers/loading
30-
title: Load pipelines, models, and schedulers
31-
- local: using-diffusers/schedulers
32-
title: Load and compare different schedulers
28+
title: Load pipelines
3329
- local: using-diffusers/custom_pipeline_overview
3430
title: Load community pipelines and components
31+
- local: using-diffusers/schedulers
32+
title: Load models and schedulers
3533
- local: using-diffusers/using_safetensors
3634
title: Load safetensors
3735
- local: using-diffusers/other-formats

docs/source/en/using-diffusers/custom_pipeline_overview.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,48 @@ pipeline = DiffusionPipeline.from_pretrained(
109109
</hfoption>
110110
</hfoptions>
111111

112+
### Load from_pipe
113+
114+
Did you know that you can use `from_pipe` with a community pipeline? Let me show you an example of using long negative prompt and prompt weighting!
115+
116+
```bash
117+
pipe_lpw = DiffusionPipeline.from_pipe(
118+
pipe_sd,
119+
custom_pipeline="lpw_stable_diffusion",
120+
).to("cuda")
121+
122+
prompt = "best_quality (1girl:1.3) bow bride brown_hair closed_mouth frilled_bow frilled_hair_tubes frills (full_body:1.3) fox_ear hair_bow hair_tubes happy hood japanese_clothes kimono long_sleeves red_bow smile solo tabi uchikake white_kimono wide_sleeves cherry_blossoms"
123+
neg_prompt = "lowres, bad_anatomy, error_body, error_hair, error_arm, error_hands, bad_hands, error_fingers, bad_fingers, missing_fingers, error_legs, bad_legs, multiple_legs, missing_legs, error_lighting, error_shadow, error_reflection, text, error, extra_digit, fewer_digits, cropped, worst_quality, low_quality, normal_quality, jpeg_artifacts, signature, watermark, username, blurry"
124+
generator = torch.Generator(device="cpu").manual_seed(33)
125+
out_lpw = pipe_lpw.text2img(
126+
prompt,
127+
negative_prompt=neg_prompt,
128+
width=512,height=512,
129+
max_embeddings_multiples=3,
130+
num_inference_steps=num_inference_steps,
131+
generator=generator,
132+
).images[0]
133+
```
134+
135+
<div class="flex justify-center">
136+
<img class="rounded-xl" src="https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/from_pipe_out_lpw_4.png"/>
137+
</div>
138+
139+
let’s run StableDiffusionPipeline with the same inputs to compare: the result from the long prompt weighting pipeline is more aligned with the text prompt.
140+
141+
```
142+
generator = torch.Generator(device="cpu").manual_seed(33)
143+
out_sd = pipe_sd(
144+
prompt=prompt,
145+
negative_prompt=negative_prompt,
146+
generator=generator,
147+
num_inference_steps=num_inference_steps,
148+
).images[0]
149+
out_sd
150+
```
151+
<div class="flex justify-center">
152+
<img class="rounded-xl" src="https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/from_pipe_out_sd_5.png"/>
153+
</div>
112154

113155
For more information about community pipelines, take a look at the [Community pipelines](custom_pipeline_examples) guide for how to use them and if you're interested in adding a community pipeline check out the [How to contribute a community pipeline](contribute_pipeline) guide!
114156

0 commit comments

Comments
 (0)