Update app.py
Browse files
app.py
CHANGED
|
@@ -25,13 +25,23 @@ def chat_fn(message, history):
|
|
| 25 |
yield f"Hata: {str(e)}"
|
| 26 |
|
| 27 |
def image_fn(prompt):
|
| 28 |
-
if not prompt:
|
|
|
|
|
|
|
|
|
|
| 29 |
try:
|
| 30 |
-
|
| 31 |
-
return
|
| 32 |
except Exception as e:
|
| 33 |
-
print(f"
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
# Arayüz
|
| 37 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue")) as demo:
|
|
|
|
| 25 |
yield f"Hata: {str(e)}"
|
| 26 |
|
| 27 |
def image_fn(prompt):
|
| 28 |
+
if not prompt:
|
| 29 |
+
return None
|
| 30 |
+
|
| 31 |
+
# 1. Deneme: En hızlı model (SDXL Turbo)
|
| 32 |
try:
|
| 33 |
+
image = client.text_to_image(prompt, model="stabilityai/sdxl-turbo")
|
| 34 |
+
return image
|
| 35 |
except Exception as e:
|
| 36 |
+
print(f"SDXL Turbo Hatası: {e}. Yedek modele geçiliyor...")
|
| 37 |
+
|
| 38 |
+
# 2. Deneme: En kararlı yedek model (Stable Diffusion v1.5)
|
| 39 |
+
try:
|
| 40 |
+
image = client.text_to_image(prompt, model="runwayml/stable-diffusion-v1-5")
|
| 41 |
+
return image
|
| 42 |
+
except Exception as e2:
|
| 43 |
+
print(f"Yedek Model Hatası: {e2}")
|
| 44 |
+
return None
|
| 45 |
|
| 46 |
# Arayüz
|
| 47 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue")) as demo:
|