zhiqwang / sightseq

Computer vision tools for fairseq, containing PyTorch implementation of text recognition and object detection
MIT License
124 stars 34 forks source link

TypeError: 'DigitsBatchTrain' object is not iterable #3

Closed jianghonggang closed 5 years ago

jianghonggang commented 5 years ago

Extract the Chinese_dataset.rar to data folder and move all pictures to images, then modify data_test.txt to data_dev.txt.

run main.py, it shows that:

Creating directory if it does not exist: './checkpoint/densenet121_rmsprop_lr5.0e-05_wd5.0e-04_bsize64_imsize32' Using model from scratch (random weights) 'densenet121' Traceback (most recent call last): File "/home/luban/repository/crnn.pytorch/main.py", line 352, in main() File "/home/luban/repository/crnn.pytorch/main.py", line 197, in main loss = train(train_loader, model, criterion, optimizer, epoch) File "/home/luban/repository/crnn.pytorch/main.py", line 231, in train for i, (images, targets, target_lengths) in enumerate(train_loader): TypeError: 'DigitsBatchTrain' object is not iterable

Process finished with exit code 1

zhiqwang commented 5 years ago

Hi @jianghonggang , you should rename data_dev.txt to dev.txt and data_train.txt to train.txt, I forget to give this information.

jianghonggang commented 5 years ago

Hi @jianghonggang , you should modify _datadev.txt to dev.txt and _datatrain.txt to train.txt, I forget to give this information.

I have modified dataset.py 25 line: label_path = os.path.join(data_root, '{}.txt'.format(mode)) to label_path = os.path.join(dataroot, 'data{}.txt'.format(mode))

jianghonggang commented 5 years ago

好吧,北京的同学,我们还是中文交流吧

zhiqwang commented 5 years ago

好吧,北京的同学,我们还是中文交流吧

Jiang 准备跑什么数据,可否告知一下?

jianghonggang commented 5 years ago

现在跑的是Chinese_dataset.rar解压后的数据,还没上自己的训练数据。

zhiqwang commented 5 years ago

我现在没有硬件(gpu)测试模型,线上放的模型是一个 epoch 出来的结果(Chinese dataset 这个准确率是 97.5%),多跑两个 epoch 准确率应该有进一步提升,如果方便,可以 push 一下模型出来

jianghonggang commented 5 years ago

现在的问题是程序跑不起来,运行main.py时报错: TypeError: 'DigitsBatchTrain' object is not iterable

zhiqwang commented 5 years ago

现有的参数如果不收敛,可能需要加 criterion = nn.CTCLoss(zero_infinity=True) 需要最新的 pytroch nightly 版本。

zhiqwang commented 5 years ago

现在的问题是程序跑不起来,运行main.py时报错: TypeError: 'DigitsBatchTrain' object is not iterable

python 3.6+?

jianghonggang commented 5 years ago

python: 3.6.8 pytorch: 1.0.1

zhiqwang commented 5 years ago

--alphabet ./data/alphabet_decode_5990.txt 这个参数呢?

jianghonggang commented 5 years ago

对,是这个参数

zhiqwang commented 5 years ago

./data/images 文件夹下应该没有子文件夹

jianghonggang commented 5 years ago

修改main.py line 231:

for i, e in enumerate(train_loader):
    images = e.images
    targets = e.targets
    target_lengths = e.target_lengths

可以跑了

zhiqwang commented 5 years ago

修改main.py line 231:

for i, e in enumerate(train_loader):
    images = e.images
    targets = e.targets
    target_lengths = e.target_lengths

可以跑了

好诡异,不知道 python 有这个操作,估计是 DigitsBatchTrain 这个类写得不规范