Phips commited on
Commit
400c300
1 Parent(s): 7304764

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -14
app.py CHANGED
@@ -13,19 +13,15 @@ from realesrgan.archs.srvgg_arch import SRVGGNetCompact
13
 
14
  last_file = None
15
  img_mode = "RGBA"
16
- firstrun = True
17
 
18
  def realesrgan(img, model_name, face_enhance):
 
19
 
20
- # remove last upscale when doing this new upscale to prevent memory being full
21
- # added firstrun variable since I was running into global declaration problems?
22
- if not firstrun:
23
- global last_file
24
-
25
- if last_file:
26
- print(f"Deleting {last_file} ...")
27
- os.remove(last_file)
28
- last_file = None
29
 
30
  if not img:
31
  return
@@ -114,11 +110,7 @@ def realesrgan(img, model_name, face_enhance):
114
  extension = 'jpg'
115
  out_filename = f"output_{rnd_string(16)}.{extension}"
116
  cv2.imwrite(out_filename, output)
117
- global last_file
118
  last_file = out_filename
119
- if firstrun:
120
- global firstrun
121
- firstrun = False
122
  return out_filename
123
 
124
 
 
13
 
14
  last_file = None
15
  img_mode = "RGBA"
 
16
 
17
  def realesrgan(img, model_name, face_enhance):
18
+ global last_file
19
 
20
+ # remove last upscale when doing this new upscale to prevent memory being full
21
+ if last_file:
22
+ print(f"Deleting {last_file} ...")
23
+ os.remove(last_file)
24
+ last_file = None
 
 
 
 
25
 
26
  if not img:
27
  return
 
110
  extension = 'jpg'
111
  out_filename = f"output_{rnd_string(16)}.{extension}"
112
  cv2.imwrite(out_filename, output)
 
113
  last_file = out_filename
 
 
 
114
  return out_filename
115
 
116