ginipick commited on
Commit
f7cc5a8
·
verified ·
1 Parent(s): 3a47996

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -301,16 +301,12 @@ def _process(img: Image.Image, prompt: str | BoundingBox | None, bg_prompt: str
301
  new_size = (int(img.width * ratio), int(img.height * ratio))
302
  img = img.resize(new_size, Image.LANCZOS)
303
 
304
- # CUDA 메모리 관리 수정
305
- try:
306
- if torch.cuda.is_available():
307
- current_device = torch.cuda.current_device()
308
- with torch.cuda.device(current_device):
309
- torch.cuda.empty_cache()
310
- except Exception as e:
311
- print(f"CUDA memory management failed: {e}")
312
-
313
- with torch.cuda.amp.autocast(enabled=torch.cuda.is_available()):
314
  mask, bbox, time_log = _gpu_process(img, prompt)
315
  masked_alpha = apply_mask(img, mask, defringe=True)
316
 
 
301
  new_size = (int(img.width * ratio), int(img.height * ratio))
302
  img = img.resize(new_size, Image.LANCZOS)
303
 
304
+ # CUDA 메모리 관리
305
+ if torch.cuda.is_available():
306
+ torch.cuda.empty_cache()
307
+
308
+ # 새로운 autocast 구문 사용
309
+ with torch.amp.autocast('cuda', enabled=torch.cuda.is_available()):
 
 
 
 
310
  mask, bbox, time_log = _gpu_process(img, prompt)
311
  masked_alpha = apply_mask(img, mask, defringe=True)
312