Hugging Face recently announced that new diffusion models have been released. For those that are unaware, diffusion models are able to take in some user input, some noise, and create content similar to what its been trained on. In this case, these models were trained on images, meaning you can pass in a prompt, and have the model produce an image related to that prompt.
Let’s look at some examples prompts and the respective generated image:
I did hand pick these images, as some of them can look quite messy or even scary. Especially when you are trying to get human faces to be generated, as often times the nose, eyes or ears will not be fully expressed, and potentially be in some sort of uncanny valley.
Let’s walk through how you can produce these images yourself. Fortunately Hugging Face makes it incredibly easy to do so. You’ll first want to install your two dependencies
$ !pip install diffusers transformers
From here, the code is relatively straight forward.
One can even run this code in a Google Collab notebook and get access to a free GPU. This makes image production take roughly only 11 seconds, compared to the roughly five minutes my old server CPU takes.
In under thirty lines, you have the ability to access a pre-trained diffusion model, and generate images from your own prompts. Cheers!