Skip to content Skip to sidebar Skip to footer

ValueError: Could Not Convert String To Float: 'nonPdr'

I'm facing this error: ValueError: could not convert string to float: 'nonPdr', when I run this code: model = Sequential() model.add(Conv2D(input_shape=(605,700,3), filters=64, ker

Solution 1:

In your ReadImages function, you are making list of strings:

LabelList.append(os.path.splitext(File)[0])

And later when you use ReadImages function, you are trying to convert this list of strings into numpy array. Here:

data, labels = ReadImages(TRAIN_DIR)
model.fit(np.array(data), np.array(labels), epochs=10, batch_size=32)

Possible solution might be assigning your class names to numbers:

classes = ["nonPdr", "another_class"]
LabelList.append(classes.index[os.path.splitext(File)[0]])

0 will be appended to LabelList when your class is "nonPdr", and 1 will be append if your class is "other_class".


Post a Comment for "ValueError: Could Not Convert String To Float: 'nonPdr'"