text_plain_output_1.png
from glob import glob

import cv2

import numpy as np

train_data1 = glob('../input/fruits-360_dataset/fruits-360/Training/Raspberry/*')
train_data2 = glob('../input/fruits-360_dataset/fruits-360/Training/Pomelo Sweetie/*')
test_data1 = glob('../input/fruits-360_dataset/fruits-360/Test/Raspberry/*')
test_data2 = glob('../input/fruits-360_dataset/fruits-360/Test/Pomelo Sweetie/*')
x_train = []
x_test = []
def create_data(data, values):
    for i in values:
        im = cv2.imread(i, 0)
        data.append(im)
    return len(values)
train_Rasberry_size = create_data(x_train, train_data1)
train_Pomelo_size = create_data(x_train, train_data2)
test_Rasberry_size = create_data(x_test, test_data1)
test_Pomelo_size = create_data(x_test, test_data2)

x_train = np.asarray(x_train, dtype=np.float64)
x_train = x_train.reshape(x_train.shape[0], x_train.shape[1] * x_train.shape[2])
z = np.zeros(train_Rasberry_size)
o = np.ones(train_Pomelo_size)
y_train = np.concatenate((z, o), axis=0)

x_test = np.asarray(x_test, dtype=np.float64)
x_test = x_test.reshape(x_test.shape[0], x_test.shape[1] * x_test.shape[2])
z = np.zeros(test_Rasberry_size)
o = np.ones(test_Pomelo_size)
y_test = np.concatenate((z, o), axis=0)
print('x_test:', x_test.shape)
print('y_test:', y_test.shape)