zhiweili commited on
Commit
ca58311
·
1 Parent(s): 1f492ec

fix not defined

Browse files
Files changed (2) hide show
  1. app_base.py +1 -1
  2. enhance_utils.py +18 -3
app_base.py CHANGED
@@ -55,7 +55,7 @@ def create_demo() -> gr.Blocks:
55
  guidance_scale,
56
  )
57
  run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
58
- enhanced_image = enhance_image(res_image, enhance_face)
59
  run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
60
 
61
  return enhanced_image, res_image, time_cost_str
 
55
  guidance_scale,
56
  )
57
  run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
58
+ enhanced_image = enhance_image(res_image)
59
  run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
60
 
61
  return enhanced_image, res_image, time_cost_str
enhance_utils.py CHANGED
@@ -2,17 +2,32 @@ import os
2
  import torch
3
  import cv2
4
  import numpy as np
 
5
 
6
  from PIL import Image
7
  from gfpgan.utils import GFPGANer
8
  from basicsr.archs.srvgg_arch import SRVGGNetCompact
9
  from realesrgan.utils import RealESRGANer
10
 
11
- os.system("pip freeze")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  if not os.path.exists('GFPGANv1.4.pth'):
13
- os.system("wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.4.pth -P .")
14
  if not os.path.exists('realesr-general-x4v3.pth'):
15
- os.system("wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth -P .")
16
 
17
  os.makedirs('output', exist_ok=True)
18
 
 
2
  import torch
3
  import cv2
4
  import numpy as np
5
+ import subprocess
6
 
7
  from PIL import Image
8
  from gfpgan.utils import GFPGANer
9
  from basicsr.archs.srvgg_arch import SRVGGNetCompact
10
  from realesrgan.utils import RealESRGANer
11
 
12
+
13
+ def runcmd(cmd, verbose = False, *args, **kwargs):
14
+
15
+ process = subprocess.Popen(
16
+ cmd,
17
+ stdout = subprocess.PIPE,
18
+ stderr = subprocess.PIPE,
19
+ text = True,
20
+ shell = True
21
+ )
22
+ std_out, std_err = process.communicate()
23
+ if verbose:
24
+ print(std_out.strip(), std_err)
25
+ pass
26
+
27
  if not os.path.exists('GFPGANv1.4.pth'):
28
+ runcmd("wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.4.pth -P .")
29
  if not os.path.exists('realesr-general-x4v3.pth'):
30
+ runcmd("wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth -P .")
31
 
32
  os.makedirs('output', exist_ok=True)
33