Diffusers documentation

BaseOutputs

You are viewing v0.15.0 version. A newer version v0.31.0 is available.
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

BaseOutputs

All models have outputs that are instances of subclasses of 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 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

class diffusers.utils.BaseOutput

< >

( )

Base class for all model outputs as dataclass. Has a __getitem__ that allows indexing by integer or slice (like a tuple) or strings (like a dictionary) that will ignore the None attributes. Otherwise behaves like a regular python dictionary.

You can’t unpack a BaseOutput directly. Use the to_tuple() method to convert it to a tuple before.

to_tuple

< >

( )

Convert self to a tuple containing all the attributes/keys that are not None.