File size: 639 Bytes
a1e4316
 
fc4eaf7
 
948c263
338ad64
 
b632ef5
 
a1e4316
 
 
 
 
158b294
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import gradio as gr 
from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler
import torch

model_id = "stabilityai/stable-diffusion-2"
scheduler = EulerDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler")

pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, revision="fp16", torch_dtype=torch.float16)

def txt2img(prompt):
  image = pipe(prompt, height=768, width=768, guidance_scale = 10).images[0]
  # image.save("sd_image.png")
  return image
    
gr.Interface(txt2img, gr.Text(), gr.Image(), title = 'Stable Diffusion 2.0 Colab with Gradio UI').launch(share = False, debug = True)