Skip to content

Latest commit

 

History

History
55 lines (37 loc) · 1.65 KB

File metadata and controls

55 lines (37 loc) · 1.65 KB

BaseOutputs

All models have outputs that are instances of subclasses of [~utils.BaseOutput]. Those are data structures containing all the information returned by the model, but that can also be used as tuples or dictionaries.

Let's see how this looks in an example:

from diffusers import DDIMPipeline

pipeline = DDIMPipeline.from_pretrained("google/ddpm-cifar10-32")
outputs = pipeline()

The outputs object is a [~pipelines.ImagePipelineOutput], as we can see in the documentation of that class below, it means it has an image attribute.

You can access each attribute as you would usually do, and if that attribute has not been returned by the model, you will get None:

outputs.images

or via keyword lookup

outputs["images"]

When considering our outputs object as tuple, it only considers the attributes that don't have None values. Here for instance, we could retrieve images via indexing:

outputs[:1]

which will return the tuple (outputs.images) for instance.

BaseOutput

[[autodoc]] utils.BaseOutput - to_tuple