PRNet_PyTorch icon indicating copy to clipboard operation
PRNet_PyTorch copied to clipboard

[FIXED] TypeError: cannot unpack non-iterable NoneType object

Open sngyo opened this issue 2 years ago • 0 comments

Solution

Original Code

https://github.com/tomguluson92/PRNet_PyTorch/blob/2d30e244855a043eec071baf78e8edbab9c11c78/tools/WLP300dataset.py#L53

Fixed version

if img_id is not None:
    ...

or simply just remove if img_id:

why

The TypeError: cannot unpack non-iterable NoneType object occurs when the function get_img_path in PRNetDataset tries to load img_id == 0.

When the generate_posmap_300WLP.py is executed according to README.md, each folder is generated sequentially numbered from folder 0 as described.

However, in python, 0 would be same with False as below:

img_id = 0
if img_id: 
    print("true")
else:
    print("false")

>>> false

Therefore, the function does not return a value, causing the data loader to bug out.

sngyo avatar May 28 '22 03:05 sngyo