Guide to enter codes to compare three Deflion models (v1.5, v2-Base & Base & SD3-medium) Side in Gage Colab using Gradio

In this vestamary, we will open the old AI industrial capacity, stable models v1.5, v2-base, and putting up 3 Medium Medium in central media, producing a picture. Running completely in Google Colab with Gradio Interface, We will find comparison alongside three powerful pipes, quick speeds of Iteration, and speedy GPU. Whether we are a maketer who wants to elevate our visual products or engineer that wishes to take our A-acget content.
!pip install huggingface_hub
from huggingface_hub import notebook_login
notebook_login()
We include HuggingFatfat.Hub library and request a copy of the_login () function, which moves you to access your account.
!pip uninstall -y torchvision
!pip install --upgrade torch torchvision --index-url
!pip install --upgrade diffusers transformers accelerate safetensors gradio pillow
We start the power-producing any Torvivision to clear the potential conflict with the torchvishonition from pytorch wheels in CUDA 11.8, to develop recent versions of the construction and use GPU.
import torch
from diffusers import StableDiffusionPipeline, StableDiffusion3Pipeline
import gradio as gr
device = "cuda" if torch.cuda.is_available() else "cpu"
We import pytro to both the stability of V1 and V3 pipes from the Diffusers library, and the gradio of active demeans. Assessing accessibility of the CUDA and places a change of service at “Cuda” when the GPU is; Besides, it falls back to “CPU”, to ensure your models working in the correct hardware.
pipe1 = StableDiffusionPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5",
torch_dtype=torch.float16,
safety_checker=None
).to(device)
pipe1.enable_attention_slicing()
We are uploading the Modest V1.5 model model (Float16) without a built-in inspector (GPU, if any), and enable accelerating stocks to reduce Peak Vram generation during the generation of the image.
pipe2 = StableDiffusionPipeline.from_pretrained(
"stabilityai/stable-diffusion-2-base",
torch_dtype=torch.float16,
safety_checker=None
).to(device)
pipe2.enable_attention_slicing()
We load the – the Model in 16-bit Precision Without the Default Safety Filter, Transfers To Your Chosen Desert, and Activates Attention Sticing Inference Inference.
pipe3 = StableDiffusion3Pipeline.from_pretrained(
"stabilityai/stable-diffusion-3-medium-diffusers",
torch_dtype=torch.float16,
safety_checker=None
).to(device)
pipe3.enable_attention_slicing()
We pull with a variable AI firm
def generate(prompt, steps, scale):
img1 = pipe1(prompt, num_inference_steps=steps, guidance_scale=scale).images[0]
img2 = pipe2(prompt, num_inference_steps=steps, guidance_scale=scale).images[0]
img3 = pipe3(prompt, num_inference_steps=steps, guidance_scale=scale).images[0]
return img1, img2, img3
Now, this activity is conducting the same text as soon as the three uploaded text (pipeline, pipe2, pipeline) using monitoring measures and first rate from the v1.5, v2-base.
def choose(selection):
return f"✅ You selected: **{selection}**"
with gr.Blocks() as demo:
gr.Markdown("## AI Social-Post Generator with 3 Models")
with gr.Row():
prompt = gr.Textbox(label="Prompt", placeholder="A vibrant beach sunset…")
steps = gr.Slider( 1, 100, value=50, step=1, label="Inference Steps")
scale = gr.Slider( 1.0, 20.0, value=7.5, step=0.1, label="Guidance Scale")
btn = gr.Button("Generate Images")
with gr.Row():
out1 = gr.Image(label="Model 1: SD v1.5")
out2 = gr.Image(label="Model 2: SD v2-base")
out3 = gr.Image(label="Model 3: SD v3-medium")
sel = gr.Radio(
["Model 1: SD v1.5","Model 2: SD v2-base","Model 3: SD v3-medium"],
label="Select your favorite"
)
txt = gr.Markdown()
btn.click(fn=generate, inputs=[prompt, steps, scale], outputs=[out1, out2, out3])
sel.change(fn=choose, inputs=sel, outputs=txt)
demo.launch(share=True)
Finally, this gratio app creates a concrete UI where you can install a quick text, adjust the quick instruction, and prepare the guidance, and generate photos from SD v1.5, v2-medium side. It also has a radio selector, allows you to select the output of your favorite model, and display a simple verification message when making a choice.
In conclusion, by combining the stability of the State-the-The-Art construction app for information-an-gradio app, you have seen how to protect yourself, and compare, and send a marvelous vision. From A / BB-Instruction Indicators to change the campaign property on a scale, AI strengths provide performance, AI flexibility provides efficiency, operation, and social support that transform your content pipe.
Look Colab Notebook. Don't forget to follow Sane and join ours Telegraph station including LinkedIn Grtopic. Don't forget to join ours 90k + ml subreddit. Assurance and partnerships, please speak to us.
🔥 [Register Now] Summit of the Minicon Virtual in Agentic AI: Free Registration + Certificate of Before Hour 4 Hour Court (May 21, 9 AM

Nikhil is a student of students in MarktechPost. Pursuing integrated graduates combined in the Indian Institute of Technology, Kharagpur. Nikhl is a UI / ML enthusiasm that searches for applications such as biomoutomostoments and biomedical science. After a solid in the Material Science, he examines new development and developing opportunities to contribute.