Define the environment
First, create a file with your Beam App definition. You can name this whatever you want. In this example, name itapp.py
.
app.py
Inference Function
Write a simple function that takes a prompt passed from the user, and returns an image generated using Stable Diffusion.You need an access token from Huggingface to run this example. You can sign up
for Huggingface and access your token on the settings
page, and store it in the Beam
Secrets Manager.
image.save()
method below. You defined a file path called output.png
in app.py
, and that’s where your images will be saved.
run.py
Deploying the API
In your teriminal, run:
Generating images
In the dashboard, click Call API to view the API URL.
Querying the status of a job
You will use the/task
API to retrieve the status of a job, passing in the Task ID.
outputs
dictionary, as a pre-signed URL.