Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -105,25 +105,23 @@ def load_img2img():
|
|
| 105 |
return pipe_img2img
|
| 106 |
|
| 107 |
# === HILFSFUNKTION FÜR ROBUSTE ZWISCHENSPEICHERUNG ===
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
def save_with_fallback(image):
|
| 109 |
try:
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
)
|
| 116 |
-
path = temp_file.name
|
| 117 |
-
temp_file.close()
|
| 118 |
-
|
| 119 |
-
image.save(path, "PNG")
|
| 120 |
-
print(f"HF-Temp gespeichert: {path}")
|
| 121 |
-
return path
|
| 122 |
except Exception as e:
|
| 123 |
print(f"Temp-Speicherung fehlgeschlagen: {e}")
|
| 124 |
return image
|
| 125 |
|
| 126 |
|
|
|
|
| 127 |
# === FUNKTIONEN ===
|
| 128 |
def text_to_image(prompt, steps, guidance_scale):
|
| 129 |
try:
|
|
|
|
| 105 |
return pipe_img2img
|
| 106 |
|
| 107 |
# === HILFSFUNKTION FÜR ROBUSTE ZWISCHENSPEICHERUNG ===
|
| 108 |
+
from gradio import TempFile
|
| 109 |
+
|
| 110 |
+
temp_file_manager = TempFile()
|
| 111 |
+
|
| 112 |
def save_with_fallback(image):
|
| 113 |
try:
|
| 114 |
+
with temp_file_manager as temp_file:
|
| 115 |
+
path = temp_file.name
|
| 116 |
+
image.save(path, "PNG")
|
| 117 |
+
print(f"Gradio-Temp gespeichert: {path}")
|
| 118 |
+
return path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
except Exception as e:
|
| 120 |
print(f"Temp-Speicherung fehlgeschlagen: {e}")
|
| 121 |
return image
|
| 122 |
|
| 123 |
|
| 124 |
+
|
| 125 |
# === FUNKTIONEN ===
|
| 126 |
def text_to_image(prompt, steps, guidance_scale):
|
| 127 |
try:
|