diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

API: move pipeline's `output_type` to its Output object

Open keturn opened this issue 2 years ago • 3 comments

Now that Pipelines return a well-defined PipelineOutput object, I suggest something along the lines of

class StableDiffusionPipelineOutput:
    def images(self) -> List[PIL.Image.Image]: # […]
    def as_array(self) -> np.ndarray: # […]

That retains the functionality of having PIL Image support built-in to diffusers while also making the return types unambiguous.

keturn avatar Sep 10 '22 00:09 keturn

Hey @keturn that's an interesting idea! The problem though is that we have to maintain backward compatibility with the tuples tensor, so tuples[0] output has to match StableDiffusionPipelineOutput[0].

We could deprecate the output_type function argument and maybe just add a new .images_array variable?

Also cc @anton-l @patil-suraj

patrickvonplaten avatar Sep 13 '22 16:09 patrickvonplaten

Agree with @patrickvonplaten regarding the matching tuples, but returning a PIL image by default won't work either (ONNX restriction to only have lists or tensors in the output). But having an as_pil() function in the dataclass instead could work, although breaking the "returning PIL by default" design.

anton-l avatar Sep 13 '22 16:09 anton-l

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

github-actions[bot] avatar Oct 10 '22 15:10 github-actions[bot]