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

feat(ui): image batching in workflows #7343

Merged
merged 18 commits into from
Nov 19, 2024

Conversation

psychedelicious
Copy link
Collaborator

Summary

Adds support for image "batching" to the workflow editor.

The batch API is currently in use by the linear UI, but until now there was no way for users to interact with it directly. This PR adds a new node called Image Batch, which queues a graph for each of its images.

How it works

Add an Image Batch node, drag images into it and connect the Image output into any other node(s).

When you click Invoke, the special Image Batch node is removed from the graph and a batch config is created from its list of images and all its outgoing connections. The backend gets the batch config and processes it, enqueuing a separate graph for each image in the list.

Examples

Single Batch -> Single Node

The simplest case is using a batch on a single node. Here's a batch that resizes 5 images to 200x200 thumbnails.

image

Results:

image

This results in 5 graphs, each containing a single resize node with one of the 5 images in the batch list. Note the images are 200x200 pixels.

Single Batch -> Multiple Nodes

You can also use a single batch on multiple nodes. This batch resizes the image to 200x200 pixels, then pastes this thumbnail version back on top of the full size version of the image.

image

Results:

image

This also results in 5 graphs, each of which contains a resize and paste node. In each graph, each node gets the same input image of the 5 images in the batch list. The graph does not get any of the other images in the batch.

The batch node can have any number of outgoing connections from its image output - all of them get the same image.

Multiple Batches -> Single/Multiple nodes

When multiple batches are used, they are combined such that all permutations are run (e.g. the product of batches is taken).

image

Results:

image

In this case, the product of the two batches is 15 graphs. Each image of the 3-image batch is used as the base image, and a thumbnail of each tiger is pasted on top of it.

No Pairwise Batching

When using multiple batches, they are always multiplied - never paired.

Imagine you had two batches of 5 images. As described in the multiplicative example above, you'd get 5 images * 5 images = 25 graphs.

Pairwise batching would instead take the first image from each of the two batches and use them together in each graph.

While the server's batching API supports this, it is not implemented in the UI just yet. It's much more complicated to make a UI for pairwise batching, so we'll evaluate use-cases for it and can explore a UI for it in the future.

No Dynamic Inputs

You cannot dynamically generate a batch's image collection. It must be provided up-front.

Other Field Types

This PR implements support for image batching, any field type is possible so long as we can provide a UI for it. For example, a String Batch could queue multiple graphs for a list of prompts, or a Model Batch could queue a graph for every model.

Image batching is the biggest impact here, so we've added it first. We can add other field types in the future, depending on demand. The system supports it; it's just a matter of building a solid UI/UX.

Using a Board for an Image Batch

For now, you will need to manually select all images in a board and drag them in. We'll look into ways to use a board directly in the future.

Versus Iterate Nodes

Batching serves a similar use-case to iterate nodes, and can replace them in any situation where Iterate nodes do not need their input collection to be dynamic.

Going forward, we'll suggest batching to iterate nodes for situations where there are no dynamic inputs.

Combining Batch Outputs

One thing you might like to do with batches is combine the outputs of a batch. This is not feasible for now, sorry.

Other Changes

  • You may now drag images into image collection fields directly.
  • Image collection field validation is updated to support min and max item counts.
  • Special was added to the Classification enum. This indicates that the UI had some special handling for the node. Maybe this should just be named batch. All it does is add a green lightning bolt icon to the node. Suppose we could also skip this classification and instead match on node type.

Related Issues / Discussions

Many offline discussions.

QA Instructions

My main concern is the field validation changes. Previously, field validation was mostly concerned with required fields having a value. Now, we also may need to check collection sizes. It's possible I missed something and fields render as invalid w/ red colors, when they are actually fine.

Besides fuzzing field validation, try out the Batch API.

I just realized the Invoke button's tooltip does not calculate the number of graphs it will queue. I'll do that in a followup.

Merge Plan

n/a

Checklist

  • The PR has a short but descriptive title, suitable for a changelog

@github-actions github-actions bot added python PRs that change python files invocations PRs that change invocations services PRs that change app services frontend PRs that change frontend files labels Nov 19, 2024
@hipsterusername hipsterusername force-pushed the psyche/feat/ui/image-batching-workflow-2 branch from 08154e8 to 3ce766d Compare November 19, 2024 03:02
@psychedelicious psychedelicious enabled auto-merge (rebase) November 19, 2024 03:08
@psychedelicious psychedelicious merged commit 91d981a into main Nov 19, 2024
14 checks passed
@psychedelicious psychedelicious deleted the psyche/feat/ui/image-batching-workflow-2 branch November 19, 2024 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend PRs that change frontend files invocations PRs that change invocations python PRs that change python files services PRs that change app services
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[enhancement]: Batch Processing for Assets [enhancement]: batch upscale
2 participants