Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -219,6 +219,9 @@ def infer(prompt, neg, seed, rand, w, h, cfg, steps, scheduler_type,
|
|
| 219 |
filepath = f"temp_{filename}" # ここで一時ファイルのパスを定義
|
| 220 |
|
| 221 |
try:
|
|
|
|
|
|
|
|
|
|
| 222 |
|
| 223 |
if rand:
|
| 224 |
seed = random.randint(0, MAX_SEED)
|
|
@@ -302,9 +305,9 @@ def infer(prompt, neg, seed, rand, w, h, cfg, steps, scheduler_type,
|
|
| 302 |
gallery_items = [(item[2], item[1].replace("|-|", "\n")) for item in history]
|
| 303 |
|
| 304 |
processed_img, processed_gallery_items = process_image(img, gallery_items)
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
latest_caption_table = make_html_table(caption_text)
|
| 309 |
return processed_img, processed_gallery_items, latest_caption_table
|
| 310 |
|
|
|
|
| 219 |
filepath = f"temp_{filename}" # ここで一時ファイルのパスを定義
|
| 220 |
|
| 221 |
try:
|
| 222 |
+
gc.collect() # 追加
|
| 223 |
+
if torch.cuda.is_available(): # 追加
|
| 224 |
+
torch.cuda.empty_cache() # 追加
|
| 225 |
|
| 226 |
if rand:
|
| 227 |
seed = random.randint(0, MAX_SEED)
|
|
|
|
| 305 |
gallery_items = [(item[2], item[1].replace("|-|", "\n")) for item in history]
|
| 306 |
|
| 307 |
processed_img, processed_gallery_items = process_image(img, gallery_items)
|
| 308 |
+
if processed_img is None or processed_gallery_items is None:
|
| 309 |
+
print("Image processing failed, skipping history update.")
|
| 310 |
+
return None, history_gallery, history_tables
|
| 311 |
latest_caption_table = make_html_table(caption_text)
|
| 312 |
return processed_img, processed_gallery_items, latest_caption_table
|
| 313 |
|