Update app.py
Browse files
app.py
CHANGED
|
@@ -39,33 +39,63 @@ img_pipe = img_pipe.to("cpu")
|
|
| 39 |
|
| 40 |
def generate_image(prompt):
|
| 41 |
if not prompt.strip():
|
| 42 |
-
raise gr.Error("Prompt boş
|
| 43 |
|
| 44 |
image = img_pipe(
|
| 45 |
prompt,
|
| 46 |
-
|
|
|
|
|
|
|
| 47 |
).images[0]
|
| 48 |
|
| 49 |
return image
|
| 50 |
|
|
|
|
| 51 |
# ---------------- UI ----------------
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
)
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
gr.ChatInterface(chat_fn)
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
app.launch()
|
|
|
|
| 39 |
|
| 40 |
def generate_image(prompt):
|
| 41 |
if not prompt.strip():
|
| 42 |
+
raise gr.Error("Prompt boş")
|
| 43 |
|
| 44 |
image = img_pipe(
|
| 45 |
prompt,
|
| 46 |
+
height=512,
|
| 47 |
+
width=512,
|
| 48 |
+
num_inference_steps=12
|
| 49 |
).images[0]
|
| 50 |
|
| 51 |
return image
|
| 52 |
|
| 53 |
+
|
| 54 |
# ---------------- UI ----------------
|
| 55 |
+
import gradio as gr
|
| 56 |
+
|
| 57 |
+
theme = gr.themes.Soft(
|
| 58 |
+
primary_hue="blue",
|
| 59 |
+
secondary_hue="cyan",
|
| 60 |
+
neutral_hue="slate",
|
| 61 |
+
font=[gr.themes.GoogleFont("Inter")]
|
| 62 |
+
)
|
|
|
|
| 63 |
|
| 64 |
+
with gr.Blocks(
|
| 65 |
+
title="MaindAI",
|
| 66 |
+
theme=theme,
|
| 67 |
+
css="""
|
| 68 |
+
body { background: #0b1220; }
|
| 69 |
+
.gradio-container { max-width: 900px !important; }
|
| 70 |
+
footer { display: none !important; }
|
| 71 |
+
"""
|
| 72 |
+
) as app:
|
| 73 |
+
|
| 74 |
+
gr.Markdown("""
|
| 75 |
+
<div style="display:flex;align-items:center;gap:12px;">
|
| 76 |
+
<img src="file=Maindai.png" width="48">
|
| 77 |
+
<h1 style="color:#3b82f6;margin:0;">MaindAI</h1>
|
| 78 |
+
</div>
|
| 79 |
+
<p style="color:#94a3b8;">Chat & Görsel Üretim</p>
|
| 80 |
+
""")
|
| 81 |
+
|
| 82 |
+
with gr.Tabs():
|
| 83 |
+
|
| 84 |
+
with gr.Tab("💬 Chat"):
|
| 85 |
gr.ChatInterface(chat_fn)
|
| 86 |
+
|
| 87 |
+
with gr.Tab("🎨 Görsel"):
|
| 88 |
+
prompt = gr.Textbox(
|
| 89 |
+
label="Görsel açıklaması",
|
| 90 |
+
placeholder="örnek: cyberpunk mavi tonlarda bir şehir"
|
| 91 |
+
)
|
| 92 |
+
btn = gr.Button("Oluştur", variant="primary")
|
| 93 |
+
img = gr.Image(height=512)
|
| 94 |
+
|
| 95 |
+
btn.click(
|
| 96 |
+
generate_image,
|
| 97 |
+
inputs=prompt,
|
| 98 |
+
outputs=img
|
| 99 |
+
)
|
| 100 |
|
| 101 |
app.launch()
|