Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support streaming images via AsyncGenerator in createStableDiffusionImages #22

Open
skirsten opened this issue May 18, 2023 · 1 comment
Labels
enhancement New feature or request needs discussion Let's keep chatting about this

Comments

@skirsten
Copy link

It would be great if the interface would support streaming images using AsyncGenerator.

E.g.

createStableDiffusionImages: async function* (options) {
  const image = await fetch(`${window.location.origin}/DummyImage.png`);
  const blob = await image.blob();
  const createdAt = new Date();

  for (let i = 0; i < (options?.count || 4); i++) {
    yield {
      id: `${Math.random() * 10000000}`,
      createdAt,
      blob,
    };

    set(({ imagesGeneratedSoFar }) => ({
      imagesGeneratedSoFar: imagesGeneratedSoFar + 1,
    }));

    await new Promise((resolve) => setTimeout(resolve, 1000));
  }
},

The type could look something like:

createStableDiffusionImages?: (options?: {
  /** The `StableDiffusionInput` you've been asked to generate, if empty, you could still return a random image */
  input?: StableDiffusionInput;
  /** Determines how many images will be created using the given `StableDiffusionInput` */
  count?: number;
}) =>
  | MaybePromise<StableDiffusionImages | undefined>
  | AsyncGenerator<StableDiffusionImage>;

to support both flows.

What do you think?

@cruhl cruhl self-assigned this May 19, 2023
@cruhl cruhl added enhancement New feature or request good first issue needs discussion Let's keep chatting about this and removed good first issue labels May 19, 2023
@cruhl
Copy link
Contributor

cruhl commented May 19, 2023

I definitely want to support streaming images.

The contract for plugins is really sticky and important to get right, so I'm a bit leery about adding anything without a working implementation.

Maybe we can get this implemented with the Stability plugin or the open PR for the webui plugin?

@cruhl cruhl removed their assignment May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs discussion Let's keep chatting about this
Projects
None yet
Development

No branches or pull requests

2 participants