Open chenmw269 opened 3 years ago
I also encountered this problem. It may be that some images in the data set are grayscale images instead of rgb images. I deleted these grayscale images to solve this problem. Here is my code. `def remove_single_channel_images(images_files): for path in sorted(os.listdir(images_files)): image_path = os.path.join(images_files, path) image = Image.open(image_path) image = np.array(image) if image.shape != (256, 256, 3): print(image_path) os.remove(image_path)
remove_single_channel_images('datasets/horse2zebra/train/B')`
The main reason for this problem is that there are single channel images in the data set. Solution: just add. convert ('rgb ') in datasets.py file iterm_B = self.transform(Image.open(self.files_B[random.randint(0, len(self.files_B)-1)]).convert('RGB'))
When I use my own data set, the program runs normally, but with the dataset :horse2zebra, the program starts to report errors: