Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -160,26 +160,27 @@ def infer(prompt, neg, seed, rand, w, h, cfg, steps, scheduler_type,
|
|
| 160 |
|
| 161 |
gallery_items = [(item[0], item[1]) for item in history]
|
| 162 |
# tables_html = "".join(f'<div style="margin-bottom:12px">{make_html_table(item[1])}</div>' for item in history)
|
| 163 |
-
del img
|
| 164 |
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
|
|
|
|
|
|
| 172 |
|
| 173 |
except RuntimeError as e:
|
| 174 |
-
# CUDA Out of Memory
|
| 175 |
-
error_message = f"
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
|
|
|
| 181 |
|
| 182 |
-
|
| 183 |
# CSS 設定(ダークモード強制防止+カフェ風テーマ)
|
| 184 |
css = """
|
| 185 |
@import url('https://fonts.googleapis.com/css2?family=Playpen+Sans+Hebrew:wght@100;200;300;400;500;600;700;800&display=swap');
|
|
|
|
| 160 |
|
| 161 |
gallery_items = [(item[0], item[1]) for item in history]
|
| 162 |
# tables_html = "".join(f'<div style="margin-bottom:12px">{make_html_table(item[1])}</div>' for item in history)
|
|
|
|
| 163 |
|
| 164 |
+
import gc
|
| 165 |
+
import torch
|
| 166 |
+
def process_image(img, gallery_items): # Assuming this is part of a function
|
| 167 |
+
try:
|
| 168 |
+
gc.collect()
|
| 169 |
+
# Clear PyTorch's cache if GPU memory is being used
|
| 170 |
+
if torch.cuda.is_available():
|
| 171 |
+
torch.cuda.empty_cache()
|
| 172 |
+
return img, gallery_items
|
| 173 |
|
| 174 |
except RuntimeError as e:
|
| 175 |
+
# Catch errors like CUDA Out of Memory
|
| 176 |
+
error_message = f"error in generate: {e}\n\n"
|
| 177 |
+
if "CUDA out of memory" in str(e):
|
| 178 |
+
error_message += "memory error"
|
| 179 |
+
else:
|
| 180 |
+
error_message += "other error"
|
| 181 |
+
print(error_message) # Output to server logs
|
| 182 |
+
return None, None
|
| 183 |
|
|
|
|
| 184 |
# CSS 設定(ダークモード強制防止+カフェ風テーマ)
|
| 185 |
css = """
|
| 186 |
@import url('https://fonts.googleapis.com/css2?family=Playpen+Sans+Hebrew:wght@100;200;300;400;500;600;700;800&display=swap');
|