Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
22 |
-
|
23 |
-
|
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 |
|