Simple Streamlit application that uses the Amazon Bedrock API to call the Amazon Titan Image Generator v2 model and replaces an image's background using outpainting.
Ensure you have access to the Amazon Titan Image Generator G1 v2 model in the "Model access" tab of the Amazon Bedrock Web Console.
Create Python virtual environment locally and install required packages (1x only). Script assumes you already have a recent version of Python 3 installed and use a python3
alias.
# I am running Python 3.12 or later
python3 --version
python3 -m venv .venv
source .venv/bin/activate
pip install pip --upgrade
pip install -r requirements.txt --upgrade
REM I am running Python 3.12 or later
python --version
python -m venv .venv
.venv\Scripts\activate
python -m pip install pip --upgrade
python -m pip install -r requirements.txt --upgrade
Provide your AWS credential on the commandline or authenticate in your normal way before starting the application.
export AWS_ACCESS_KEY_ID="<YOUR_AWS_ACCESS_KEY_ID>"
export AWS_SECRET_ACCESS_KEY="<YOUR_AWS_SECRET_ACCESS_KEY>"
export AWS_SESSION_TOKEN="<YOUR_AWS_SESSION_TOKEN>"
SET AWS_ACCESS_KEY_ID=YOUR_AWS_ACCESS_KEY_ID
SET AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY
SET AWS_SESSION_TOKEN=YOUR_AWS_SESSION_TOKEN
Start the Streamlit application. The application should start locally on http://localhost:8501
and open in your web browser automatically. View the terminal output for more logging information.
streamlit run app.py --server.runOnSave true
You can pass custom arguments to Streamlit when starting the application. For example:
streamlit run app.py \
--server.runOnSave true \
--theme.base "dark" \
--theme.backgroundColor "#26273B" \
--theme.primaryColor "#ACADC1" \
--theme.secondaryBackgroundColor "#454560" \
--theme.font "sans serif"\
--ui.hideTopBar "true" \
--client.toolbarMode "minimal"
streamlit run app.py ^
--server.runOnSave true ^
--theme.base "dark" ^
--theme.backgroundColor "#26273B" ^
--theme.primaryColor "#ACADC1" ^
--theme.secondaryBackgroundColor "#454560" ^
--theme.font "sans serif"^
--ui.hideTopBar "true" ^
--client.toolbarMode "minimal"
The burger image used in the demonstration is from Pexels.com. Photo by Valeria Boltneva.
Video preview of application on YouTube.
Screengrabs of the application.
The contents of this repository represent my viewpoints and not of my past or current employers, including Amazon Web Services (AWS). All third-party libraries, modules, plugins, and SDKs are the property of their respective owners.