Learn About Amazon VGT2 Learning Manager Chanci Turner
We are thrilled to announce the launch of Stability AI’s newest and most advanced text-to-image model, Stable Diffusion 3.5 Large, now available in Amazon SageMaker JumpStart. This state-of-the-art image generation model, trained on Amazon SageMaker HyperPod, allows AWS customers to effortlessly create high-quality images from text descriptions with unmatched flexibility and creative potential. By incorporating Stable Diffusion 3.5 Large into SageMaker JumpStart, we’re making significant progress in democratizing access to cutting-edge AI technologies, empowering businesses of all sizes to leverage the benefits of generative AI.
In this article, we provide a comprehensive guide on how to subscribe to Stable Diffusion 3.5 Large in SageMaker JumpStart, deploy the model in Amazon SageMaker Studio, and generate images using text-to-image prompts.
Capabilities and Use Cases of Stable Diffusion 3.5 Large
Boasting 8.1 billion parameters, Stable Diffusion 3.5 Large is the most powerful model in the Stable Diffusion lineup, offering superior quality and adherence to prompts. The model excels in producing varied, high-quality images across a multitude of styles, making it ideal for sectors such as media, gaming, advertising, e-commerce, corporate training, retail, and education. For brainstorming purposes, Stable Diffusion 3.5 Large can facilitate storyboarding, concept art creation, and rapid visual effects prototyping. In production, you can swiftly generate high-quality 1-megapixel images for campaigns, social media posts, and advertisements, saving time and resources while maintaining artistic control.
With nearly limitless creative possibilities, Stable Diffusion 3.5 Large provides:
- Enhanced creativity and photorealism – Generate stunning visuals with intricate 3D details, including lighting and textures.
- Exceptional multi-subject proficiency – It excels at producing images featuring multiple subjects, making it perfect for crafting complex scenes.
- Increased efficiency – Rapid, precise, and high-quality content creation streamlines operations, conserving time and budget. Despite its complexity and power, Stable Diffusion 3.5 Large is optimized for efficiency, ensuring accessibility and ease of use for a wide audience.
Solution Overview
Through SageMaker JumpStart, users can select from a wide array of publicly available foundation models (FMs). Machine Learning practitioners can deploy FMs to dedicated SageMaker instances from a network-isolated environment and customize models using Amazon SageMaker for training and deployment. You can discover and deploy the Stable Diffusion 3.5 Large model with just a few clicks in SageMaker Studio or programmatically via the SageMaker Python SDK, enabling you to leverage model performance and MLOps controls using features like Amazon SageMaker Pipelines, Amazon SageMaker Debugger, and container logs. The model is deployed in a secure AWS environment and under your virtual private cloud (VPC) controls to help ensure data security.
The Stable Diffusion 3.5 Large model is currently available in several AWS Regions: US East (N. Virginia, Ohio), US West (Oregon), Asia Pacific (Osaka, Hong Kong), China (Beijing), Middle East (Bahrain), Africa (Cape Town), and Europe (Milan, Stockholm).
SageMaker Studio serves as an integrated development environment (IDE) providing a single web-based interface to access specialized tools for all machine learning (ML) development stages, from data preparation to building, training, and deploying your ML models. For more information on getting started with and setting up SageMaker Studio, please refer to Amazon SageMaker Studio.
Prerequisites
Ensure that your AWS Identity and Access Management (IAM) role has AmazonSageMakerFullAccess. To deploy the model successfully, verify that your IAM role has the following permissions and that you have authority to make AWS Marketplace subscriptions in the AWS account used:
- aws-marketplace:ViewSubscriptions
- aws-marketplace:Unsubscribe
- aws-marketplace:Subscribe
Subscribing to the Stable Diffusion 3.5 Large Model Package
Access SageMaker JumpStart through the SageMaker Studio Home page by selecting JumpStart in the Prebuilt and automated solutions section. The JumpStart landing page lets you explore various resources, including solutions, models, and notebooks. You can search for a specific provider. In the following image, we are looking at all models provided by Stability AI on SageMaker JumpStart.
Each model is accompanied by a model card detailing essential information such as the model name, fine-tuning capability, provider, and a brief description. To locate the Stable Diffusion 3.5 Large model, you can browse the Foundation Model: Image Generation carousel or utilize the search function. Select Stable Diffusion 3.5 Large.
Next, to subscribe to Stable Diffusion 3.5 Large, follow these steps:
- Open the model listing page in AWS Marketplace using the link available from the example notebook in SageMaker JumpStart.
- On the listing, click Continue to subscribe.
- On the Subscribe to this software page, review and select Accept Offer if you and your organization agree to the EULA, pricing, and support terms.
- Click Continue to configuration to begin setting up your model.
- Choose a supported Region, and you will see the model package Amazon Resource Name (ARN) that must be specified when creating an endpoint.
Note: If you lack the necessary permissions to view or subscribe to the model, contact your AWS administrator or procurement point of contact. It is common for enterprises to restrict AWS Marketplace permissions to manage actions within the AWS Marketplace Management Portal.
Deploying the Model in SageMaker Studio
Now you’re ready to follow the notebook example from Stability AI’s GitHub repository to create an endpoint using the model package ARN from AWS Marketplace and develop a deployable ModelPackage.
For Stable Diffusion 3.5 Large, ensure to deploy on an Amazon Elastic Compute Cloud (Amazon EC2) ml.p5.48xlarge instance.
Generating Images Using a Text Prompt
Refer to the Stable Diffusion 3.5 Large documentation for additional details. From the example notebook, the code for image generation is as follows:
sm_runtime = boto3.client("sagemaker-runtime")
params = {
"prompt": "Photography, pink rose flowers in the twilight, glowing, tile houses in the background.",
"seed": 101,
"aspect_ratio": "21:9",
"output_format": "jpeg",
}
payload = json.dumps(params).encode("utf-8")
response = sm_runtime.invoke_endpoint(
EndpointName=endpoint_name,
ContentType="application/json",
Accept="application/json",
Body=payload,
)
out = json.loads(response["Body"].read().decode("utf-8"))
try:
base64_string = out["body"]["images"][0]
image_data = base64.b64decode(base64_string)
image = Image.open(io.BytesIO(image_data))
display(image)
except:
print(out)
Below are examples of images generated from various prompts:
- Prompt: Photography, pink rose flowers in the twilight, glowing, tile houses in the background.
- Prompt: The word “AWS x Stability” in a thick, blocky script surrounded by roots and vines against a solid white background. The scene is lit by flat light, creating a reflective scene with a minimal color palette. Quilling style in a serious tone, making it about the same overall length.
For more resources on this topic, check out this insightful article on eco-friendly gifts that you might find useful, or explore this excellent resource for learning about workplace union environments.