aramkris's picture
Update app.py
d06b652
Raw History Blame Contribute Delete
1.08 kB
import gradio as gr
import os
import torch
from diffusers import StableDiffusionPipeline
#print(f"Is CUDA available: {torch.cuda.is_available()}")
#if torch.cuda.is_available():
# pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16, revision="fp16", use_auth_token=os.getenv("HUGGING_FACE_HUB_TOKEN"))
# pipe = pipe.to("cuda")
#else:
pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", use_auth_token=os.getenv("HUGGING_FACE_HUB_TOKEN"))
# prompt = "a photo of an astronaut riding a horse on mars"
# image = pipe(prompt).images[0]
title = "Stable Diffusion Demo"
description = "Just trying Stable Diffusion Demo"
def inference(text):
output_sd = pipe(text).images[0]
return [output_sd]
io = gr.Interface(
inference,
gr.Textbox(lines=3),
outputs=[
gr.Image(type="pil", label="Stable Diffusion"),
],
title=title,
description=description,
)
io.launch()
# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
# iface.launch()