File size: 773 Bytes
8923aba
 
7ab00ee
031ae3b
f726406
a1538f9
7ab00ee
 
 
 
 
 
a1538f9
7ab00ee
 
a1538f9
 
 
 
7ab00ee
 
 
 
 
 
 
 
9f261f3
7ab00ee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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)