Issue
I am having this error. This is code for basic CNN I don't understand where the problem is. If it is any backend problem. I am using Anaconda environment in pycharm
training_data = []
count = 1
id = []
test_samples = []
def read_load_images():
path = 'C:/Users/Nabia/PycharmProjects/untitled/training_set/'
categories = ["01","02"]
for category in categories:
path_os = os.path.join(path,category)
for img in os.listdir(path_os):
my_img = cv2.imread(os.path.join(path_os,img),0)
my_img = cv2.resize(my_img,(300,300))
training_data.append(np.array(my_img))
def read_load_labels():
with open('data.csv', newline='') as f:
reader = csv.reader(f)
for row in reader:
id.append(row)
read_load_images()
read_load_labels()
training_data = np.array(training_data)
labels = np.array(id)
# print(training_data[0])
# print(training_data.shape)
# print(labels.shape)
# print(id)
train_img,test_img,train_label,test_label = train_test_split(training_data,id,test_size = 0.20, random_state = 2)
print('train img',train_img.shape)
print('test img',test_img.shape)
train_label = np.array(train_label)
test_label = np.array(test_label)
print(train_label.reshape)
print(test_label.shape)
The error which i'm getting is this: error image
Solution
I think your data.csv load function is causing the problem.
What are the values of training_data.shape[0] and id.shape[0]? They should be the same as this is a requirement in train_test_split(). If they don't match, you can look at the data.csv load read_load_labels function next.
Answered By - Donald S
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.