Will-uob's picture
Is work?
2b83f19
raw
history blame
814 Bytes
import gradio as gr
from torch import autocast
from diffusers import StableDiffusionPipeline
import re
import os
import requests
def greet(name):
return "Hello " + name + "!!"
def create_waifu(prompt):
pipe = StableDiffusionPipeline.from_pretrained(
'hakurei/waifu-diffusion',
torch_dtype=torch.float32
).to('cuda')
with autocast("cuda"):
image = pipe(prompt, guidance_scale=6)[0][0]
return image
"""
Interface class is initialized with three required parameters
- fn: the function to wrap a UI around
- inputs: components to use for the input
- outputs: which components to use for the output
"""
iface = gr.Interface(fn=greet,
inputs=gr.Textbox(lines=1, placeholder="Please enter your prompt..."),
outputs="image")
iface.launch()