open-mmlab / mmaction2

OpenMMLab's Next Generation Video Understanding Toolbox and Benchmark
https://mmaction2.readthedocs.io
Apache License 2.0
4.34k stars 1.25k forks source link

[Bug]analyze_logs.py can not plot the training log #2612

Open Aidenxu0305 opened 1 year ago

Aidenxu0305 commented 1 year ago

Branch

main branch (1.x version, such as v1.0.0, or dev-1.x branch)

Prerequisite

Environment

hi,i tryin to use the analyze_log.py in our tools to plot the acc/top1 and acc/top5,but something wrong. The position of file is mmaction2/tools/analysis_Tools/analyze_logs. py. The code"if log_dict[epoch]['mode'][-1] == 'val'" whether should be changed? Because there are no keys 'mode' in the JSON files which is generated by trainning. thanks

Describe the bug

(workxzy) PS D:\xzy\mmaction2> python tools/analysis_tools/analyze_logs.py plot_curve work_dir/stgcn_40epoch/20230730_120426/vis_data/scalars.json --keys top1_acc top5_acc --out results.pdf

plot curve of work_dir/stgcn_40epoch/20230730_120426/vis_data/scalars.json, metric is top1_acc Traceback (most recent call last): File "D:\xzy\mmaction2\tools\analysis_tools\analyze_logs.py", line 167, in main() File "D:\xzy\mmaction2\tools\analysis_tools\analyze_logs.py", line 163, in main eval(args.task)(log_dicts, args) File "D:\xzy\mmaction2\tools\analysis_tools\analyze_logs.py", line 60, in plot_curve if log_dict[epoch]['mode'][-1] == 'val': IndexError: list index out of range

Reproduces the problem - code sample

"lr": 0.09984601549529389, "data_time": 0.0016210556030273437, "loss": 2.2928349912166595, "top1_acc": 0.3333333333333333, "top5_acc": 0.3333333333333333, "loss_cls": 2.2928349912166595, "time": 0.030268120765686034, "epoch": 1, "iter": 2070, "memory": 555, "step": 2070} {"acc/top1": 0.26666666666666666, "acc/top5": 0.6231578947368421, "acc/mean1": 0.06778146250804876, "data_time": 0.047777099079555935, "time": 0.062130782339307994, "step": 1}

here is a sample of training log,there is no key 'mode' in the val row

Reproduces the problem - command or script

No response

Reproduces the problem - error message

No response

Additional information

No response

cir7 commented 1 year ago

This script is outdated and is for version 0.x. We will try to update it soon.

lmc2000 commented 10 months ago

请问更新了吗

DreamSUUNY commented 6 months ago

我也出现了这个问题,在运行python tools/analysis_tools/analyze_logs.py plot_curve work_dirs/posec3d_third/20240528_164154/vis_data/output/20240528_164154_output.json --keys top1_acc 后报错,Traceback (most recent call last): File "tools/analysis_tools/analyze_logs.py", line 167, in main() File "tools/analysis_tools/analyze_logs.py", line 163, in main eval(args.task)(log_dicts, args) File "tools/analysis_tools/analyze_logs.py", line 60, in plot_curve if log_dict[epoch]['mode'][-1] == 'val': IndexError: list index out of range 训练后生成的日志文件缺少mode键对值train、val,该如何解决这个问题?