Customize the runtime
First, you’ll define aRuntime
with an Image
.
We’re going to be defining two things:
- Which packages to install in the runtime
- A storage volume to temporarily store images downloaded from S3
app.py
Storing AWS secrets
Since we’re pulling image files from Amazon S3, you’ll need your own AWS credentials to run this example. You can save your AWS credentials in the Beam Secrets Manager, and access the secrets asos.environ
variables.

Reading and writing files from S3
Let’s write a basic client to read and write files to an S3 bucket. You’ll setup a dedicated bucket for images that are unprocessed, and another bucket for finished images.Show Code
Show Code
run.py
Processing images with rembg
We’ll userembg
to remove the backgrounds from our images.
Let’s write a function to:
- Download all the files in your bucket to a Storage Volume
- Apply the background removal process to each image with
rembg
- Upload the each processed image to an S3 bucket
Show Code
Show Code
run.py
Running the function on a schedule
Since we want this to run on a schedule, we’ll add a Scheduled Job to the Beam app.app.py