<jupyter_start><jupyter_text>You have to create folders as written in the code below and store the photos in these folders<jupyter_code>train_dir = './train/train/'
test_dir = './data/test/test/'
train_images = [train_dir+i for i in os.listdir(train_dir)]
test_images = [test_dir+i for i in os.listdir(test_dir)]
random.shuffle(train_images)
def prepare_data(list_of_images):
    x = [] 
    y=[]
    for image in tqdm(list_of_images):
        x.append(cv2.resize(cv2.imread(image), (224,224), interpolation=cv2.INTER_CUBIC))
        z=(re.split('\d+',image)[0][-4:-1])
        if 'cat' in z:
            y.append(0)
        else:
            y.append(1)                    
    return x,y
X ,Y= prepare_data(train_images)
print(K.image_data_format())
import gc
gc.collect()
X = np.array(X)
file = open('X_weights.np','wb')
np.save(file,X)
file.close()
Y = np.array(Y)
file2 = open('Y_weights.np','wb')
np.save(file2,Y)
file2.close()<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup