meijieru / crnn.pytorch

Convolutional recurrent network in pytorch
MIT License
2.38k stars 658 forks source link

AttributeError: 'lmdbDataset' object has no attribute 'getLabel' in convert_dataset.py. getLabel Missing #16

Closed ahmedmazari-dhatim closed 7 years ago

ahmedmazari-dhatim commented 7 years ago

Hello, when l run convert_dataset.py l get the following error :

python2 convert_dataset.py 
Origin dataset has 23920 samples
Traceback (most recent call last):
  File "convert_dataset.py", line 57, in <module>
    convert('/home/ahmed/Downloads/sample/output', '/home/ahmed/Downloads/sample/o_train')
  File "convert_dataset.py", line 25, in convert
    label = originDataset.getLabel(i + 1)
AttributeError: 'lmdbDataset' object has no attribute 'getLabel'

indeed, in dataset.py there is no getLabel How to fix that ?

abhiML commented 7 years ago

Did you figure it out yet? I am having the same issue.

ahmedmazari-dhatim commented 7 years ago

@abhiML , hi not yet l'm still struggling to solve it.

abhiML commented 7 years ago

Did you build the lmdb file following the original guide?

ahmedmazari-dhatim commented 7 years ago

@abhiML , are you talking about Create a new LMDB dataset. A python program is provided in tool/create_dataset.py. Refer to the function createDataset for details (need to pip install lmdb first). yes l did this

abhiML commented 7 years ago

Okay. Could you tell me what exactly is this program convert_dataset.py trying to achieve?

ahmedmazari-dhatim commented 7 years ago

@abhiML , l'm asking the same question. But l think we can train crnn_main.py with the outpouts of create_datasset.py

ahmedmazari-dhatim commented 7 years ago

@abhiML , see #17

meijieru commented 7 years ago

@abhiML convert_dataset.py is only for user who wants to trained with varied image size. For training with fixed size image such as 100x32, only use create_dataset.py.

ahmedmazari-dhatim commented 7 years ago

@meijieru , thanks for answering. My dataset contains images of varied size. This is why l want to use convert_dataset.py but l get the following error :
AttributeError: 'lmdbDataset' object has no attribute 'getLabel'

abhiML commented 7 years ago

Okay but now I am another error Traceback (most recent call last): File "crnn_main.py", line 200, in <module> cost = trainBatch(crnn, criterion, optimizer) File "crnn_main.py", line 183, in trainBatch preds = crnn(image) File "/home/ubuntu/anaconda/lib/python2.7/site-packages/torch/nn/modules/module.py", line 206, in __call__ result = self.forward(*input, **kwargs) File "/home/ubuntu/crnn.pytorch/models/crnn.py", line 81, in forward assert h == 1, "the height of conv must be 1" AssertionError: the height of conv must be 1 did you come across this?

ahmedmazari-dhatim commented 7 years ago

@abhiML , have you succeded to run crnn_main.py ? please see #17

abhiML commented 7 years ago

No I haven't succeeded in running crnn_main.py

ahmedmazari-dhatim commented 7 years ago

no l mean you succeed some lines of code. you got an error at line 200 but me l got an error atline 18 l did the following :

parser = argparse.ArgumentParser()
parser.add_argument('/home/ahmed/Downloads/sample/output/train', required=True, help='path to dataset')
parser.add_argument('/home/ahmed/Downloads/sample/output/test', required=True, help='path to dataset')

then l run : python2 crnn_main.py [--param home/ahmed/Downloads/sample/output/train /home/ahmed/Downloads/sample/output/test]

@abhiML , in that way you run your code ?

abhiML commented 7 years ago

well i run it using this statement

python crnn_main.py --trainroot="/home/ubuntu/mnt" --valroot="/home/ubuntu/mnt/ramdisk" --cuda

ahmedmazari-dhatim commented 7 years ago

and in your mnt you have only data-train.mdb & lock-train.mdb and inramdisk you have data-valid.mdb & lock-train.mdb ?

ahmedmazari-dhatim commented 7 years ago

@abhiML , l run it as follow : python2 crnn_main.py --trainroot="/home/ahmed/Downloads/training_data/output/train" --valroot="/home/ahmed/Downloads/training_data/output/test" --cuda

l got the following error stating no file directory :

Namespace(Diters=5, adadelta=False, adam=False, alphabet='0123456789abcdefghijklmnopqrstuvwxyz', batchSize=64, beta1=0.5, crnn='', cuda=True, displayInterval=500, experiment=None, imgH=64, keep_ratio=False, lr=1, n_test_disp=10, ngpu=1, nh=100, niter=25, random_sample=False, saveInterval=500, trainroot='/home/ahmed/Downloads/training_data/output/train', valInterval=500, valroot='/home/ahmed/Downloads/training_data/output/test', workers=2)
Random Seed:  9252
Traceback (most recent call last):
  File "crnn_main.py", line 59, in <module>
    train_dataset = dataset.lmdbDataset(root=opt.trainroot)
  File "/home/ahmed/crnn/dataset.py", line 25, in __init__
    meminit=False)
lmdb.Error: /home/ahmed/Downloads/training_data/output/train: No such file or directory
abhiML commented 7 years ago

what is train? a folder or a file? And the second one is the validation set not the test set.

in your case train should be a folder. Not a file. Inside train your data.mdb and lock.mdb must be present.

ahmedmazari-dhatim commented 7 years ago

train is a folder that contains data.mdb and lock.mdb test is a floder that contains data.mdb and lock.mdb

l just named it test rather than valid. it was not working because l renamed the files data.mdb to data-train.mdb

ahmedmazari-dhatim commented 7 years ago

@abhiML , Now we have the same error :

Traceback (most recent call last):
  File "crnn_main.py", line 201, in <module>
    cost = trainBatch(crnn, criterion, optimizer)
  File "crnn_main.py", line 184, in trainBatch
    preds = crnn(image)
  File "/home/ahmed/anaconda3/envs/cv/lib/python2.7/site-packages/torch/nn/modules/module.py", line 206, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/ahmed/crnn/models/crnn.py", line 80, in forward
    assert h == 1, "the height of conv must be 1"
AssertionError: the height of conv must be 1