aiqtech commited on
Commit
bb8f0a5
·
verified ·
1 Parent(s): ea4e2a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -299,8 +299,14 @@ def image_to_3d(trial_id: str, seed: int, randomize_seed: bool, ss_guidance_stre
299
  return None, None
300
 
301
  return generated_image
 
 
 
302
  finally:
303
- clear_gpu_memory() # 함수 종료 시 메모리 정리
 
 
 
304
 
305
  def clear_gpu_memory():
306
  """GPU 메모리를 더 철저하게 정리하는 함수"""
@@ -414,9 +420,15 @@ def text_to_image(prompt: str, height: int, width: int, steps: int, scales: floa
414
  gc.collect()
415
 
416
  return generated_image
 
 
 
417
  finally:
418
- clear_gpu_memory() # 함수 종료 시 메모리 정리
419
-
 
 
 
420
  css = """
421
  footer {
422
  visibility: hidden;
 
299
  return None, None
300
 
301
  return generated_image
302
+ except Exception as e:
303
+ print(f"Error in image generation: {str(e)}")
304
+ return None
305
  finally:
306
+ if torch.cuda.is_available():
307
+ torch.cuda.empty_cache()
308
+ torch.cuda.synchronize()
309
+ gc.collect()
310
 
311
  def clear_gpu_memory():
312
  """GPU 메모리를 더 철저하게 정리하는 함수"""
 
420
  gc.collect()
421
 
422
  return generated_image
423
+ except Exception as e:
424
+ print(f"Error in image generation: {str(e)}")
425
+ return None
426
  finally:
427
+ if torch.cuda.is_available():
428
+ torch.cuda.empty_cache()
429
+ torch.cuda.synchronize()
430
+ gc.collect()
431
+
432
  css = """
433
  footer {
434
  visibility: hidden;