I was trying out this tutorial using this Plant Leaves dataset (with over 35k images consisting .JPG, .PNG as well as .JPEG files) with tensorflow version 1.14
And I followed similar steps except; skipping "Load using keras.preprocessing" part. I directly jumped over to "Load using tf.data" part. But when I ran the snippet it threw me this error:
File "D:\Softwares\Anaconda\lib\site-packages\tensorflow\python\ops\ragged\ragged_string_ops.py", line 640, in strings_split_v1
return ragged_result.to_sparse()
AttributeError: 'Tensor' object has no attribute 'to_sparse'
Complete error:
My code snippet is:
dir_root=pathlib.Path("D:/Projects/IIIT/LeafID/Dataset/PlantVillage")
list_ds=tf.data.Dataset.list_files(str(dir_root/"*/*"))
def getLabel(fpath):
parts = tf.strings.split(fpath, os.path.sep)
return parts[-2] == clnames
def decodeimg(img):
img=tf.image.decode_jpeg(img,channels=3)
img=tf.image.convert_image_dtype(img,tf.float32)
return tf.image.resize(img,[64,64])
def process_path(fpath):
label=getLabel(fpath)
img=tf.io.read_file(fpath)
img=decodeimg(img)
return img, label
label_ds=list_ds.map(process_path,num_parallel_calls=AUTOTUNE)
which is almost similar to the code here, except the variables. I couldn't understand what's the problem here? Is there something wrong with the process of images getting converted to tensor? Because when I open ragged_string_ops.py, it shows me something like this:
if result_type == "SparseTensor":
return ragged_result.to_sparse()
T.I.A.