ohayonguy commited on
Commit
6fe04b4
·
1 Parent(s): fc56fc6
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -29,7 +29,7 @@ model = SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=32, ups
29
  half = True if torch.cuda.is_available() else False
30
  upsampler = RealESRGANer(scale=4, model_path=realesr_model_path, model=model, tile=0, tile_pad=10, pre_pad=0, half=half)
31
 
32
- pmrf = MMSERectifiedFlow.from_pretrained('ohayonguy/PMRF_blind_face_image_restoration').to(device).to(torch.bfloat16)
33
 
34
  face_helper_dummy = FaceRestoreHelper(
35
  1,
@@ -56,6 +56,8 @@ def generate_reconstructions(pmrf_model, x, y, non_noisy_z0, num_flow_steps, dev
56
 
57
  return x_t_next.clip(0, 1).to(torch.float32)
58
 
 
 
59
  def enhance_face(img, face_helper, has_aligned, only_center_face=False, paste_back=True, scale=2):
60
  face_helper.clean_all()
61
 
@@ -100,6 +102,7 @@ def enhance_face(img, face_helper, has_aligned, only_center_face=False, paste_ba
100
  return face_helper.cropped_faces, face_helper.restored_faces, None
101
 
102
 
 
103
  @spaces.GPU()
104
  def inference(img, aligned, scale, num_steps):
105
  if scale > 4:
 
29
  half = True if torch.cuda.is_available() else False
30
  upsampler = RealESRGANer(scale=4, model_path=realesr_model_path, model=model, tile=0, tile_pad=10, pre_pad=0, half=half)
31
 
32
+ pmrf = MMSERectifiedFlow.from_pretrained('ohayonguy/PMRF_blind_face_image_restoration').to(device=device, dtype=torch.bfloat16)
33
 
34
  face_helper_dummy = FaceRestoreHelper(
35
  1,
 
56
 
57
  return x_t_next.clip(0, 1).to(torch.float32)
58
 
59
+ @torch.inference_mode()
60
+ @spaces.GPU()
61
  def enhance_face(img, face_helper, has_aligned, only_center_face=False, paste_back=True, scale=2):
62
  face_helper.clean_all()
63
 
 
102
  return face_helper.cropped_faces, face_helper.restored_faces, None
103
 
104
 
105
+ @torch.inference_mode()
106
  @spaces.GPU()
107
  def inference(img, aligned, scale, num_steps):
108
  if scale > 4: