How to create your AI-generated avatars for free (no coding needed)
🤖

How to create your AI-generated avatars for free (no coding needed)

by Anita Kirkovska | Join my Newsletter | Updated 22 Feb 2023
 
With Stable Diffusion & DreamBooth, you can now create your AI-avatars using your own images.
 
  • Stable Diffusion is a text-to-image AI model that lets you generate images from text.
  • Dreambooth is a technique that gets you to “teach” Stable Diffusion to generate augmented images from your photos.
 
In this tutorial I’ll show you how to generate your own AI-avatars with Google Colab, which is like Google Docs but for executing python code in your browser.
Don't worry, you won't have to code; you will just run some code.
That’s it. Let’s get to it
 

💪🏻 Training a new model in 10 steps (~1hour 15 mins)

 
Step 1 → Open the Google Colab document
Open this Colab document, where you’ll be “teaching” your AI and generating your AI avatars.
Step 2 → Enable GPU power (<1min)
In the Colab document, go to Runtime > Change runtime type, and make sure GPU is selected under “Hardware Accelerator”.
notion image
Step 3 → Connect your Google Drive with the Colab document (<1min)
To connect your Google Drive, just click on the “play” icon in the first cell in the document. It will ask you to authenticate your Drive account. Done.
💡
All of your images will be stored in your google drive, so make sure you have some space available.
notion image
Step 4 → Set up your environment (<1min)
Just click on the play button to run the “Dependencies” step, that will set up your environment. As soon as it installs everything move to the next step.
notion image
Step 5 → Download Stable Diffusion (<5min)
We’ll use one of the HuggingFace models for this step: 1.5 Stable Diffusion model link.
If you’re loading this model for the first time you will need to accept the terms and conditions on the link.
Then, to download the model into this notebook, simply add this path runwayml/stable-diffusion-v1-5 under the Path_to_HuggingFace field.
💡
With this setup you’ll be running the 1.5 Stable Diffusion model. This step will take around 5-8 minutes to execute.
 
notion image
 
Step 6 → Set up DreamBooth (<5min)
Now we need to create a session.
In the first sell just give the session a name under “Session-Name” (this can be whatever you want, as you only use it to load previously trained models to retrain/use)
notion image
Then run this cell (without changing anything). Next you’ll need to upload your images.
Step 7 Upload your images (<5min)
The “Instance Images” is a very important step.
In order to help your AI program generate avatars for you, you need to feed it with some of your photos. The program will “learn” your characteristics, and then it will be able to create new ones.
  • Get 20 photos of you, and make sure you pick different varieties. Different background, position, clothes, moods, ponytails, beard, hats – you get my point. Also make sure the quality is good, and you don’t have any shadows on your face.
  • Change the names of the photos with a unique keyword (your name and surname) and add numbers to them, in an orderly manner. For example: anitakirkovska(1).jpg, anitakirkovska(2).jpg… up to anitakirkovska(20).jpg.
 
Here’s a screenshot of my images:
notion image
💡
Important to remember > This unique keyword will be your instance name when you’ll generate a prompt to the AI. In my case the prompts will be: “a portrait of anitakirkovska …” So, make sure it’s unique! Stable Difussion needs to know that this is a new person (you) with unique identifiers, so it doesn’t confuse you with another person’s images.
→ Run the cell to upload your images. You can skip the Captions and the Concept Images (Regularization) steps for now.
Step 8 → Train your own model (40-50min)
In this step, I’ve used 1500 training steps, and it produced nice outputs. So, since this is the first time you’re doing this, I recommend to change the “Training_Steps” to 1500, and just run the cell.
notion image
When the model starts to train you’ll see this prompt in your Colab document:
notion image
Here we can see that the model is at 6%, and has covered 85 training steps. It needs to reach the 1500 that we gave it to him, and the model will be trained successfully.
Once completed it will convert into a ckpt that can be found in your gdrive under fast-dreambooth/Sessions/anita-test2 but we don't need to go there. The ‘’anita-test2’’ is the session name I gave under step 6.
If you use 20 photos and 1500 training steps it may took ~45 minutes to finish.
 
⏰ While you wait
Read this post in my newsletter: Speak-with-ChatGPT
Search for prompt inspiration on Openart.ai
Step 9 → Test your model (<5min)
After your model is successfully trained, you’re ready to test it.
If you’re running this notebook for the first time and want to use the current trained model, leave everything empty and just run the cell. No need to fill out anything.
Run the cell.
notion image
After testing is done, the notebook will generate a link to an app that you can use. You can find it under “Running on local URL”.
Click on it and you’ll be directed to another window where you’re able to give prompts to the model and generate your own images.
notion image
This cell will continue to run while you test your prompts, because it provides connection with the webUI.
 
Step 10 → Generate your photos
In the app you can play with different prompts. Below are some prompt ideas to get you started. Otherwise, you can check Lexica.art or Open.art for some prompt inspiration.
notion image
 

🛑 Known issues and fixes

 
Module errors:
From what I've seen most of the time this is an issue if you have an old sd folder by running an older colab best way to fix this is deleting the sd folder in gdrive and rerunning auto1111
^C errors:
This is an out of memory error if you're uploading a big model (7gb or more) just tick the option large_model if you get this error elsewhere try changing to a high RAM runtime.
Connection errors:
Seems to be a bit of a fight between whatever server is working best at the time, if gradio server isn't working as desired untick the box and run through the tunnel server link and vice versa
Extension errors:
If you're installing and running extensions through Automatic1111 when you run into an error with those extension first try searching through the Automatic1111 github issues for similar errors.

✍🏼 Prompts

Prompt ideas to get you started
 
 

😍 Thank you note

I hope that this was useful to you - thank you for reading.
Massive thanks to Taha Tesser and George for their feedback!
If you have any questions or suggestions on how to improve this tutorial, please DM me on twitter.
 

📜 Join my newsletter

 
notion image
 
I just launched my newsletter “The Prompt” where I cover everything that’s happening in the world of AI.
How-to’s like this one, new apps, highlighting makers who are building amazing tools and use-cases on how AI can be applicable to you - I cover all of that and more.
Here’s the first issue: Anyone needs more AI-generated media?