Background Removal Made Easy and Affordable with Amazon Bedrock Titan Models
Learn how you can use Amazon Bedrock’s Titan models to remove image backgrounds programmatically
Removing image backgrounds can be a tedious task if you’re not a Photoshop wizard. While many apps on the App Store and Play Store promise seamless background removal, they come with a hefty price tag, often charging $10 to $20 per image or subscription. But what if I told you there’s a way to achieve the same results — if not better — for mere cents?
With just a few lines of Python, you’ll not only save money but also gain the flexibility to integrate this capability into your workflows and applications.
Why Choose Amazon Bedrock Titan Models?
Amazon Bedrock is a game-changer in generative AI. Unlike traditional apps, Bedrock provides scalable, cost-effective, and production-ready AI services. By leveraging the Titan models, you can achieve professional-quality background removal at a fraction of the cost — just a few cents per request.
What We’re Building
Using the Python code, we’ll:
- Read an input image.
- Process it with Amazon Bedrock Titan’s background removal capabilities.
- Save the output with a transparent background.
Let’s dive into the solution!
Prerequisites
Before we start, ensure you have:
- An AWS account with access to Amazon Bedrock.
- Python 3.8 or later installed.
- The AWS CLI configured with appropriate credentials.
- Required Python packages:
boto3
,Pillow
.
pip install boto3 pillow
The Code
The complete code for this solution is available in our GitHub repository. To begin, you can clone the repository to your local terminal with below commands:
git clone https://github.com/awsdataarchitect/bedrock-examples
cd bedrock-examples
How It Works
- Read the Image: The script reads your image file and encodes it into a base64 string for processing.
- Invoke Amazon Bedrock Titan Model: It sends the image to the Titan model for background removal.
- Process the Output: The response is decoded, and the output image is saved with a transparent background.
python3 bedrock_titan_image_bg_remove.py
INFO:__main__:Removing background with Amazon Titan Image Generator V2 model amazon.titan-image-generator-v2:0
INFO:botocore.credentials:Found credentials in shared credentials file: ~/.aws/credentials
INFO:__main__:Successfully removed background with Amazon Titan Image Generator V2 model amazon.titan-image-generator-v2:0
Finished background removal using Amazon Titan Image Generator V2 model amazon.titan-image-generator-v2:0.
Before and After (Sample)

Why It’s a Game-Changer
Using this approach, each image costs just a few cents to process. When compared to $10-$20 per image charged by apps, the savings are monumental. Additionally, you get the added benefit of automating this process and integrating it into your applications.
Potential Applications
- E-commerce platforms: Remove backgrounds for product images.
- Social media tools: Enable users to create custom profile pictures.
- Creative projects: Simplify workflows for designers and creators.
Conclusion
Amazon Bedrock Titan models offer an innovative, cost-effective solution for image background removal. By leveraging this code, you can achieve professional-grade results for a fraction of the cost. Say goodbye to overpriced apps and hello to scalable, efficient AI solutions.
Try it out, and let me know what creative applications you come up with. Happy coding!
In Plain English 🚀
Thank you for being a part of the In Plain English community! Before you go:
- Be sure to clap and follow the writer ️👏️️
- Follow us: X | LinkedIn | YouTube | Discord | Newsletter | Podcast
- Create a free AI-powered blog on Differ.
- More content at PlainEnglish.io