|
import gradio as gr |
|
import torch |
|
from diffusers import StableDiffusionPipeline |
|
|
|
def generate_image(prompt): |
|
try: |
|
|
|
model_id = "runwayml/stable-diffusion-v1-5" |
|
pipe = StableDiffusionPipeline.from_pretrained( |
|
model_id, |
|
torch_dtype=torch.float32 |
|
).to('cpu') |
|
|
|
|
|
image = pipe(prompt).images[0] |
|
return image |
|
except Exception as e: |
|
return str(e) |
|
|
|
|
|
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) |