Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when training with custom dataset: cv2.error error: (-215:Assertion failed) !ssize.empty() in function 'resize' #17

Open
lqtrung-95 opened this issue Mar 5, 2019 · 3 comments

Comments

@lqtrung-95
Copy link

lqtrung-95 commented Mar 5, 2019

Hi I'm using the crnn-pytorch project to train a new model with my custom dataset, but when I run the command python train.py --data-path datatrain --test-init True --test-epoch 10 --output-dir snapshot --batch-size 8, it returned the error like this

python train.py --data-path datatrain --test-init True --test-epoch 10 --output-dir snapshot --batch-size 8
Test phase
0%| | 0/1 [00:00<?, ?it/s]Traceback (most recent call last):
File "train.py", line 108, in
main()
File "/home/trungle/anaconda3/lib/python3.7/site-packages/click/core.py", line 764, in call
return self.main(*args, **kwargs)
File "/home/trungle/anaconda3/lib/python3.7/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/home/trungle/anaconda3/lib/python3.7/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/trungle/anaconda3/lib/python3.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "train.py", line 67, in main
acc, avg_ed = test(net, data, data.get_abc(), cuda, visualize=False)
File "/home/trungle/PycharmProjects/crnn-pytorch/test.py", line 28, in test
for sample in iterator:
File "/home/trungle/anaconda3/lib/python3.7/site-packages/tqdm/_tqdm.py", line 979, in iter
for obj in iterable:
File "/home/trungle/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 637, in next
return self._process_next_batch(batch)
File "/home/trungle/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 658, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
cv2.error: Traceback (most recent call last):
File "/home/trungle/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 138, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/trungle/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 138, in
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/trungle/PycharmProjects/crnn-pytorch/dataset/text_data.py", line 37, in getitem
sample = self.transform(sample)
File "/home/trungle/anaconda3/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 49, in call
img = t(img)
File "/home/trungle/PycharmProjects/crnn-pytorch/dataset/data_transform.py", line 17, in call
sample["img"] = cv2.resize(sample["img"], self.size)
cv2.error: OpenCV(3.4.2) /tmp/build/80754af9/opencv-suite_1535558553474/work/modules/imgproc/src/resize.cpp:4044: error: (-215:Assertion failed) !ssize.empty() in function 'resize'

I'm pretty sure that the data and desc.json are in the right format.
If anyone can help I would be very appreciated, thanks so much.

@lqtrung-95 lqtrung-95 changed the title Error when training with custom dataset: 'list' object has no attribute 'find' Error when training with custom dataset: cv2.error error: (-215:Assertion failed) !ssize.empty() in function 'resize' Mar 5, 2019
@mjack3
Copy link

mjack3 commented Jul 9, 2019

I have the same error right now, did you fixed?

@trevorspreadbury
Copy link

I was having the same issue and I seem to have solved it. After investigating my issue, this error was appearing due to the image being None. This was caused by dataset/text_data.py attempting to read path/to/dataset/image_name and not finding an image there. The image is actually located in path/to/dataset/data/image_name as described in the README. The proper path is actually commented out in line 32 in dataset/text_data.py and I'm not sure why. Is this a bug?

So the solution for me was to uncomment line 32 and comment line 33

@mjack3
Copy link

mjack3 commented Jul 12, 2019

The error is because the json hasnot the correct path to the images. That’s why. I solved this issue in mu computer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants