Skip to content

Commit

Permalink
[Fix] Fix bug in tools/analyse_logs.py caused by wrong plot_iter in…
Browse files Browse the repository at this point in the history
… some cases. (open-mmlab#1428)

* fix_analyze_logs

* fix comments

* fix comments
  • Loading branch information
MengzhangLI authored and mob5566 committed Apr 13, 2022
1 parent b60891c commit 9f602bb
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tools/analyze_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def plot_curve(log_dicts, args):
plot_epochs = []
plot_iters = []
plot_values = []
# In some log files, iters number is not correct, `pre_iter` is
# used to prevent generate wrong lines.
pre_iter = -1
# In some log files exist lines of validation,
# `mode` list is used to only collect iter number
# of training line.
for epoch in epochs:
epoch_logs = log_dict[epoch]
if metric not in epoch_logs.keys():
Expand All @@ -43,11 +43,9 @@ def plot_curve(log_dicts, args):
plot_values.append(epoch_logs[metric][0])
else:
for idx in range(len(epoch_logs[metric])):
if pre_iter > epoch_logs['iter'][idx]:
continue
pre_iter = epoch_logs['iter'][idx]
plot_iters.append(epoch_logs['iter'][idx])
plot_values.append(epoch_logs[metric][idx])
if epoch_logs['mode'][idx] == 'train':
plot_iters.append(epoch_logs['iter'][idx])
plot_values.append(epoch_logs[metric][idx])
ax = plt.gca()
label = legend[i * num_metrics + j]
if metric in ['mIoU', 'mAcc', 'aAcc']:
Expand Down

0 comments on commit 9f602bb

Please sign in to comment.