Phips commited on
Commit
7304764
·
1 Parent(s): 361972b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -13,19 +13,23 @@ from realesrgan.archs.srvgg_arch import SRVGGNetCompact
13
 
14
  last_file = None
15
  img_mode = "RGBA"
 
16
 
17
  def realesrgan(img, model_name, face_enhance):
18
- global last_file
19
-
 
 
 
 
 
 
 
 
 
20
  if not img:
21
  return
22
 
23
- # remove last upscale when doing this new upscale to prevent memory being full
24
- if last_file:
25
- print(f"Deleting {last_file} ...")
26
- os.remove(last_file)
27
- last_file = None
28
-
29
  imgwidth, imgheight = img.size
30
 
31
  if imgwidth > 1000 or imgheight > 1000:
@@ -112,6 +116,9 @@ def realesrgan(img, model_name, face_enhance):
112
  cv2.imwrite(out_filename, output)
113
  global last_file
114
  last_file = out_filename
 
 
 
115
  return out_filename
116
 
117
 
 
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
32
 
 
 
 
 
 
 
33
  imgwidth, imgheight = img.size
34
 
35
  if imgwidth > 1000 or imgheight > 1000:
 
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