Run AI prediction functions (a.k.a "predictors") in your Python apps. With Function, you can build AI-powered apps by creating and composing GPU-accelerated predictors that run in the cloud. In a few steps:
Function is distributed on PyPi. This distribution contains both the Python client and the command line interface (CLI). To install, open a terminal and run the following command:
# Install Function
$ pip install --upgrade fxn
Note
Function requires Python 3.9+
Head over to fxn.ai to create an account by logging in. Once you do, generate an access key:
Let's run the @samples/stable-diffusion
predictor which accepts a text prompt
and generates a corresponding image. Run the following Python script:
from fxn import Function
# Create the Function client
fxn = Function(access_key="<ACCESS KEY>")
# Create a prediction
prediction = fxn.predictions.create(
tag="@samples/stable-diffusion",
inputs={
"prompt": "An astronaut riding a horse on Mars"
}
)
# Show the generated image
image = prediction.results[0]
image.show()
Tip
Explore public predictors on Function or create your own.
Open up a terminal and run the following command:
# Login to Function
fxn auth login <ACCESS KEY>
# Make a prediction using the Function CLI
fxn predict @samplefxn/stable-diffusion \
--prompt "An astronaut riding a horse on the moon"
Within a few seconds, you should see a creepy-looking image pop up 😅:
- Discover predictors to use in your apps.
- Join our Discord community.
- Check out our docs.
- Learn more about us on our blog.
- Reach out to us at [email protected].
Function is a product of NatML Inc.