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

Either no mask or multiple masks found for the ID #312

Open
SkevyHoo opened this issue Nov 5, 2021 · 6 comments
Open

Either no mask or multiple masks found for the ID #312

SkevyHoo opened this issue Nov 5, 2021 · 6 comments

Comments

@SkevyHoo
Copy link

SkevyHoo commented Nov 5, 2021

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?

@ihamdi
Copy link

ihamdi commented Nov 29, 2021

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.

@ihamdi
Copy link

ihamdi commented Nov 29, 2021

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.

@ihamdi
Copy link

ihamdi commented Nov 30, 2021

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.

@ihamdi
Copy link

ihamdi commented Nov 30, 2021

@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.

@wujiayi
Copy link

wujiayi commented Jan 5, 2022

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.

@silakanveli
Copy link

silakanveli commented Nov 9, 2022

Traceback (most recent call last):
File "train.py", line 188, in
train_net(net=net,
File "train.py", line 79, in train_net
for batch in train_loader:
File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 578, in next
data = self._next_data()
File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1273, in _next_data
return self._process_data(data)
File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1299, in _process_data
data.reraise()
File "/opt/conda/lib/python3.8/site-packages/torch/_utils.py", line 461, in reraise
raise exception
AssertionError: Caught AssertionError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 300, in _worker_loop
data = fetcher.fetch(index)
File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataset.py", line 290, in getitem
return self.dataset[self.indices[idx]]
File "/workspace/unet/utils/data_loading.py", line 62, in getitem
assert len(mask_file) == 1, f'Either no mask or multiple masks found for the ID {name}: {mask_file}'
AssertionError: Either no mask or multiple masks found for the ID 0de66245f268_09: []

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.

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

4 participants