outputs.md 1.79 KB
Newer Older
Aryan's avatar
Aryan committed
1
<!--Copyright 2025 The HuggingFace Team. All rights reserved.
Nathan Lambert's avatar
Nathan Lambert committed
2
3
4
5
6
7
8
9
10
11
12

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->

Steven Liu's avatar
Steven Liu committed
13
# Outputs
Nathan Lambert's avatar
Nathan Lambert committed
14

15
All model outputs are subclasses of [`~utils.BaseOutput`], data structures containing all the information returned by the model. The outputs can also be used as tuples or dictionaries.
Nathan Lambert's avatar
Nathan Lambert committed
16

Steven Liu's avatar
Steven Liu committed
17
For example:
Nathan Lambert's avatar
Nathan Lambert committed
18

Patrick von Platen's avatar
Patrick von Platen committed
19
20
```python
from diffusers import DDIMPipeline
Nathan Lambert's avatar
Nathan Lambert committed
21

Patrick von Platen's avatar
Patrick von Platen committed
22
23
24
pipeline = DDIMPipeline.from_pretrained("google/ddpm-cifar10-32")
outputs = pipeline()
```
Nathan Lambert's avatar
Nathan Lambert committed
25

Steven Liu's avatar
Steven Liu committed
26
The `outputs` object is a [`~pipelines.ImagePipelineOutput`] which means it has an image attribute.
Patrick von Platen's avatar
Patrick von Platen committed
27

Steven Liu's avatar
Steven Liu committed
28
You can access each attribute as you normally would or with a keyword lookup, and if that attribute is not returned by the model, you will get `None`:
Patrick von Platen's avatar
Patrick von Platen committed
29
30
31
32
33
34

```python
outputs.images
outputs["images"]
```

Steven Liu's avatar
Steven Liu committed
35
36
When considering the `outputs` object as a tuple, it only considers the attributes that don't have `None` values.
For instance, retrieving an image by indexing into it returns the tuple `(outputs.images)`:
Patrick von Platen's avatar
Patrick von Platen committed
37
38
39
40
41

```python
outputs[:1]
```

Steven Liu's avatar
Steven Liu committed
42
43
44
45
46
<Tip>

To check a specific pipeline or model output, refer to its corresponding API documentation.

</Tip>
Patrick von Platen's avatar
Patrick von Platen committed
47
48
49
50
51

## BaseOutput

[[autodoc]] utils.BaseOutput
    - to_tuple
Steven Liu's avatar
Steven Liu committed
52
53
54
55
56
57
58
59
60
61
62

## ImagePipelineOutput

[[autodoc]] pipelines.ImagePipelineOutput

## AudioPipelineOutput

[[autodoc]] pipelines.AudioPipelineOutput

## ImageTextPipelineOutput

63
[[autodoc]] ImageTextPipelineOutput