Titan Images
Unstable API
0.8.0
@project-lakechain/bedrock-image-generators
The Bedrock image generators package enables developers to use image generation models hosted on Amazon Bedrock, and create images at scale within their pipelines. The Amazon Titan image generator is part of this package and makes it possible to generate images from text, realize image inpainting and outpainting, as well as image-to-image variation.
đŧī¸ Text-to-Image
To generate images as part of your pipelines from a text prompt, you can use the TitanImageGenerator
construct. This construct either takes the content of input text document as a prompt for generating an image, allowing you to nicely chain documents together, or can also take a user-provided prompt.
âšī¸ The below example demonstrates how to use the Titan image generator to create images from an arbitrary prompt every 5 minutes, using the Scheduler Trigger.
đ§âđ¨ Image Inpainting
The Titan model supports image inpainting by modifying a specific area of an image delimited by a mask, with an AI generated image. To implement inpainting within a pipeline, you can use the TitanImageGenerator
by specifying a source image and a mask prompt. Mask prompts identify the area to be painted in natural language, such as âhouseâ or âwindowâ.
đ In the below example we create a pipeline that triggers when an image is uploaded to a source S3 bucket, and replace any âhouseâ detected in the image by a âModern houseâ.
Original Image | Inpainted Image |
---|---|
Example
đī¸ Image Outpainting
The Amazon Titan image model also supports outpainting, relative to a mask prompt. Image outpainting refers to painting an existing image outside of the area delimited by the mask image.
đ In the below example we create a pipeline that triggers when an image is uploaded to a source S3 bucket, and replaces the environment outside of a âhouseâ with a âbeautiful garden and swimming poolâ.
Original Image | Outpainted Image |
---|---|
Example
⨠Image Variation
The Titan model also supports taking an image as an input, and transforming that image using a textual prompt into a new image.
To perform image variation, you use the TitanImageGenerator
and provide it with a ImageVariationTask
.
Example
âī¸ Background Removal
The Titan model supports identifying the main subject within a picture and cleanly and accurately remove the background of the image, leaving only the main subject.
To perform background removal, you use the TitanImageGenerator
and provide it with a BackgroundRemovalTask
.
đ Background removal is only available with the Titan Model image generator v2 model.
Original Image | Background Removed |
---|---|
Example
đ¨ Color Guided Generation
The Titan model allows users to influence how an image is generated based on a color palette. This feature is useful when you want to generate images that adhere to a specific color branding guideline.
To perform color guided image generation, you use the TitanImageGenerator
and provide it with a ColorGuidedGenerationTask
.
đ Color guided image generation is only available with the Titan Model image generator v2 model.
Reference Image | Color Palette | Generated Image |
---|---|---|
Example
đ§Ŋ Object Removal
With the Amazon Titan Image Generator, you can use semantic masks based on a prompt to isolate a certain subject in an image and segment it. By using the inpainting capabilities of the Titan Image Generator, you can use content-aware inpainting to remove objects from images.
To perform object removal, you use the TitanImageGenerator
and provide it with a ImageInpaintingTask
without any textual prompt.
Original Image | Object Removed |
---|---|
Example
đ Image Conditioning
The Titan model supports image conditioning, which allows you to shape your creations with precision and intention. By providing a reference image, you can instruct the model to focus on specific visual characteristics, such as edges, object outlines, and structural elements, or segmentation maps that define distinct regions and objects within the reference image.
To perform image conditioning, you use the TitanImageGenerator
and provide it with a TextToImageTask
with a reference image.
đ Image conditioning is only available with the Titan Model image generator v2 model.
Original Image | Generated Image |
---|---|
Example
đ Region Selection
You can specify the AWS region in which you want to invoke Amazon Bedrock using the .withRegion
API.
đ By default, the middleware will use the current region in which it is deployed.
âī¸ Model Parameters
For the different tasks supported by the TitanImageGenerator
, you can specify additional parameters to customize the generation of the images. You pass additional parameters using the .withImageGenerationParameters
API on the task to execute.
Parameters
Below are the parameters you can pass to the image generation tasks. See the official Titan documentation to understand the effect of available parameters.
Parameter | Description | Default |
---|---|---|
numberOfImages | The number of images to generate. | 1 |
quality | The quality of the generated images. | standard |
cfgScale | Specifies how strongly the generated image should adhere to the prompt. | 8.0 |
height | The height of the generated image. | 1024 |
width | The width of the generated image. | 1024 |
seed | Determines the initial noise setting. | random |
đī¸ Architecture
This middleware is based on a Lambda compute and interacts with the Amazon Bedrock service in the specified region to generate images.
đˇī¸ Properties
Supported Inputs
Mime Type | Description |
---|---|
text/plain | Text document |
image/png | Image document |
image/jpeg | Image document |
application/json+scheduler | Scheduler event |
Supported Outputs
Mime Type | Description |
---|---|
image/png | Image document |
Supported Compute Types
Type | Description |
---|---|
CPU | This middleware only supports CPU compute. |
đ Examples
- Titan Inpainting Pipeline - An example showcasing how to perform image inpainting using Amazon Titan.
- Image Outpainting Pipeline - An example showcasing how to perform image outpainting using Amazon Titan.
- Titan Background Removal Pipeline - Builds a pipeline demonstrating image background removal using the Amazon Titan model.