JS6969 commited on
Commit
b7f0cd8
·
verified ·
1 Parent(s): b1ca0b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -287,7 +287,8 @@ def realesrgan(img, model_name, denoise_strength, face_enhance, outscale):
287
  # ----- CUDA / precision / tiling -----
288
  use_cuda = False
289
  try:
290
- use_cuda = hasattr(cv2, "cuda") and cv2.cuda.getCudaEnabledDeviceCount() > 0
 
291
  except Exception:
292
  use_cuda = False
293
  gpu_id = 0 if use_cuda else None
@@ -359,6 +360,7 @@ def render_progress(pct: float, text: str = "") -> str:
359
  label = f"<div style='font-size:12px;opacity:.8;margin-top:4px;'>{text} {pct:.1f}%</div>"
360
  return bar + label
361
 
 
362
  def batch_realesrgan(
363
  files: list, # from gr.Files (type='filepath')
364
  model_name: str,
 
287
  # ----- CUDA / precision / tiling -----
288
  use_cuda = False
289
  try:
290
+ import torch
291
+ use_cuda = torch.cuda.is_available()
292
  except Exception:
293
  use_cuda = False
294
  gpu_id = 0 if use_cuda else None
 
360
  label = f"<div style='font-size:12px;opacity:.8;margin-top:4px;'>{text} {pct:.1f}%</div>"
361
  return bar + label
362
 
363
+ @GPU()
364
  def batch_realesrgan(
365
  files: list, # from gr.Files (type='filepath')
366
  model_name: str,