Skip to content

Simple script for using Stable Diffusion XL text-to-image on AWS Bedrock

Notifications You must be signed in to change notification settings

codeforkjeff/bedrock-sdxl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bedrock-sdxl

Simple script for using Stable Diffusion XL text-to-image on AWS Bedrock

I wrote this to mess around. Use at your own risk.

Prequisites / Setup

  • Get an AWS account
  • Get model access to Stable Diffusion XL in AWS Bedrock
  • Generate access keys with permission to use the Bedrock service and the SDXL model
  • Edit these two files on your machine as follows:

~/.aws/profile

[profile bedrock-sdxl]
# or whatever region you're using
region=us-east-1

~/.aws/credentials

[bedrock-sdxl]
aws_access_key_id=PASTE_YOUR_KEY_HERE
aws_secret_access_key=PASTE_YOUR_KEY_HERE

Install

python -m venv venv
source ./venv/bin/activate
pip install -r requirements.txt

Usage

Single text prompt. The truncated sha hash at the end of the filename is calculated on the set of request parameters, including a random seed based on your machine ID. So the hash in your filename will be different. The image will open on your computer if xdg-open is available.

$ ./bedrock-sdxl.py -p "a swimming duck"
writing output/a_swimming_duck_c9ac9897.json
writing output/a_swimming_duck_c9ac9897.png

Text prompt with multiple weights

$ ./bedrock-sdxl.py -p "a swimming duck" 1.0 "a swimming elephant" 0.7

Text prompt with multiple weights, including negative weight

$ ./bedrock-sdxl.py -p "a swimming duck" 1.0 "a swimming elephant" 0.7 "orange sky" -1.0

Setting 'steps' body parameter to 75 (see these docs for a complete list of parameters)

$ ./bedrock-sdxl.py -p "a swimming duck" 1.0 "a swimming elephant" 0.7 "orange sky" -1.0 -b steps 75

Setting multiple parameters

$ ./bedrock-sdxl.py -p "a swimming duck" 1.0 "a swimming elephant" 0.7 "orange sky" -1.0 -b steps 75 seed 666 style_preset photographic

To (re)generate an image from parameters stored in a .json file

$ ./bedrock-sdxl.py -r output/a_swimming_duck_c9ac9897.json

To see all the options

$ ./bedrock-sdxl.py -h

About

Simple script for using Stable Diffusion XL text-to-image on AWS Bedrock

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages