cjf8899 / CDRL

:earth_asia:Official PyTorch implementation of "Unsupervised Change Detection Based on Image Reconstruction Loss", CVPRW 2022.
46 stars 5 forks source link

TypeError: image must be numpy array type #4

Closed choumie closed 2 years ago

choumie commented 2 years ago

Hi i tried your code and when i want to train with Levir dataset i get an error: Namespace(b1=0.5, b2=0.999, batch_size=1, dataset_name='LEVIR-CD', epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=4, n_epochs=10, root_path='/content/datasets/', sample_interval=2000, save_name='levir') /usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py:490: UserWarning: This DataLoader will create 4 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary. cpusetchecked)) 890 [ WARN:0@1.952] global /io/opencv/modules/imgcodecs/src/loadsave.cpp (239) findDecoder imread('/content/datasets/LEVIR-CD_A2B_B2A/train/A/train_249.png'): can't open/read file: check file path/integrity Traceback (most recent call last): File "main.py", line 126, in for i, batch in enumerate(dataloader): File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 530, in next data = self._next_data() File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1224, in _next_data return self._process_data(data) File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1250, in _process_data data.reraise() File "/usr/local/lib/python3.7/dist-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 "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop data = fetcher.fetch(index) File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/content/datasets.py", line 28, in getitem transformed_B = self.transforms_B(image=img_B) File "/usr/local/lib/python3.7/dist-packages/albumentations/core/composition.py", line 190, in call self._check_args(**data) File "/usr/local/lib/python3.7/dist-packages/albumentations/core/composition.py", line 267, in _check_args raise TypeError("{} must be numpy array type".format(data_name)) TypeError: image must be numpy array type

rfww commented 2 years ago

check your data path "/content/datasets/LEVIR-CD_A2B_B2A/train/A/train_249.png"