Pytorch-UNet
Pytorch-UNet copied to clipboard
Either no mask or multiple masks found for the ID
I used my own dataset to train U-Net,and it took a error: Either no mask or multiple masks found for the ID So how to solve it?
I'm using the Carvana dataset (which is what this code is supposed to download but I kept getting unauthorized error) and I'm getting the same thing. Any idea on how to fix that?
I'm going to take a quick look at the files and see if anything stands out.
I used my own dataset to train U-Net,and it took a error: Either no mask or multiple masks found for the ID So how to solve it?
Somehow, running it on my home PC (i9 RTX 3090 Ubuntu) doesn't give me that error anymore. I never had an issue before running code on the laptop (i7 RTX 2060 Ubuntu). Absolutely have no idea why that would happen on one machine but not another.
I'll let you know if it happens again.
I used my own dataset to train U-Net,and it took a error: Either no mask or multiple masks found for the ID So how to solve it?
Go to utils folder then data_loading.py and add: if len(mask_file)!=1: print(name) in getitem just after img_file = list(self.images_dir.glob(name + '.*'))
This will show you which file is the problem. In my case, I had an empty folder inside the /data/imgs and /data/masks folder that was causing the issue. I checked the other machine and I didn't have that so it makes sense that its the issue.
@milesial changing the listdir(images_dir) to glob would be an easy fix to avoid this problem. Or just mention that we need to make sure imgs and masks folders in the data/ should contain nothing other than the actual masks and images.
The directory of your mask in data_loading file is wrong. The data_loading file includes the code to read the image and mask. But the author set a mask_suffix in the code. Please check your mask directory.
Traceback (most recent call last):
File "train.py", line 188, in
All folders are created correctly.
data/imgs/ data/masks/
When i check mask. It is found.
root@8a72d2424c09:/workspace/unet# ls data/masks/ | grep 0de66245f268_09 0de66245f268_09.png
Looks like i fixed it by setting utils/data_loading.py last line super().init(images_dir, masks_dir, scale, mask_suffix='')
It was expecting '_mask' suffix, have no idea why.