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()
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
or via keyword lookup
When considering our
outputs object as tuple, it only considers the attributes that don’t have
Here for instance, we could retrieve images via indexing:
which will return the tuple
(outputs.images) for instance.
class diffusers.utils.BaseOutput< source >
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
You can’t unpack a
BaseOutput directly. Use the to_tuple() method to convert it to a tuple
to_tuple< source >
Convert self to a tuple containing all the attributes/keys that are not