deep-text-recognition-benchmark icon indicating copy to clipboard operation
deep-text-recognition-benchmark copied to clipboard

ImportError: cannot import name '_accumulate' from 'torch._utils'

Open RobertLee0522 opened this issue 10 months ago • 1 comments

python train.py --train_data data/train --valid_data data/val --select_data MJ-ST --batch_ratio 0.5-0.5 --Transformation None --FeatureExtraction VGG --SequenceModeling BiLSTM --Prediction CTC

Error message:

Traceback (most recent call last):
  File "C:\Users\54-0461100-01\Desktop\img_process\easyocr_process\deep-text-recognition-benchmark\train.py", line 16, in <module>
    from dataset import hierarchical_dataset, AlignCollate, Batch_Balanced_Dataset
  File "C:\Users\54-0461100-01\Desktop\img_process\easyocr_process\deep-text-recognition-benchmark\dataset.py", line 13, in <module>
    from torch._utils import _accumulate
ImportError: cannot import name '_accumulate' from 'torch._utils' (C:\Users\54-0461100-01\anaconda3\envs\easyocr\lib\site-packages\torch\_utils.py)

Environment details:

  • 2.3.0+cu118

RobertLee0522 avatar May 02 '24 07:05 RobertLee0522

Hi, I think your version of pytorch is higher than requirement, so in this, the _accumulate is remove. My solution is changing from import name '_accumulate' from 'torch._utils' to from itertools import accumulate as _accumulate This work for me

sugar6502 avatar May 06 '24 19:05 sugar6502