Update app.py
Browse files
app.py
CHANGED
@@ -1,29 +1,38 @@
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
-
from diffusers import
|
4 |
|
5 |
def generate_image(prompt):
|
6 |
try:
|
7 |
# Model yükleme
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
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 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
|
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
+
from diffusers import DiffusionPipeline
|
4 |
|
5 |
def generate_image(prompt):
|
6 |
try:
|
7 |
# Model yükleme
|
8 |
+
pipe = DiffusionPipeline.from_pretrained(
|
9 |
+
"runwayml/stable-diffusion-v1-5",
|
10 |
+
torch_dtype=torch.float32,
|
11 |
+
use_safetensors=True
|
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 f"Hata oluştu: {str(e)}"
|
19 |
|
20 |
# Gradio arayüzü
|
21 |
+
with gr.Blocks() as demo:
|
22 |
+
gr.Markdown("# Görsel Oluşturucu")
|
23 |
+
with gr.Row():
|
24 |
+
text_input = gr.Textbox(
|
25 |
+
label="Prompt'unuzu girin",
|
26 |
+
placeholder="Örnek: zehra bir portre"
|
27 |
+
)
|
28 |
+
image_output = gr.Image(label="Oluşturulan Görsel")
|
29 |
+
|
30 |
+
generate_btn = gr.Button("Görsel Oluştur")
|
31 |
+
generate_btn.click(
|
32 |
+
fn=generate_image,
|
33 |
+
inputs=[text_input],
|
34 |
+
outputs=[image_output]
|
35 |
+
)
|
36 |
|
37 |
+
if __name__ == "__main__":
|
38 |
+
demo.launch(show_error=True)
|