testt / app.py
codermert's picture
Update app.py
7ab00ee verified
raw
history blame
773 Bytes
import gradio as gr
import torch
from diffusers import StableDiffusionPipeline
def generate_image(prompt):
try:
# Model yükleme
model_id = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(
model_id,
torch_dtype=torch.float32
).to('cpu')
# Görsel oluşturma
image = pipe(prompt).images[0]
return image
except Exception as e:
return str(e)
# Gradio arayüzü
demo = gr.Interface(
fn=generate_image,
inputs=gr.Textbox(label="Prompt'unuzu girin"),
outputs=gr.Image(label="Oluşturulan Görsel"),
title="Görsel Oluşturucu",
description="Bir prompt girin ve görsel oluşturun"
)
demo.launch(debug=True, share=False)