You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want finetune model, and when i use trainer.ipynb i get this error `ImportError Traceback (most recent call last)
Cell In[1], line 4
2 import torch.backends.cudnn as cudnn
3 import yaml
----> 4 from train import train
5 from utils import AttrDict
6 import pandas as pd
File ~/pet/pcb/EasyOCR/trainer/train.py:15
12 import numpy as np
14 from utils import CTCLabelConverter, AttnLabelConverter, Averager
---> 15 from dataset import hierarchical_dataset, AlignCollate, Batch_Balanced_Dataset
16 from model import Model
17 from test import validation
File ~/pet/pcb/EasyOCR/trainer/dataset.py:13
11 import numpy as np
12 from torch.utils.data import Dataset, ConcatDataset, Subset
---> 13 from torch._utils import _accumulate
14 import torchvision.transforms as transforms
16 def contrast_grey(img):
ImportError: cannot import name '_accumulate' from 'torch._utils' (/home/simba9/anaconda3/envs/easyocr/lib/python3.9/site-packages/torch/_utils.py)`
The text was updated successfully, but these errors were encountered:
Just ran into the same problem. Pytorch v2.3.0 no longer defines function _accumulate in torch/_utils.py. What worked for me was to patch the code from an older version, namely v2.2.0
def _accumulate(iterable, fn=lambda x, y: x + y):
"Return running totals"
# _accumulate([1,2,3,4,5]) --> 1 3 6 10 15
# _accumulate([1,2,3,4,5], operator.mul) --> 1 2 6 24 120
it = iter(iterable)
try:
total = next(it)
except StopIteration:
return
yield total
for element in it:
total = fn(total, element)
yield total
So, either find and downgrade to an older version of Pytorch such as v2.2.0 or use my workaround, which is:
comment out the offending import statement in line 13
I want finetune model, and when i use trainer.ipynb i get this error `ImportError Traceback (most recent call last)
Cell In[1], line 4
2 import torch.backends.cudnn as cudnn
3 import yaml
----> 4 from train import train
5 from utils import AttrDict
6 import pandas as pd
File ~/pet/pcb/EasyOCR/trainer/train.py:15
12 import numpy as np
14 from utils import CTCLabelConverter, AttnLabelConverter, Averager
---> 15 from dataset import hierarchical_dataset, AlignCollate, Batch_Balanced_Dataset
16 from model import Model
17 from test import validation
File ~/pet/pcb/EasyOCR/trainer/dataset.py:13
11 import numpy as np
12 from torch.utils.data import Dataset, ConcatDataset, Subset
---> 13 from torch._utils import _accumulate
14 import torchvision.transforms as transforms
16 def contrast_grey(img):
ImportError: cannot import name '_accumulate' from 'torch._utils' (/home/simba9/anaconda3/envs/easyocr/lib/python3.9/site-packages/torch/_utils.py)`
The text was updated successfully, but these errors were encountered: