clovaai / deep-text-recognition-benchmark

Text recognition (optical character recognition) with deep learning methods, ICCV 2019
Apache License 2.0
3.68k stars 1.08k forks source link

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

Open RobertLee0522 opened 2 months ago

RobertLee0522 commented 2 months ago

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:

sugar6502 commented 1 month ago

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