open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.22k stars 9.4k forks source link

MMDetWandbHook not logging train/loss or validation losses #9798

Open MABatin opened 1 year ago

MABatin commented 1 year ago

Prerequisite

Task

I have modified the scripts/configs, or I'm working on my own tasks/models/datasets.

Branch

master branch https://github.com/open-mmlab/mmdetection

Environment

sys.platform: linux
Python: 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]
CUDA available: True
GPU 0: NVIDIA GeForce RTX 2070
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 11.7, V11.7.99
GCC: x86_64-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
PyTorch: 1.13.1+cu117
PyTorch compiling details: PyTorch built with:
  - GCC 9.3
  - C++ Version: 201402
  - Intel(R) Math Kernel Library Version 2020.0.0 Product Build 20191122 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v2.6.0 (Git Hash 52b5f107dd9cf10910aaa19cb47f3abf9b349815)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - LAPACK is enabled (usually provided by MKL)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - CUDA Runtime 11.7
  - NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86
  - CuDNN 8.5
  - Magma 2.6.1
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.7, CUDNN_VERSION=8.5.0, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -fabi-version=11 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wunused-local-typedefs -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.13.1, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, 

TorchVision: 0.14.1+cu117
OpenCV: 4.7.0
MMCV: 1.7.0
MMCV Compiler: GCC 9.3
MMCV CUDA Compiler: 11.7
MMDetection: 2.28.1+c14dd6c

Reproduces the problem - code sample

log_config = dict(
    interval=1,
    hooks=[
        dict(type='TextLoggerHook'),
        dict(
            type='MMDetWandbHook',
            init_kwargs={'entity': ENTITY,
                         'project': PROJECT,
                         'name': NAME,
                         'dir': work_dir,
                         'resume': 'allow',
                         'id': ID},
            interval=1,
            num_eval_images=15,
            bbox_score_thr=0.5,
            log_checkpoint=False,
            log_checkpoint_metadata=False)])

Reproduces the problem - command or script

python /home/leon/pheno-wheat/tools/detector/train.py /home/leon/pheno-wheat/configs_dev/models/cascade_mask_rcnn_mod_dconv_c3-c5_250e_coco.py --cfg-options resume_from=None

Reproduces the problem - error message

There's no error but the TextLoggerHook is logging the following metrics for train epoch and val epoch respectively.

  1. Train epoch:
    2023-02-19 17:23:40,182 - mmdet - INFO - Epoch [7][6/145]   lr: 1.000e-02, eta: 16:24:55, time: 1.495, data_time: 0.698, memory: 5184, loss_rpn_cls: 0.2895, loss_rpn_bbox: 0.1680, s0.loss_cls: 0.4240, s0.acc: 80.1758, s0.loss_bbox: 0.3301, s0.loss_mask: 0.3559, s1.loss_cls: 0.2292, s1.acc: 76.7578, s1.loss_bbox: 0.2336, s1.loss_mask: 0.1758, s2.loss_cls: 0.1115, s2.acc: 79.1016, s2.loss_bbox: 0.0752, s2.loss_mask: 0.0934, loss: 2.4861
  2. Val epoch:
    2023-02-19 17:19:04,940 - mmdet - INFO - Epoch(val) [5][8]  loss_rpn_cls_val: 0.2945, loss_rpn_bbox_val: 0.1613, s0.loss_cls_val: 0.4241, s0.acc_val: 80.9204, s0.loss_bbox_val: 0.3339, s0.loss_mask_val: 0.3588, s1.loss_cls_val: 0.2179, s1.acc_val: 79.5044, s1.loss_bbox_val: 0.2060, s1.loss_mask_val: 0.1909, s2.loss_cls_val: 0.1056, s2.acc_val: 80.0903, s2.loss_bbox_val: 0.0608, s2.loss_mask_val: 0.0964, loss_val: 2.4503

Additional information

  1. I expected MMDetWandbHook to log all the metrics the texloggerhook would log.

  2. MMDetWandbHook is not logging the train/loss metric neither it is logging the validation loss metrics. image

  3. I'm not sure what might be the reason for this.

MorjanBAHAJI commented 1 year ago

Hello !

Can you try first to create a project in https://wandb.ai/new-project , and define in your config a simple pipeline such as:

log_config = dict(
    interval=1,
    hooks=[
        dict(type='TextLoggerHook'),
        dict(
            type='MMDetWandbHook',
            init_kwargs={'entity': "ENTITY", # The entity used to log on Wandb
                          'project': "PROJECT", # Project name in WandB
                          },
            interval=1,
            num_eval_images=15,
            bbox_score_thr=0.5,
            log_checkpoint=False,
            log_checkpoint_metadata=False)])

With ENTITY and PROJECT variable corresponding to the one created on the wandb.ai website ? It should work, but maybe there is a cleaner way to do it in MMDetection implementation of MMDetWandbHook...