crnn.pytorch icon indicating copy to clipboard operation
crnn.pytorch copied to clipboard

A question about NoneType

Open softwaregitgub opened this issue 5 years ago • 12 comments

Traceback (most recent call last): File "/home/stay/Desktop/CrnnPytorch/train.py", line 201, in cost = trainBatch(crnn, criterion, optimizer) File "/home/stay/Desktop/CrnnPytorch/train.py", line 176, in trainBatch data = train_iter.next() File "/home/stay/anaconda3/envs/tf/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 637, in next return self._process_next_batch(batch) File "/home/stay/anaconda3/envs/tf/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 658, in _process_next_batch raise batch.exc_type(batch.exc_msg) TypeError: Traceback (most recent call last): File "/home/stay/anaconda3/envs/tf/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 138, in _worker_loop samples = collate_fn([dataset[i] for i in batch_indices]) File "/home/stay/anaconda3/envs/tf/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 138, in samples = collate_fn([dataset[i] for i in batch_indices]) File "/home/stay/Desktop/CrnnPytorch/dataset.py", line 51, in getitem buf.write(imgbuf) TypeError: a bytes-like object is required, not 'NoneType'

cuda --->9.0 cudnn ---7 torch -->1.0.1

I don't know what caused it. Thank you for your answer. My data set is converted from Python 3 to MDB format. Is that the reason? Is it sometimes empty when buf. write () reads the binary?

softwaregitgub avatar Apr 04 '19 10:04 softwaregitgub

but,when i use python2 to make mdb still have this wrong?

softwaregitgub avatar Apr 04 '19 11:04 softwaregitgub

and i use other's correct mdb still have this question,so it should not be the problem of data.

softwaregitgub avatar Apr 04 '19 11:04 softwaregitgub

I have the same question.Have you solved it?

sunsun0 avatar Apr 06 '19 03:04 sunsun0

I have the same question.Have you solved it?

No, i don't know how to solve it? Do you have any ideas?

softwaregitgub avatar Apr 07 '19 08:04 softwaregitgub

hello have you solved it?

junkojunko avatar Apr 11 '19 01:04 junkojunko

i have solved it. Use python2 to make mdb, the problem did not arise.

sunsun0 avatar Apr 11 '19 07:04 sunsun0

i change the dataset.py=======> return self.nSamples + 1 to self.nSamples, and it works.

softwaregitgub avatar Apr 16 '19 03:04 softwaregitgub

Try this, i rewrite it in python3 and fix bug. https://github.com/Holmeyoung/crnn_pytorch

Holmeyoung avatar Apr 19 '19 02:04 Holmeyoung

i change the dataset.py=======> return self.nSamples + 1 to self.nSamples, and it works.

thank you,this truely sove my problem

LeiGan0215 avatar May 21 '19 16:05 LeiGan0215

i change the dataset.py=======> return self.nSamples + 1 to self.nSamples, and it works.

thank you,this truely sove my problem Hello, which interpreter do you use, python2 or python3?

FortuneSeeker avatar May 25 '20 13:05 FortuneSeeker

When training my own dataset, I got this problem: Traceback (most recent call last): File "train.py", line 60, in train_dataset = dataset.lmdbDataset(root=opt.trainRoot) File "/home/haha/Documents/Workspaces/Workspace-PyCharm/crnn-pytorch/dataset.py", line 32, in init nSamples = int(txn.get('num-samples'.encode())) TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType' What should I do?

FortuneSeeker avatar May 25 '20 13:05 FortuneSeeker

i have also meet the same mistake, and i change the way getitem do, finally it work. maybe it is why i create the dataset in a wrong way

zhangfengyo avatar Jan 29 '21 06:01 zhangfengyo