52Hz commited on
Commit
60e1569
1 Parent(s): c5462c7

Update main_test_SRMNet.py

Browse files
Files changed (1) hide show
  1. main_test_SRMNet.py +12 -0
main_test_SRMNet.py CHANGED
@@ -66,6 +66,7 @@ def main():
66
  f = os.path.splitext(os.path.split(file_)[-1])[0]
67
  save_img((os.path.join(args.result_dir, f + '.png')), restored)
68
  print('{}'.format(os.path.join(args.result_dir, f + '.png')))
 
69
  print('finish !')
70
 
71
 
@@ -99,6 +100,17 @@ def load_checkpoint(model, weights):
99
  name = k[7:] # remove `module.`
100
  new_state_dict[name] = v
101
  model.load_state_dict(new_state_dict)
 
 
 
 
 
 
 
 
 
 
 
102
 
103
 
104
  if __name__ == '__main__':
 
66
  f = os.path.splitext(os.path.split(file_)[-1])[0]
67
  save_img((os.path.join(args.result_dir, f + '.png')), restored)
68
  print('{}'.format(os.path.join(args.result_dir, f + '.png')))
69
+ clean_folder(args.input_dir)
70
  print('finish !')
71
 
72
 
 
100
  name = k[7:] # remove `module.`
101
  new_state_dict[name] = v
102
  model.load_state_dict(new_state_dict)
103
+
104
+ def clean_folder(folder):
105
+ for filename in os.listdir(folder):
106
+ file_path = os.path.join(folder, filename)
107
+ try:
108
+ if os.path.isfile(file_path) or os.path.islink(file_path):
109
+ os.unlink(file_path)
110
+ elif os.path.isdir(file_path):
111
+ shutil.rmtree(file_path)
112
+ except Exception as e:
113
+ print('Failed to delete %s. Reason: %s' % (file_path, e))
114
 
115
 
116
  if __name__ == '__main__':