Generative AI Notes

1. Introduction

Generative AI refers to deep learning models that can generate high-quality text, images, and other content based on the data they were trained on.

2. Core Technologies

3. Example: Stable Diffusion Concept

Stable Diffusion works by:

  1. Forward Diffusion: Adding noise to an image until it is random noise.
  2. Reverse Diffusion: Learning to remove noise to recover the image.
  3. Text Conditioning: Using CLIP to guide the denoising process based on a text prompt.

4. Tools and Libraries

from diffusers import StableDiffusionPipeline
import torch

model_id = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to("cuda")

prompt = "a photo of an astronaut riding a horse on mars"
image = pipe(prompt).images[0]  
image.save("astronaut_rides_horse.png")