Skip to content

Commit 6b9906f

Browse files
authored
[Docs] Pipelines for inference (#417)
* Update conditional_image_generation.mdx * Update unconditional_image_generation.mdx
1 parent a353c46 commit 6b9906f

File tree

2 files changed

+54
-16
lines changed

2 files changed

+54
-16
lines changed

docs/source/using-diffusers/conditional_image_generation.mdx

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,39 @@ specific language governing permissions and limitations under the License.
1212

1313

1414

15-
# Quicktour
15+
# Conditional Image Generation
1616

17-
Start using Diffusers🧨 quickly!
18-
To start, use the [`DiffusionPipeline`] for quick inference and sample generations!
17+
The [`DiffusionPipeline`] is the easiest way to use a pre-trained diffusion system for inference
1918

19+
Start by creating an instance of [`DiffusionPipeline`] and specify which pipeline checkpoint you would like to download.
20+
You can use the [`DiffusionPipeline`] for any [Diffusers' checkpoint](https://huggingface.co/models?library=diffusers&sort=downloads).
21+
In this guide though, you'll use [`DiffusionPipeline`] for text-to-image generation with [Latent Diffusion](https://huggingface.co/CompVis/ldm-text2im-large-256):
22+
23+
```python
24+
>>> from diffusers import DiffusionPipeline
25+
26+
>>> generator = DiffusionPipeline.from_pretrained("CompVis/ldm-text2im-large-256")
2027
```
21-
pip install diffusers
28+
The [`DiffusionPipeline`] downloads and caches all modeling, tokenization, and scheduling components.
29+
Because the model consists of roughly 1.4 billion parameters, we strongly recommend running it on GPU.
30+
You can move the generator object to GPU, just like you would in PyTorch.
31+
32+
```python
33+
>>> generator.to("cuda")
2234
```
2335

24-
## Main classes
36+
Now you can use the `generator` on your text prompt:
2537

26-
### Models
38+
```python
39+
>>> image = generator("An image of a squirrel in Picasso style").images[0]
40+
```
41+
42+
The output is by default wrapped into a [PIL Image object](https://pillow.readthedocs.io/en/stable/reference/Image.html?highlight=image#the-image-class).
2743

28-
### Schedulers
44+
You can save the image by simply calling:
2945

30-
### Pipeliens
46+
```python
47+
>>> image.save("image_of_squirrel_painting.png")
48+
```
3149

3250

docs/source/using-diffusers/unconditional_image_generation.mdx

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,41 @@ specific language governing permissions and limitations under the License.
1212

1313

1414

15-
# Quicktour
15+
# Unonditional Image Generation
1616

17-
Start using Diffusers🧨 quickly!
18-
To start, use the [`DiffusionPipeline`] for quick inference and sample generations!
17+
The [`DiffusionPipeline`] is the easiest way to use a pre-trained diffusion system for inference
1918

19+
Start by creating an instance of [`DiffusionPipeline`] and specify which pipeline checkpoint you would like to download.
20+
You can use the [`DiffusionPipeline`] for any [Diffusers' checkpoint](https://huggingface.co/models?library=diffusers&sort=downloads).
21+
In this guide though, you'll use [`DiffusionPipeline`] for unconditional image generation with [DDPM](https://arxiv.org/abs/2006.11239):
22+
23+
```python
24+
>>> from diffusers import DiffusionPipeline
25+
26+
>>> generator = DiffusionPipeline.from_pretrained("google/ddpm-celebahq-256")
27+
```
28+
The [`DiffusionPipeline`] downloads and caches all modeling, tokenization, and scheduling components.
29+
Because the model consists of roughly 1.4 billion parameters, we strongly recommend running it on GPU.
30+
You can move the generator object to GPU, just like you would in PyTorch.
31+
32+
```python
33+
>>> generator.to("cuda")
2034
```
21-
pip install diffusers
35+
36+
Now you can use the `generator` on your text prompt:
37+
38+
```python
39+
>>> image = generator().images[0]
2240
```
2341

24-
## Main classes
42+
The output is by default wrapped into a [PIL Image object](https://pillow.readthedocs.io/en/stable/reference/Image.html?highlight=image#the-image-class).
2543

26-
### Models
44+
You can save the image by simply calling:
45+
46+
```python
47+
>>> image.save("generated_image.png")
48+
```
2749

28-
### Schedulers
2950

30-
### Pipeliens
3151

3252

0 commit comments

Comments
 (0)