mmocr icon indicating copy to clipboard operation
mmocr copied to clipboard

ValueError: too many dimensions 'str' Trying to train KIE on custom Dataset

Open hmiche opened this issue 2 years ago • 2 comments

Hello . i faced a problem when trying to train my custom KIE dataset after the first epoch I got this error message : ValueError: too many

Reproduction

!python tools/train.py configs/kie/sdmgr/sdmgr_novisual_60e_wildreceipt.py

Environment Google Colab . TorchVision: 0.12.0+cu113 OpenCV: 4.1.2 MMCV: 1.5.1 MMCV Compiler: GCC 7.5 MMCV CUDA Compiler: 11.1 MMOCR: 0.6.0+f89ab85

Error traceback

2022-05-26 11:57:03,839 - mmocr - INFO - workflow: [('train', 1)], max: 60 epochs
2022-05-26 11:57:03,839 - mmocr - INFO - Checkpoints will be saved to /content/mmocr/work_dirs/sdmgr_novisual_60e_wildreceipt by HardDiskBackend.
2022-05-26 11:57:07,003 - mmocr - INFO - Saving checkpoint at 1 epochs
[>>] 17/17, 99.2 task/s, elapsed: 0s, ETA:     0sTraceback (most recent call last):
  File "tools/train.py", line 230, in <module>
    main()
  File "tools/train.py", line 226, in main
    meta=meta)
  File "/content/mmocr/mmocr/apis/train.py", line 155, in train_detector
    runner.run(data_loaders, cfg.workflow)
  File "/usr/local/lib/python3.7/dist-packages/mmcv/runner/epoch_based_runner.py", line 127, in run
    epoch_runner(data_loaders[i], **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/mmcv/runner/epoch_based_runner.py", line 54, in train
    self.call_hook('after_train_epoch')
  File "/usr/local/lib/python3.7/dist-packages/mmcv/runner/base_runner.py", line 309, in call_hook
    getattr(hook, fn_name)(self)
  File "/usr/local/lib/python3.7/dist-packages/mmcv/runner/hooks/evaluation.py", line 267, in after_train_epoch
    self._do_evaluate(runner)
  File "/usr/local/lib/python3.7/dist-packages/mmdet/core/evaluation/eval_hooks.py", line 58, in _do_evaluate
    key_score = self.evaluate(runner, results)
  File "/usr/local/lib/python3.7/dist-packages/mmcv/runner/hooks/evaluation.py", line 364, in evaluate
    results, logger=runner.logger, **self.eval_kwargs)
  File "/content/mmocr/mmocr/datasets/kie_dataset.py", line 161, in evaluate
    return self.compute_macro_f1(results, **metric_options['macro_f1'])
  File "/content/mmocr/mmocr/datasets/kie_dataset.py", line 170, in compute_macro_f1
    node_gts.append(torch.Tensor(node_gt))
ValueError: too many dimensions 'str'

hmiche avatar May 26 '22 12:05 hmiche

Does your test data has the same format as wildrecipt?

gaotongxiao avatar May 27 '22 09:05 gaotongxiao

yes it is i just copied some lines from my training set just to train if the training will start

hmiche avatar May 27 '22 14:05 hmiche