-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw.py
94 lines (76 loc) · 2.54 KB
/
draw.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
def draw_train(path):
"""
:param path: train-csv路径
:return: null
"""
# 读取CSV文件
data = pd.read_csv(path)
# 设置图像大小
fig, axs = plt.subplots(2, 2, figsize=(12, 8))
# 绘制Loss_D和Loss_G
axs[0, 0].plot(data['Epoch'], data['Loss_D'], label='Loss_D')
axs[0, 0].plot(data['Epoch'], data['Loss_G'], label='Loss_G')
axs[0, 0].set_xlabel('Epoch')
axs[0, 0].set_ylabel('Loss')
axs[0, 0].set_title('Loss_D and Loss_G')
axs[0, 0].legend()
# 绘制Score_D和Score_G
axs[0, 1].plot(data['Epoch'], data['Score_D'], label='Score_D')
axs[0, 1].plot(data['Epoch'], data['Score_G'], label='Score_G')
axs[0, 1].set_xlabel('Epoch')
axs[0, 1].set_ylabel('Score')
axs[0, 1].set_title('Score_D and Score_G')
axs[0, 1].legend()
# 绘制PSNR
axs[1, 0].plot(data['Epoch'], data['PSNR'], label='PSNR')
axs[1, 0].set_xlabel('Epoch')
axs[1, 0].set_ylabel('PSNR')
axs[1, 0].set_title('PSNR')
axs[1, 0].legend()
# 绘制SSIM
axs[1, 1].plot(data['Epoch'], data['SSIM'], label='SSIM')
axs[1, 1].set_xlabel('Epoch')
axs[1, 1].set_ylabel('SSIM')
axs[1, 1].set_title('SSIM')
axs[1, 1].legend()
# 调整子图之间的间距
plt.subplots_adjust(hspace=0.5)
# 保存图像
plt.savefig('./image/train_results.png', dpi=300, bbox_inches='tight')
# 显示图像
plt.show()
def draw_test(path):
"""
:param path: test-csv路径
:return: null
"""
# 读取CSV文件
data = pd.read_csv(path)
# 剔除Average行
data = data[data['Image'] != 'Average']
# 重置索引
data = data.reset_index(drop=True)
# 创建一个新的图像
fig, axs = plt.subplots(1, 2, figsize=(16, 6))
# 绘制PSNR
axs[0].plot(data['Image'], data['PSNR'], color='y', label='PSNR')
axs[0].set_xlabel('Image')
axs[0].set_ylabel('PSNR')
axs[0].set_title('PSNR')
axs[0].set_xticks(np.arange(len(data))[::5]) # 每隔一个标记显示一次
axs[0].legend()
# 绘制SSIM
axs[1].plot(data['Image'], data['SSIM'], color='b', label='SSIM')
axs[1].set_xlabel('Image')
axs[1].set_ylabel('SSIM')
axs[1].set_title('SSIM')
axs[1].set_xticks(np.arange(len(data))[::5]) # 每隔一个标记显示一次
axs[1].legend()
# 保存图像
plt.savefig('./image/test_results.png', dpi=300, bbox_inches='tight')
plt.show()
draw_train("./statistics/train_results.csv")
draw_test("./statistics/test_results.csv")