Spaces:
Runtime error
Runtime error
File size: 839 Bytes
cb85ac7 f8348ee cb85ac7 a3f8778 cb85ac7 f61f64b cb85ac7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
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
import os
model_id = "CompVis/stable-diffusion-v1-4"
device = "cuda"
pipe = StableDiffusionPipeline.from_pretrained(model_id, use_auth_token=os.environ["auth_token"], revision="fp16", torch_dtype=torch.float16)
pipe = pipe.to(device)
def infer(prompt):
with autocast("cuda"):
images_list = pipe(
[prompt])['sample']
return images_list
text = gr.Textbox(
label="Enter your prompt",
show_label=False,
max_lines=1,
placeholder="Enter your prompt")
gallery = gr.Gallery(
label="Generated images",
show_label=False)
intf = gr.Interface(fn = infer, inputs = text, outputs = gallery)
intf.launch() |