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
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â.
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.
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.
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.
Â
Â
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)
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:
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.
When the model starts to train youâll see this prompt in your Colab document:
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.
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.
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.
Â
đ 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
Â
Â
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? â