File size: 545 Bytes
5244c19 3b213f1 5244c19 3b213f1 fbe7c5b 3b213f1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import gradio as gr
import torch
from torch import autocast
from diffusers import StableDiffusionPipeline
def get_stable_diffusion_random_image(prompt):
model_id = "CompVis/stable-diffusion-v1-4"
device = "cuda"
pipe = StableDiffusionPipeline.from_pretrained(model_id, use_auth_token=True)
pipe = pipe.to(device)
with autocast("cuda"):
image = pipe(prompt, guidance_scale=7.5)
return image
iface = gr.Interface(fn=get_stable_diffusion_random_image, inputs="text", outputs="image")
iface.launch(share=True) |