Image-to-Image Chains
This page will tell you how to create image-to-image workflows using chains on Flush.
Unlike text-to-image models, image-to-image models take in a prompt and an image as input. We discuss this more here. Now, we’ll look at both situations in more complex examples.
Example 1: Images as Input
Let’s say we want to generate an image with a text-to-image model. However, we are not satisfied with its quality, so we want to use an upscaler to refine the generated image.
First, let’s initialize our models. We’ll be using Stable Diffusion XL as the text-to-image model and RealESRGAN as the upscaler.
Now, let’s define a prompt to pass into this chain with Flush AI’s PromptTemplate
.
Finally, let’s put everything together with a Chain
.
Note that we pass in diffusion_output[0]
. This is because diffusion_output
is an array of string image urls, and image-to-image models only take in a string of one image url.
We can run this chain with the following command.
Example 2: Text as Input
As shown previously here, we can use chains to improve prompts for text-to-image stable diffusion models. Let’s do the exact same, but for image-to-image models.
First, lets initialize our models. We’ll be using Flush’s OpenAI’s GPT-4 wrapper as the LLM and Stable Diffusion XL as the image-to-image model.
Let’s use the same PromptTemplate
from the text-to-image example:
Now, let’s put everything together with our Chain.