gy65896 commited on
Commit
1ac3262
·
verified ·
1 Parent(s): 4730297

Upload 18 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ img_file/abstract.jpg filter=lfs diff=lfs merge=lfs -text
37
+ img_file/OneRestore_poster.png filter=lfs diff=lfs merge=lfs -text
38
+ img_file/pipeline.jpg filter=lfs diff=lfs merge=lfs -text
39
+ img_file/real.jpg filter=lfs diff=lfs merge=lfs -text
img_file/OneRestore_poster.png ADDED

Git LFS Details

  • SHA256: 86ee7b33d4e6b3024b12d60eb420a58b4f3b1cccb40f0569440a46e93daf816d
  • Pointer size: 133 Bytes
  • Size of remote file: 12 MB
img_file/abstract.jpg ADDED

Git LFS Details

  • SHA256: c3e79021de0ed441274a97a4c141c64e730293a95af65c3d963ee5cd3205ace1
  • Pointer size: 132 Bytes
  • Size of remote file: 1.8 MB
img_file/cal_psnr_ssim.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import cv2
3
+ import numpy as np
4
+ import random
5
+ from skimage.metrics import peak_signal_noise_ratio as compare_psnr
6
+ from skimage.metrics import mean_squared_error as compare_mse
7
+ from skimage.metrics import structural_similarity as compare_ssim
8
+ # Modified function to add progress display using tqdm for better progress tracking
9
+ from tqdm import tqdm
10
+ import pandas as pd
11
+ # Updated function with progress display for PSNR and SSIM calculation
12
+ def calculate_psnr_ssim_with_progress(clear_folder, methods, degradation_types, win_size=7):
13
+ # Get list of all clear images
14
+ img_list = [img for img in os.listdir(clear_folder) if img.endswith('.png')]
15
+
16
+ # Initialize matrices to store mean PSNR and SSIM values
17
+ psnr_matrix = np.zeros((len(methods), len(degradation_types)))
18
+ ssim_matrix = np.zeros((len(methods), len(degradation_types)))
19
+
20
+ # Total number of tasks for progress tracking
21
+ total_tasks = len(methods) * len(degradation_types) * len(img_list)
22
+ print(len(methods), len(degradation_types), len(img_list))
23
+
24
+ # Create a progress bar
25
+ with tqdm(total=total_tasks, desc="Processing Images", unit="task") as pbar:
26
+ # Loop over methods
27
+ for k, method in enumerate(methods):
28
+ print(f"Processing method: {method}")
29
+
30
+ # Loop over degradation types
31
+ for j, degradation_type in enumerate(degradation_types):
32
+ psnr_values = []
33
+ ssim_values = []
34
+
35
+ # Loop over each image in the clear folder
36
+ for img_name in img_list:
37
+ clear_img_path = os.path.join(clear_folder, img_name)
38
+ degraded_img_path = f'./{method}/{degradation_type}/{img_name}'
39
+
40
+ # Read the clear and degraded images
41
+ clear_img = cv2.imread(clear_img_path) / 255.0
42
+ degraded_img = cv2.imread(degraded_img_path) / 255.0
43
+
44
+ # Ensure the images are read correctly
45
+ if clear_img is not None and degraded_img is not None:
46
+ # Compute PSNR and SSIM between clear and degraded image
47
+ psnr_value = compare_psnr(clear_img, degraded_img, data_range=1.0)
48
+
49
+ # Compute SSIM with specified window size and for multichannel images
50
+ ssim_value = compare_ssim(clear_img, degraded_img, multichannel=True,
51
+ win_size=min(win_size, clear_img.shape[0], clear_img.shape[1]),
52
+ channel_axis=-1, data_range=1.0)
53
+
54
+ # Store values
55
+ psnr_values.append(psnr_value)
56
+ ssim_values.append(ssim_value)
57
+
58
+ # Update progress bar after processing each image
59
+ pbar.update(1)
60
+
61
+ # Calculate mean PSNR and SSIM for the current method and degradation type
62
+ if psnr_values:
63
+ psnr_matrix[k, j] = np.mean(psnr_values)
64
+ if ssim_values:
65
+ ssim_matrix[k, j] = np.mean(ssim_values)
66
+
67
+ return psnr_matrix, ssim_matrix
68
+
69
+ def save_matrices_to_excel(psnr_matrix, ssim_matrix, methods, degradation_types, output_file='metrics.xlsx'):
70
+ # Create DataFrames for PSNR and SSIM matrices
71
+ psnr_df = pd.DataFrame(psnr_matrix, index=methods, columns=degradation_types)
72
+ ssim_df = pd.DataFrame(ssim_matrix, index=methods, columns=degradation_types)
73
+
74
+ # Create a writer to write both DataFrames to the same Excel file
75
+ with pd.ExcelWriter(output_file) as writer:
76
+ psnr_df.to_excel(writer, sheet_name='PSNR')
77
+ ssim_df.to_excel(writer, sheet_name='SSIM')
78
+
79
+ print(f'Matrices saved to {output_file}')
80
+
81
+ # Define the parameters
82
+ clear_folder = './00_gt'
83
+ methods = ['01_input', '02_MIRNet', '03_MPRNet', '04_MIRNetv2', '05_Restormer',
84
+ '06_DGUNet', '07_NAFNet', '08_SRUDC', '09_Fourmer', '10_OKNet', '11_AirNet',
85
+ '12_TransWeather', '13_WeatherDiff', '14_PromptIR', '15_WGWSNet', '16_OneRestore_visual', '17_OneRestore']
86
+ degradation_types = ['low', 'haze', 'rain', 'snow', 'low_haze', 'low_rain', 'low_snow', 'haze_rain', 'haze_snow', 'low_haze_rain', 'low_haze_snow']
87
+
88
+ # This is the function that will be used to calculate the PSNR and SSIM values across methods and degradation types
89
+ # To use the function, uncomment the line below and ensure the file paths are set correctly in your environment
90
+
91
+
92
+ psnr_matrix, ssim_matrix = calculate_psnr_ssim_with_progress(clear_folder, methods, degradation_types)
93
+ save_matrices_to_excel(psnr_matrix, ssim_matrix, methods, degradation_types)
94
+
95
+
96
+
img_file/clear_img.jpg ADDED
img_file/control1.jpg ADDED
img_file/control2.jpg ADDED
img_file/depth_map.jpg ADDED
img_file/l+h+r.jpg ADDED
img_file/l+h+s.jpg ADDED
img_file/light_map.jpg ADDED
img_file/logo_onerestore.png ADDED
img_file/metric.png ADDED
img_file/metrics_CDD-11_psnr_ssim.xlsx ADDED
Binary file (15.7 kB). View file
 
img_file/pipeline.jpg ADDED

Git LFS Details

  • SHA256: 80600ecac7ff326ef3d322ea4db08d27edf3595befdba088deb783ceb260afa3
  • Pointer size: 132 Bytes
  • Size of remote file: 2.72 MB
img_file/rain_mask.jpg ADDED
img_file/real.jpg ADDED

Git LFS Details

  • SHA256: bdd33e434a8370527d4c8d00603ce7b2b3d981eb5db58c38fe3ec32ed6a73c2d
  • Pointer size: 132 Bytes
  • Size of remote file: 1.16 MB
img_file/snow_mask.png ADDED
img_file/syn.jpg ADDED