File size: 473 Bytes
dd3cd32
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import gradio as gr
import torch
# from diffusers import DiffusionPipeline
from diffusers import StableDiffusionPipeline

SAFETENSORS_PATH = "./dreamshaper_5BakedVae.safetensors"

def generate(prompt):
    pipeline = StableDiffusionPipeline.from_pretrained(SAFETENSORS_PATH , torch_dtype = torch.float16 , use_safetensors = True)
    pipeline.to("cuda")
    return pipeline(prompt).images[0]

iface = gr.Interface(fn=generate, inputs="text", outputs="image")
iface.launch()