52Hz commited on
Commit
22a5072
·
1 Parent(s): de39981

Update main_test_SRMNet.py

Browse files
Files changed (1) hide show
  1. main_test_SRMNet.py +12 -1
main_test_SRMNet.py CHANGED
@@ -13,6 +13,17 @@ import torch.nn.functional as F
13
  from natsort import natsorted
14
  from model.SRMNet import SRMNet
15
 
 
 
 
 
 
 
 
 
 
 
 
16
  def main():
17
  parser = argparse.ArgumentParser(description='Demo Image Denoising')
18
  parser.add_argument('--input_dir', default='test/', type=str, help='Input images')
@@ -63,7 +74,7 @@ def main():
63
 
64
  f = os.path.splitext(os.path.split(file_)[-1])[0]
65
  save_img((os.path.join(out_dir, f + '.png')), restored)
66
-
67
 
68
  def save_img(filepath, img):
69
  cv2.imwrite(filepath, cv2.cvtColor(img, cv2.COLOR_RGB2BGR))
 
13
  from natsort import natsorted
14
  from model.SRMNet import SRMNet
15
 
16
+ def clean_folder(folder):
17
+ for filename in os.listdir(folder):
18
+ file_path = os.path.join(folder, filename)
19
+ try:
20
+ if os.path.isfile(file_path) or os.path.islink(file_path):
21
+ os.unlink(file_path)
22
+ elif os.path.isdir(file_path):
23
+ shutil.rmtree(file_path)
24
+ except Exception as e:
25
+ print('Failed to delete %s. Reason: %s' % (file_path, e))
26
+
27
  def main():
28
  parser = argparse.ArgumentParser(description='Demo Image Denoising')
29
  parser.add_argument('--input_dir', default='test/', type=str, help='Input images')
 
74
 
75
  f = os.path.splitext(os.path.split(file_)[-1])[0]
76
  save_img((os.path.join(out_dir, f + '.png')), restored)
77
+ clean_folder(inp_dir)
78
 
79
  def save_img(filepath, img):
80
  cv2.imwrite(filepath, cv2.cvtColor(img, cv2.COLOR_RGB2BGR))