Spaces:
Running
Running
Update main_test_SUNet.py
Browse files- main_test_SUNet.py +11 -1
main_test_SUNet.py
CHANGED
@@ -18,7 +18,16 @@ from model.SUNet import SUNet_model
|
|
18 |
with open('training.yaml', 'r') as config:
|
19 |
opt = yaml.safe_load(config)
|
20 |
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
def main():
|
24 |
parser = argparse.ArgumentParser(description='Demo Image Restoration')
|
@@ -90,6 +99,7 @@ def main():
|
|
90 |
|
91 |
f = os.path.splitext(os.path.split(file_)[-1])[0]
|
92 |
save_img((os.path.join(out_dir, f + '.png')), restored)
|
|
|
93 |
|
94 |
def save_img(filepath, img):
|
95 |
cv2.imwrite(filepath, cv2.cvtColor(img, cv2.COLOR_RGB2BGR))
|
|
|
18 |
with open('training.yaml', 'r') as config:
|
19 |
opt = yaml.safe_load(config)
|
20 |
|
21 |
+
def clean_folder(folder):
|
22 |
+
for filename in os.listdir(folder):
|
23 |
+
file_path = os.path.join(folder, filename)
|
24 |
+
try:
|
25 |
+
if os.path.isfile(file_path) or os.path.islink(file_path):
|
26 |
+
os.unlink(file_path)
|
27 |
+
elif os.path.isdir(file_path):
|
28 |
+
shutil.rmtree(file_path)
|
29 |
+
except Exception as e:
|
30 |
+
print('Failed to delete %s. Reason: %s' % (file_path, e))
|
31 |
|
32 |
def main():
|
33 |
parser = argparse.ArgumentParser(description='Demo Image Restoration')
|
|
|
99 |
|
100 |
f = os.path.splitext(os.path.split(file_)[-1])[0]
|
101 |
save_img((os.path.join(out_dir, f + '.png')), restored)
|
102 |
+
clean_folder(inp_dir)
|
103 |
|
104 |
def save_img(filepath, img):
|
105 |
cv2.imwrite(filepath, cv2.cvtColor(img, cv2.COLOR_RGB2BGR))
|