mirror of
https://github.com/open-mmlab/mmclassification.git
synced 2025-06-03 21:53:55 +08:00
[Fix] Fix wrong condition judgment in analyze_logs.py
and prevent empty curve. (#510)
* [Fix] Analyze logs with single training iteration * [Fix] Make `plot_curve` with 'accuracy' metric * [Fix] Assert length of training log records of each epoch is larger than 1 Co-authored-by: Ma Zerun <mzr1996@163.com> Co-authored-by: Ma Zerun <mzr1996@163.com>
This commit is contained in:
parent
b486bb23f8
commit
abb5a222cf
@ -57,11 +57,9 @@ def plot_curve(log_dicts, args):
|
|||||||
f'{args.json_logs[i]} does not contain metric {metric} '
|
f'{args.json_logs[i]} does not contain metric {metric} '
|
||||||
f'in train mode')
|
f'in train mode')
|
||||||
|
|
||||||
if 'mAP' in metric:
|
if any(m in metric for m in ('mAP', 'accuracy')):
|
||||||
xs = np.arange(1, max(epochs) + 1)
|
xs = epochs
|
||||||
ys = []
|
ys = [log_dict[e][metric] for e in xs]
|
||||||
for epoch in epochs:
|
|
||||||
ys += log_dict[epoch][metric]
|
|
||||||
ax = plt.gca()
|
ax = plt.gca()
|
||||||
ax.set_xticks(xs)
|
ax.set_xticks(xs)
|
||||||
plt.xlabel('epoch')
|
plt.xlabel('epoch')
|
||||||
@ -74,6 +72,9 @@ def plot_curve(log_dicts, args):
|
|||||||
iters = log_dict[epoch]['iter']
|
iters = log_dict[epoch]['iter']
|
||||||
if log_dict[epoch]['mode'][-1] == 'val':
|
if log_dict[epoch]['mode'][-1] == 'val':
|
||||||
iters = iters[:-1]
|
iters = iters[:-1]
|
||||||
|
assert len(iters) > 0, (
|
||||||
|
'The training log is empty, please try to reduce the '
|
||||||
|
'interval of log in config file.')
|
||||||
xs.append(
|
xs.append(
|
||||||
np.array(iters) + (epoch - 1) * num_iters_per_epoch)
|
np.array(iters) + (epoch - 1) * num_iters_per_epoch)
|
||||||
ys.append(np.array(log_dict[epoch][metric][:len(iters)]))
|
ys.append(np.array(log_dict[epoch][metric][:len(iters)]))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user