Update app.py
Browse files
app.py
CHANGED
@@ -1,38 +1,29 @@
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
-
from diffusers import
|
4 |
|
5 |
def generate_image(prompt):
|
6 |
try:
|
7 |
-
#
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
12 |
|
13 |
-
#
|
14 |
-
|
15 |
-
'codermert/ezelll_flux',
|
16 |
-
weight_name='flux_train_replicate.safetensors'
|
17 |
-
)
|
18 |
-
|
19 |
-
# Görsel oluştur
|
20 |
-
image = pipeline(prompt).images[0]
|
21 |
return image
|
22 |
except Exception as e:
|
23 |
return str(e)
|
24 |
|
25 |
-
# Gradio
|
26 |
-
|
27 |
-
|
28 |
-
gr.
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
generate_btn = gr.Button("Görsel Oluştur")
|
35 |
-
generate_btn.click(fn=generate_image, inputs=[text_input], outputs=[image_output])
|
36 |
|
37 |
-
|
38 |
-
iface.queue().launch(ssr_mode=False)
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
+
from diffusers import StableDiffusionPipeline
|
4 |
|
5 |
def generate_image(prompt):
|
6 |
try:
|
7 |
+
# Model yükleme
|
8 |
+
model_id = "runwayml/stable-diffusion-v1-5"
|
9 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
10 |
+
model_id,
|
11 |
+
torch_dtype=torch.float32
|
12 |
+
).to('cpu')
|
13 |
|
14 |
+
# Görsel oluşturma
|
15 |
+
image = pipe(prompt).images[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
return image
|
17 |
except Exception as e:
|
18 |
return str(e)
|
19 |
|
20 |
+
# Gradio arayüzü
|
21 |
+
demo = gr.Interface(
|
22 |
+
fn=generate_image,
|
23 |
+
inputs=gr.Textbox(label="Prompt'unuzu girin"),
|
24 |
+
outputs=gr.Image(label="Oluşturulan Görsel"),
|
25 |
+
title="Görsel Oluşturucu",
|
26 |
+
description="Bir prompt girin ve görsel oluşturun"
|
27 |
+
)
|
|
|
|
|
|
|
28 |
|
29 |
+
demo.launch(debug=True, share=False)
|
|