Guide: How to Run Stable Diffusion on Colab

datatec.studio
AI MVP
Published in
2 min readNov 4, 2023

--

pixabay.com

These days, using text-to-image features is both easy and free, thanks to tools like Microsoft Bing’s Image Creator.

If you want to create text-to-image using code, like with stable diffusion, this article is for you.

Table of Contents

1. Use Case

2. Colab Project

1. Use Case

After running the stable diffusion model, a related image should be shown when a prompt is given.

This screenshot shows the result:

Result of stable diffusion

2. Colab Project

As precondition, GPU of Colab was used.

The Colab Project and the result for each steps can be found on my github repository.

Following are related code:

# https://medium.com/@datatec.studio
!pip install diffusers==0.10.2 transformers scipy ftfy accelerate matplotlib

from diffusers import StableDiffusionPipeline

import matplotlib.pyplot as plt

pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4")

prompt = "closeup of donuts with colorful glaze isolated on clean…

--

--