Skip to playerSkip to main content
Don't have a high-end GPU? You can still run Stable Diffusion using Google Colab's free resources! In this tutorial, I demonstrate how to set up and run Stable Diffusion directly in your browser without getting blocked by Google.

I cover the entire process: setting up your Colab notebook, configuring the runtime for GPU usage, installing the necessary libraries, and fetching models from Hugging Face. I also explain how to bypass the safety checker to ensure your generations aren't unnecessarily blocked, while keeping things responsible.

Google Colab: https://colab.research.google.com/
Script Code1:
!pip install diffusers["torch"] transformers
!pip install accelerate
!pip install git+https://github.com/huggingface/diffusers

Script Code2:
from diffusers import AutoPipelineForText2Image
import torch

mymodel = "digiplay/Realisian_v5"
myprompt="masterpiece,cat, wizard cat"
mynegative_prompt = ""
myheight=768
mywidth=512
mysteps=25
myguidance_scale = 7.5

pipeline = AutoPipelineForText2Image.from_pretrained(
mymodel, torch_dtype=torch.float16, variant="fp16", use_safetensors=True
).to("cuda")
pipeline.safety_checker = None

image = pipeline(
prompt=myprompt,
negative_prompt=mynegative_prompt,
height=myheight, width=mywidth,
num_inference_step=mysteps,
guidance_scale = myguidance_scale,
).images[0]
image

Original YouTube Tutorial: https://youtu.be/JFKM-PubsNk

Video Details:
* Original Publish Date: March 20, 2024
* Focus: Stable Diffusion / Google Colab / Free AI Computing
* Test using RTX 4060 TI 16 GB of VRAM

Follow lordcaocao2025 on Dailymotion for more technical AI research and generative workflow guides!

---
Connect with me:
📺 YouTube: https://www.youtube.com/@CaoCao2025
📱 TikTok: https://www.tiktok.com/@caocao20250
💎 Patreon: https://www.patreon.com/cw/Caocao2025

#StableDiffusion #GoogleColab #AIArt #FreeTools #AITutorial #lordcaocao2025
Transcript
00:00hello guys welcome back with me chowchow2025 today we're going to learn
00:05how to generate stable diffusion text to image in Google collab without Google
00:12blocking it so what you first need to do is open go collab reset google.com and
00:18click this new notebook just wait until you have this thing now you have one
00:29code here you could add another so you have to code here now the first thing to
00:35do is to copy paste this thing I'm going to put the link on the description in
00:41the first one and then you play this play this is gonna install torch in the
00:49Google collab and then accelerate and install the diffusion itself so you need
00:55to do it the first time you play it in this session but make sure you can make
01:02sure you are connect to a GPU a change run type you click change run type and you
01:10sell it 5.3 and it usually start in this CPU you move it to a GPU okay after that
01:21you click save if you already running a runtime it's kind of disconnect so you
01:26need to repeat the step but first you need to install this and you need to do
01:31this every time you are start the runtime so it's not just one deal it's doing it
01:40every session you start all over again after that you copy paste this thing I'm
01:46going to also put it on the description you copy paste this after install that and you
01:52know the result is what you need to do models first models you decide where's the
01:58model sales you could search it on see if it AI see the name of the model and then
02:04you search it on the hugging face just search the model's name usually
02:14realision or maybe dreamshaper just see what dreamshaper 7 dreamshaper 8 you see
02:24here and it's like this the counter separate just copy paste this thing and then put it on
02:31the models you know I currently use realision v5 version 5 and then put the
02:39prompt you know you could do it whatever the problem is negative prompt it's the
02:44usual you could put whatever or not at all if you don't want to put any each and
02:51with stop guidance skill and after you've done this all simply play this I mean I
03:01try this don't mind this message it's not as fast as your local computer if you have
03:08a better computer but if you compare it to 1660 super it's not that bad see and yeah I
03:17put this pipeline safety checker non so it could generate non safe for work image I
03:25put this because simply an image like this they consider it not safe for work so a lot
03:31of black screen here if you don't put this thing non but watch out don't don't generate the full
03:40other stuff and let's see if we change it to for the old one a woman in the school a
03:52teacher and then we
03:54process again
04:04you can play with the prompt what good is from this is you will not be blocked by
04:11Google but remember if the GPU run out because you use it a lot you need to wait
04:19like two or three days so usually you could play it like seven and eight hours you know
04:28playing this and stuff it's not gonna block but suddenly you run out of CPU power in
04:35this session and you will be able to play it after like one or two days usually so
04:41don't worry if you run out of time and okay guys that's it running stable
04:48diffusion in Google collapse it's free using the free CPU of course and it's not
04:56being blocked but you need to know a little scripting here you know it's it's
05:01very easy it's basically only like a few lines thank you for watching don't
05:08forget to like share and comment and see you get on next episode have a nice day
Comments

Recommended