-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdraw.py
More file actions
67 lines (58 loc) · 2.03 KB
/
Copy pathdraw.py
File metadata and controls
67 lines (58 loc) · 2.03 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use('TKAgg')
# 读取文件内容
file_path = 'logs_x8rgb.txt'
with open(file_path, 'r') as file:
lines = file.readlines()
# 提取数据
train_loss = eval(lines[0].split(":")[1].strip())
train_psnr = eval(lines[1].split(":")[1].strip())
train_ssim = eval(lines[2].split(":")[1].strip())
train_mse = eval(lines[3].split(":")[1].strip())
test_loss = eval(lines[4].split(":")[1].strip())
test_psnr = eval(lines[5].split(":")[1].strip())
test_ssim = eval(lines[6].split(":")[1].strip())
test_mse = eval(lines[7].split(":")[1].strip())
# 确保数据长度一致
epochs = list(range(1, len(train_loss) + 1))
# 绘制训练和测试的Loss曲线
plt.figure(figsize=(12, 8))
plt.plot(epochs, train_loss, label='Train Loss', linestyle='-', c='b')
plt.plot(epochs, test_loss, label='Test Loss', linestyle='--', c='r')
plt.xlabel('Epochs')
plt.ylabel('Loss')
plt.legend()
plt.grid(True)
plt.savefig('result/loss_x8rgb.jpg', format='jpg')
plt.show()
# 绘制训练和测试的PSNR曲线
plt.figure(figsize=(12, 8))
plt.plot(epochs, train_psnr, label='Train PSNR', linestyle='-', c='b')
plt.plot(epochs, test_psnr, label='Test PSNR', linestyle='--', c='r')
plt.xlabel('Epochs')
plt.ylabel('PSNR')
plt.legend()
plt.grid(True)
plt.savefig('result/psnr_x8rgb.jpg', format='jpg')
plt.show()
# 绘制训练和测试的SSIM曲线
plt.figure(figsize=(12, 8))
plt.plot(epochs, train_ssim, label='Train SSIM', linestyle='-', c='b')
plt.plot(epochs, test_ssim, label='Test SSIM', linestyle='--', c='r')
plt.xlabel('Epochs')
plt.ylabel('SSIM')
plt.legend()
plt.grid(True)
plt.savefig('result/ssim_x8ECA2.jpg', format='jpg')
plt.show()
# 绘制训练和测试的MSE曲线
plt.figure(figsize=(12, 8))
plt.plot(epochs, train_mse, label='Train MSE', linestyle='-', c='b')
plt.plot(epochs, test_mse, label='Test MSE', linestyle='--', c='r')
plt.xlabel('Epochs')
plt.ylabel('MSE')
plt.legend()
plt.grid(True)
plt.savefig('result/mse_x8rgb.jpg', format='jpg')
plt.show()