levindabhi / cloth-segmentation

This repo contains code and a pre-trained model for clothes segmentation.
MIT License
565 stars 102 forks source link

TypeError: Caught TypeError in DataLoader worker process 0. and TypeError: 'float' object cannot be interpreted as an integer #6

Closed davichen2017 closed 2 years ago

davichen2017 commented 2 years ago

Traceback (most recent call last): File "C:\dl\u2net-cloth-segmentation-main\train.py", line 182, in training_loop(opt) File "C:\dl\u2net-cloth-segmentation-main\train.py", line 111, in training_loop data_batch = next(get_data) File "C:\dl\u2net-cloth-segmentation-main\data\custom_dataset_data_loader.py", line 50, in sample_data for batch in loader: File "C:\Anaconda3\envs\UnetTorch\lib\site-packages\torch\utils\data\dataloader.py", line 530, in next data = self._next_data() File "C:\Anaconda3\envs\UnetTorch\lib\site-packages\torch\utils\data\dataloader.py", line 1224, in _next_data return self._process_data(data) File "C:\Anaconda3\envs\UnetTorch\lib\site-packages\torch\utils\data\dataloader.py", line 1250, in _process_data data.reraise() File "C:\Anaconda3\envs\UnetTorch\lib\site-packages\torch_utils.py", line 457, in reraise raise exception TypeError: Caught TypeError in DataLoader worker process 0. Original Traceback (most recent call last): File "C:\Anaconda3\envs\UnetTorch\lib\site-packages\torch\utils\data_utils\worker.py", line 287, in _worker_loop data = fetcher.fetch(index) File "C:\Anaconda3\envs\UnetTorch\lib\site-packages\torch\utils\data_utils\fetch.py", line 49, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "C:\Anaconda3\envs\UnetTorch\lib\site-packages\torch\utils\data_utils\fetch.py", line 49, in data = [self.dataset[idx] for idx in possibly_batched_index] File "C:\dl\u2net-cloth-segmentation-main\data\aligned_dataset.py", line 74, in getitem sub_mask = self.rle_decode( File "C:\dl\u2net-cloth-segmentation-main\data\aligned_dataset.py", line 164, in rle_decode img = np.zeros(shape[0] * shape[1], dtype=np.uint8) TypeError: 'float' object cannot be interpreted as an integer

environment: python = 3.9.0 pytorch =1.11.0

Cuda compilation tools, release 11.3, V11.3.58 Build cuda_11.3.r11.3/compiler.29745058_0

Why do I have this problem when I reproduce? Thank you

levindabhi commented 2 years ago

Can you check self.fine_width and self.fine_height in options/base_options.py is int or not

davichen2017 commented 2 years ago

Can you check self.fine_width and self.fine_height in options/base_options.py is int or not

Thanks your reply.

I cloned the code from here and downloaded the dataset from Kaggle, but I haven't changed this code: self.fine_width = 192 4 self.fine_height = 192 4

I have altered changed code only,because i only have one GPU

self.image_folder = r"D:\\DataSets\\Cloth\\imaterialist\\train"  # image folder path
self.df_path = r"D:\\DataSets\\Cloth\\imaterialist\\train_csv\\train.csv"  # label csv path

# self.image_folder = "./imaterialist/train/"  # image folder path
# self.df_path = "./imaterialist/train.csv"  # label csv path

self.distributed = False # True for multi gpu training

Is it related to the dataset ? or other

Thanks.

davichen2017 commented 2 years ago

If set self.nThreads = 0 ,then “TypeError: Caught TypeError in DataLoader worker process 0” disappear.

davichen2017 commented 2 years ago

I have change this code,then “TypeError: 'float' object cannot be interpreted as an integer ” disappear. self.image_info[index]["orig_height"] = int(row["Height"]) self.image_info[index]["orig_width"] = int(row["Width"])