text_to_image2 / app.py
AbdulRahim07's picture
Create app.py
6069e8e
raw
history blame contribute delete
515 Bytes
import transformers
import gradio as gr
from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler
import torch
model_id = "stabilityai/stable-diffusion-2"
scheduler = EulerDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler")
pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, torch_dtype=torch.float16)
pipe = pipe.to("cuda")
def imgtext(inp):
image = pipe(inp).images[0]
return image
wp=gr.Interface(fn=imgtext,inputs="text",outputs="image")
wp.launch()