Home > Software design >  AttributeError: 'Tensor' object has no attribute 'numpy' while mapping a functio
AttributeError: 'Tensor' object has no attribute 'numpy' while mapping a functio

Time:05-12

I'm trying to map a function process_image to the dataset. This function calls another function, get_label. In get_label, I'm trying to retrieve the label's name from images.

The file path is like this: C:\\Users\\sis\\Desktop\\test\\0002_c1s1_000451_03.jpg. The label is number 0002.

enter image description here

def get_lab(file_path):
    parts = tf.strings.split(file_path, os.path.sep)
    part=parts[-1].numpy().decode().split('_')[0]
    label=tf.strings.to_number(part)
    return label

CodePudding user response:

  • Related