Text-to-image algorithms creates an image from scratch from a text description, using machine learning to understand your words and convert them to a unique image each time.
Researchers at OpenAI, Google, Facebook, and others have developed text-to-image tools, and similar models have proliferated online in the open source ecosystem.
These tools represent a massive cultural shift because they remove the requirement for technical labor from the process of image-making. Instead, they promotes for creative ideation, skillful use of language, and curatorial taste.
However, the installation of this tool requires powerfull machines, but can be accomplished also using cloud resources, even free of charge.
Today i’d like to share my simple solution that use a free tier of Google Colab in order to run the Stable Diffusion model.
What is Stable Diffusion?
“Stable Diffusion is a machine learning text-to-image model to generate digital images from natural language descriptions, but can be also used for other tasks, like generating image-to-image translations guided by a text prompt.” (from Wikipedia)
Unlike models like DALL-E, Stable Diffusion makes its source code available: its license prohibits certain harmful use cases, in order tu address concerns about AI ethics, stating that the model can be used to create deepfakes.
What is Google Colab?
Colab is a free Jupyter notebook environment that runs entirely in the cloud, powered by Google. It does not require a setup and the notebooks can be simultaneously edited by multiple team members - just the way you edit documents in Google Docs. Furthermore, Colab supports many popular machine learning libraries.
My Colab solution for running Stable Diffusion
The notepad is composed by two sections.
The first, named Setup, needs to be executed the first time you start th Colab session, and performs the installation of required librearies and the download of the model from Huggingface. In order to perform the second step, you need to register and account on huggingface.com to obtain an API Token, that you must copy in the specific field.
The second section performs the image creation process: you need to understand that in this istance of Stable Diffusion, the safety_checker option is disabled, so the results can be also explicits.
You can deploy a copy of the notebook on your Colab Istance directly from GitHub repository, with a simple click on this button: