Stable Diffusion is making waves across the machine learning space with its new innovative approach for text-image generation. Stable Diffusion is a deep learning model released by StabilityAI in 2022, and it is mainly used for providing detailed images conditioned on text descriptions.
In this blog, we will walk you through how to deploy Stable Diffusion and run sub-1ms latency inference with a line of code!
How to Deploy Stable Diffusion
What You'll Need
To deploy Stable Diffusion with almost real-time inference, you'll need a few things:
Access the Stochastic GitHub Repository: X-Stable-Diffusion. Currently, the repository includes 4 optimization techniques with more in the pipeline
Python and Docker installed on your system
A Stochastic Account: If you don’t have a Stochastic Account, the CLI will prompt you to create one when accessing our library. It is free and just takes 1 minute Sign Up →
Install the latest version of the stochasticx library:
pip install stochasticx
Deploy the Stable Diffusion Model:
stochasticx stable-diffusion deploy --type aitemplate
To infer with this deployed model:
stochasticx stable-diffusion infer --prompt "Riding a horse"
Check all the options of the infer command:
stochasticx stable-diffusion infer --help
You can get the logs of the deployment executing the following command:
stochasticx stable-diffusion logs
Stop and remove the deployment with this command:
stochasticx stable-diffusion stop
Sample Images Generated Using Stable Diffusion
Stable Diffusion is very versatile in both the prompts it can accept and the images it can generate. Below are some images generated using Stable Diffusion with a given prompt, across different types of optimizations.
Prompt: “The Easter bunny riding a motorcycle in New York City”
Text-image generation is becoming a huge deal in the machine learning world, with Stable Diffusion as one of the models to access text-image capabilities. Fortunately, anyone can deploy Stable Diffusion with the Stochastic X library through a few lines of code.
Speeding up other models with Stochastic X is just as easy. The Stochastic X platform automatically speeds up your deep learning models for you. To learn more, view our other blog articles, or contact us.
Access our product here: Sign Up →
For enterprise solutions, reach out here: Enterprise Inquiries →