milesial / Pytorch-UNet

PyTorch implementation of the U-Net for image semantic segmentation with high quality images
GNU General Public License v3.0
9.3k stars 2.51k forks source link

IndexError: list index out of range #484

Open liuyisu opened 8 months ago

liuyisu commented 8 months ago

May I ask how to solve this problem?Thank you very much

微信图片_20240320151036
dengzhuohao commented 4 months ago

I have the same question. Have you solved it?

zzzzzzl24 commented 3 months ago

image Generally speaking, this can be caused by the mismatch of file path, file name and mask suffix. If your original image is named in the form of ‘image_001.jpg’, when your mask file is named ‘image_001.png’, the mask_suffix is set to ’ ‘ (set to empty), if your mask file is named ‘image_001_mask.png’, please set mask_suffix to ‘_mask’, this may solve your problem!

2506791459 commented 1 month ago

PS D:\WICT\UNet\Pytorch-UNet-master> & E:/Anaconda/envs/u-net/python.exe d:/WICT/UNet/Pytorch-UNet-master/Pytorch-UNet-master/train.py INFO: Using device cpu INFO: Network: 3 input channels 2 output channels (classes) Transposed conv upscaling INFO: Creating dataset with 5088 examples INFO: Scanning mask files to determine unique values 0%| | 0/5088 [00:04<?, ?it/s] INFO: Creating dataset with 5088 examples INFO: Scanning mask files to determine unique values 0%| | 0/5088 [00:04<?, ?it/s] multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "E:\Anaconda\envs\u-net\lib\multiprocessing\pool.py", line 125, in worker result = (True, func(*args, *kwds)) File "d:\WICT\UNet\Pytorch-UNet-master\Pytorch-UNet-master\utils\data_loading.py", line 27, in unique_mask_values mask_file = list(mask_dir.glob(idx + mask_suffix + '.'))[0] mask_file = list(mask_dir.glob(idx + mask_suffix + '.*'))[0] IndexError: list index out of range """ IndexError: list index out of range """

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

Traceback (most recent call last): File "d:/WICT/UNet/Pytorch-UNet-master/Pytorch-UNet-master/train.py", line 213, in train_model( train_model( File "d:/WICT/UNet/Pytorch-UNet-master/Pytorch-UNet-master/train.py", line 45, in train_model dataset = BasicDataset(dir_img, dir_mask, img_scale) File "d:/WICT/UNet/Pytorch-UNet-master/Pytorch-UNet-master/train.py", line 45, in train_model dataset = BasicDataset(dir_img, dir_mask, img_scale) File "d:\WICT\UNet\Pytorch-UNet-master\Pytorch-UNet-master\utils\data_loading.py", line 53, in init unique = list(tqdm( File "E:\Anaconda\envs\u-net\lib\site-packages\tqdm\std.py", line 1181, in iter unique = list(tqdm( File "E:\Anaconda\envs\u-net\lib\site-packages\tqdm\std.py", line 1181, in iter File "E:\Anaconda\envs\u-net\lib\site-packages\tqdm\std.py", line 1181, in iter for obj in iterable: File "E:\Anaconda\envs\u-net\lib\multiprocessing\pool.py", line 865, in next raise value IndexError: list index out of range PS D:\WICT\UNet\Pytorch-UNet-master>

May I ask how to solve this problem?Thank you very much