Spaces:
Runtime error
Runtime error
import gradio as gr | |
import torch | |
from torch import autocast | |
from diffusers import StableDiffusionPipeline | |
from datasets import load_dataset | |
from PIL import Image | |
import re | |
model_id = "CompVis/stable-diffusion-v1-4" | |
device = "cuda" | |
pipe = StableDiffusionPipeline.from_pretrained(model_id, use_auth_token=True) | |
pipe = pipe.to(device) | |
def infer(prompt): | |
with autocast("cuda"): | |
images_list = pipe( | |
[prompt])['sample'] | |
return images_list | |
prompt = 'a perfect photo of a sunset on a Greek beach' | |
intf = gr.Interface(fn = infer, inputs = prompt, outputs = gr.outputs.Image()) | |
intf.launch() |