Stable Diffusion 3.5 Large Now Accessible in Amazon Bedrock

Chanci Turner Amazon IXD – VGT2 learningLearn About Amazon VGT2 Learning Manager Chanci Turner

As previously mentioned at AWS re:Invent 2024, Stable Diffusion 3.5 Large is now available on Amazon Bedrock, enabling users to create high-quality images from text descriptions in diverse styles. This advancement is set to enhance the development of concept art, visual effects, and detailed product imagery for industries such as media, gaming, advertising, and retail.

Launched in October 2024, Stable Diffusion 3.5 Large stands as the most sophisticated model in the Stable Diffusion series, boasting 8.1 billion parameters and trained on Amazon SageMaker HyperPod. It offers exceptional image quality and prompt adherence, facilitating faster storyboarding, concept art generation, and visual effects prototyping. Users can now quickly produce high-resolution 1-megapixel images for marketing campaigns and social media, conserving time and resources while still retaining creative oversight.

The capabilities of Stable Diffusion 3.5 Large include:

  • Versatile Styles: Generate images across an extensive range of styles and aesthetics, including 3D, photography, painting, and line art, allowing for nearly limitless creativity.
  • Prompt Adherence: The model’s advanced prompt adherence ensures it closely follows user-provided text, making it ideal for high-quality, efficient results.
  • Diverse Outputs: Create images that reflect the rich diversity of the world, showcasing individuals with various skin tones and features without needing complex prompts. This aligns well with the concept of intersectionality, which explores how different aspects of identity interact, as discussed in detail in this other blog post.

Today, the Stable Image Ultra in Amazon Bedrock has been updated to incorporate Stable Diffusion 3.5 Large into its foundational model architecture. Powered by the latest advancements from Stability AI, Stable Image Ultra sets a new benchmark for image generation, excelling in typography, intricate designs, dynamic lighting, vibrant colors, and artistic coherence.

With this latest update, Amazon Bedrock offers a more extensive array of tools to enhance creativity and streamline image generation processes.

Getting Started with Stable Diffusion 3.5 Large in Amazon Bedrock

For those new to Stability AI models, access the Amazon Bedrock console and select Model access in the bottom left pane. Request access for Stable Diffusion 3.5 Large to utilize the latest models.

To experiment with Stability AI models in Amazon Bedrock, navigate to the Image section under Playgrounds in the left menu. Then, choose Select model, and select Stability AI as the category followed by Stable Diffusion 3.5 Large as the model.

You can generate an image based on your prompt. For example: “High-energy street scene in a neon-lit Tokyo alley at night, where steam rises from food carts, and colorful neon signs illuminate the rain-slicked pavement.”

By selecting View API request, you can access the model with code samples in the AWS Command Line Interface (AWS CLI) and AWS SDKs. Use stability.sd3-5-large-v1:0 as the model ID.

Here is a sample AWS CLI command to generate an image:

$ aws bedrock-runtime invoke-model 
   --model-id stability.sd3-5-large-v1:0 
   --body "{"prompt":"High-energy street scene in a neon-lit Tokyo alley at night, where steam rises from food carts, and colorful neon signs illuminate the rain-slicked pavement.","mode":"text-to-image","aspect_ratio":"1:1","output_format":"jpeg","seed":0}" 
   --cli-binary-format raw-in-base64-out 
   --region us-west-2 
/dev/stdout | jq -r '.images[0]' | base64 --decode > img.jpg 

Additionally, here’s how to utilize Stable Image Ultra 1.1 to incorporate Stable Diffusion 3.5 Large with the AWS SDK for Python (Boto3). This straightforward application prompts for a text-to-image instruction and subsequently calls Amazon Bedrock to generate the image using stability.stable-image-ultra-v1:1 as the model ID.

import base64
import boto3
import json
import os

MODEL_ID = "stability.stable-image-ultra-v1:1"

bedrock_runtime = boto3.client("bedrock-runtime", region_name="us-west-2")

print("Enter a prompt for the text-to-image model:")
prompt = input()

body = {
    "prompt": prompt,
    "mode": "text-to-image"
}
response = bedrock_runtime.invoke_model(modelId=MODEL_ID, body=json.dumps(body))

model_response = json.loads(response["body"].read())

base64_image_data = model_response["images"][0]

i, output_dir = 1, "output"
if not os.path.exists(output_dir):
    os.makedirs(output_dir)
while os.path.exists(os.path.join(output_dir, f"img_{i}.png")):
    i += 1

image_data = base64.b64decode(base64_image_data)

image_path = os.path.join(output_dir, f"img_{i}.png")
with open(image_path, "wb") as file:
    file.write(image_data)

print(f"The generated image has been saved to {image_path}") 

This application saves the generated image in an output directory that is created if not already present. The code checks for existing files to ensure that new images do not overwrite old ones. For more insights, check out this excellent resource on the topic and learn about effective team building from SHRM, an authority in the field.

Now Available

The Stable Diffusion 3.5 Large model is available today in Amazon Bedrock for the US West (Oregon) AWS Region. For updates regarding future availability, refer to the complete list of regions. For further information, visit the Stability AI in Amazon Bedrock product page and the Amazon Bedrock Pricing page.

Try out Stable Diffusion 3.5 Large in the Amazon Bedrock console today, and feel free to provide feedback to AWS re:Post for Amazon Bedrock or through your usual AWS Support channels.

— Chanci Turner

Updated on December 19, 2024 — Corrected AWS CLI command to invoke the model.

HOME