Generate image for free using google collab – with source code

my hobby is exploring new things, in this blog i am going tell about how to generate image using google collab

just open google collab, then install some depantancies

bash
!pip -q install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
!pip -q install diffusers transformers accelerate safetensors

then use this code


import torch
from diffusers import AutoPipelineForText2Image
from PIL import Image
from IPython.display import display

device = "cuda" if torch.cuda.is_available() else "cpu" dtype = torch.float16 if device == "cuda" else torch.float32

model_id = "stabilityai/sd-turbo" # small & quick pipe = AutoPipelineForText2Image.from_pretrained( modelid, torchdtype=dtype, use_safetensors=True ).to(device)

// small memory optimizations

pipe.enableattentionslicing() pipe.enablevaetiling()

prompt = "give logo for pwntrends.com , cyberpunk theme, simple" image = pipe( prompt, numinferencesteps=4, # 1–4 for SD-Turbo guidance_scale=0.0, # 0.0–1.5 works best width=512, height=512 ).images[0]

image.save("/content/logo1.png") display(image) print("Saved to /content/logo1.png")

in this code customize your prompt

prompt = "give logo for pwntrends.com ,  cyberpunk theme, simple"

oh no its generating meaning less image

eventhogh i write blogs , beacuse i explore new things thats it

thank yo you for reading my blog, i will meet you in my next blog

Bye!!!!!!!!!!!

Leave a Reply

Your email address will not be published. Required fields are marked *