I'm using this data http://weegee.vision.ucmerced.edu/datasets/landuse.html on a Google Colab.
Trying to load the images as a dataframe using:
# Download and unzip images
!wget http://weegee.vision.ucmerced.edu/datasets/UCMerced_LandUse.zip
!unzip UCMerced_LandUse.zip
print("DONE!")
filename = '//content/UCMerced_LandUse/Images'
data = tf.keras.preprocessing.image_dataset_from_directory(filename)
I get the following error:
TypeError: Input 'filename' of 'ReadFile' Op has type float32 that does not match expected type of string.
It founds the folders with the labels, but it misses all one hundred images inside each label folder. The image format is '.tif'.
In the image you can observe the directory structure.
The function:
tf.keras.preprocessing.image.load_img('/content/UCMerced_LandUse/Images/agricultural/agricultural00.tif', grayscale=False, color_mode="rgb", target_size=None, interpolation="nearest")
Works well and show the image.
I have tried all found in the following post: TypeError: Input 'filename' of 'ReadFile' Op has type float32 that does not match expected type of string Like rename the files:
all_dir = glob.glob('UCMerced_LandUse/Images/*/')
for dir in sort(all_dir):
name = dir.split('/')[2]
for img, n in zip(sort(glob.glob(dir + '*.tif')), range(0,100)):
new_file = os.path.join(dir, '{}{}.tif'.format(name, n))
os.rename(img, str(new_file))
And some other "solutions" proposed in internet. But no ones fix the problem.
If you have some clues from where I'm failing, it would be appreciated.
Thanks.