cocoat commited on
Commit
1d4f2a9
·
verified ·
1 Parent(s): dcd1459

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -163,21 +163,21 @@ def infer(prompt, neg, seed, rand, w, h, cfg, steps, scheduler_type,
163
  del img
164
 
165
  # Pythonのガベージコレクタを強制実行し、不要なメモリを回収します
166
- import gc
167
- gc.collect()
168
  # GPUメモリを使用している場合、PyTorchのキャッシュをクリアします
169
- if torch.cuda.is_available():
170
- torch.cuda.empty_cache()
171
- return img, gallery_items
172
 
173
- except RuntimeError as e:
174
  # CUDA Out of Memoryなどのエラーをキャッチ
175
- error_message = f"画像生成中にエラーが発生しました: {e}\n\n"
176
- if "CUDA out of memory" in str(e):
177
- error_message += "GPUメモリが不足している可能性があります。画像のサイズを小さくするか、ステップ数を減らしてみてください。"
178
- else:
179
- error_message += "原因不明のエラーです。入力パラメータを確認してください。"
180
- print(error_message) # サーバーログに出力
181
 
182
 
183
  # CSS 設定(ダークモード強制防止+カフェ風テーマ)
 
163
  del img
164
 
165
  # Pythonのガベージコレクタを強制実行し、不要なメモリを回収します
166
+ import gc
167
+ gc.collect()
168
  # GPUメモリを使用している場合、PyTorchのキャッシュをクリアします
169
+ if torch.cuda.is_available():
170
+ torch.cuda.empty_cache()
171
+ return img, gallery_items
172
 
173
+ except RuntimeError as e:
174
  # CUDA Out of Memoryなどのエラーをキャッチ
175
+ error_message = f"画像生成中にエラーが発生しました: {e}\n\n"
176
+ if "CUDA out of memory" in str(e):
177
+ error_message += "GPUメモリが不足している可能性があります。画像のサイズを小さくするか、ステップ数を減らしてみてください。"
178
+ else:
179
+ error_message += "原因不明のエラーです。入力パラメータを確認してください。"
180
+ print(error_message) # サーバーログに出力
181
 
182
 
183
  # CSS 設定(ダークモード強制防止+カフェ風テーマ)