-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw_fig.py
55 lines (50 loc) · 2.14 KB
/
draw_fig.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import matplotlib.pyplot as plt
import re
train_psnr_bistlm_differ = []
valid_psnr_bistlm_differ = []
train_psnr_bistlm_fu = []
valid_psnr_bistlm_fu = []
epochs = list(range(1, 200+1)) # 假设有 200 个 epochs
#
file_path_bistlm_differ = "/home/ubuntu/ESTRNN_Trans/experiment/2024_03_31_15_16_26_ESTRNN_BSD_halfdata_epoch200_newbackbone_傅里叶_图片相减/log.txt"
with open(file_path_bistlm_differ, 'r') as file:
lines = file.readlines()
for line in lines:
if "[train]" in line and "PSNR" in line:
psnr_match = re.search(r'PSNR : (\d+\.\d+)', line)
if psnr_match:
psnr_value = float(psnr_match.group(1))
train_psnr_bistlm_differ.append(psnr_value)
elif "[valid]" in line and "PSNR" in line:
psnr_match = re.search(r'PSNR : (\d+\.\d+)', line)
if psnr_match:
psnr_value = float(psnr_match.group(1))
valid_psnr_bistlm_differ.append(psnr_value)
file_path_bistlm_fu = "/home/ubuntu/ESTRNN_Trans/experiment/2024_01_13_06_35_25_ESTRNN_BSD_halfdata_epoch200_newbackbone_傅里叶/log.txt"
with open(file_path_bistlm_fu, 'r') as file:
lines = file.readlines()
for line in lines:
if "[train]" in line and "PSNR" in line:
psnr_match = re.search(r'PSNR : (\d+\.\d+)', line)
if psnr_match:
psnr_value = float(psnr_match.group(1))
train_psnr_bistlm_fu.append(psnr_value)
elif "[valid]" in line and "PSNR" in line:
psnr_match = re.search(r'PSNR : (\d+\.\d+)', line)
if psnr_match:
psnr_value = float(psnr_match.group(1))
valid_psnr_bistlm_fu.append(psnr_value)
# 绘制 PSNR 变化图
plt.figure(figsize=(10, 6))
plt.plot(epochs, train_psnr_bistlm_differ, label='Train PSNR')
plt.plot(epochs, valid_psnr_bistlm_differ, label='Valid PSNR')
plt.plot(epochs, train_psnr_bistlm_fu, label='Train PSNR')
plt.plot(epochs, valid_psnr_bistlm_fu, label='Valid PSNR')
# 添加标签和标题
plt.xlabel('Epoch')
plt.ylabel('PSNR')
plt.title('PSNR Changes Over Epochs')
plt.legend()
plt.grid(True)
plt.savefig("savefig")
plt.show()