[Fix] Fix bug in tools/analyse_logs.py caused by wrong plot_iter in some cases. (#1428)

* fix_analyze_logs

* fix comments

* fix comments
This commit is contained in:
MengzhangLI 2022-04-05 12:47:41 +08:00 committed by GitHub
parent ecd2dc474a
commit dfcc0b68df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,9 +31,9 @@ def plot_curve(log_dicts, args):
plot_epochs = [] plot_epochs = []
plot_iters = [] plot_iters = []
plot_values = [] plot_values = []
# In some log files, iters number is not correct, `pre_iter` is # In some log files exist lines of validation,
# used to prevent generate wrong lines. # `mode` list is used to only collect iter number
pre_iter = -1 # of training line.
for epoch in epochs: for epoch in epochs:
epoch_logs = log_dict[epoch] epoch_logs = log_dict[epoch]
if metric not in epoch_logs.keys(): if metric not in epoch_logs.keys():
@ -43,11 +43,9 @@ def plot_curve(log_dicts, args):
plot_values.append(epoch_logs[metric][0]) plot_values.append(epoch_logs[metric][0])
else: else:
for idx in range(len(epoch_logs[metric])): for idx in range(len(epoch_logs[metric])):
if pre_iter > epoch_logs['iter'][idx]: if epoch_logs['mode'][idx] == 'train':
continue plot_iters.append(epoch_logs['iter'][idx])
pre_iter = epoch_logs['iter'][idx] plot_values.append(epoch_logs[metric][idx])
plot_iters.append(epoch_logs['iter'][idx])
plot_values.append(epoch_logs[metric][idx])
ax = plt.gca() ax = plt.gca()
label = legend[i * num_metrics + j] label = legend[i * num_metrics + j]
if metric in ['mIoU', 'mAcc', 'aAcc']: if metric in ['mIoU', 'mAcc', 'aAcc']: