GPTSTTS / app.py
seawolf2357's picture
Update app.py
b4f27ac verified
raw
history blame
727 Bytes
import gradio as gr
from transformers import StableDiffusionPipeline
import torch
# ๋ชจ๋ธ ์ดˆ๊ธฐํ™”
pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5",
use_auth_token=True)
pipe.to("cuda" if torch.cuda.is_available() else "cpu")
# ํ…์ŠคํŠธ ํ”„๋กฌํ”„ํŠธ๋กœ๋ถ€ํ„ฐ ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•˜๋Š” ํ•จ์ˆ˜
def generate_image(prompt):
with torch.autocast("cuda"):
image = pipe(prompt).images[0]
return image
# Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ •์˜
iface = gr.Interface(
fn=generate_image,
inputs=gr.Textbox(label="Enter a prompt for the AI to generate an image"),
outputs=gr.Image(type="pil"),
)
# ์ธํ„ฐํŽ˜์ด์Šค ์‹คํ–‰
iface.launch()