Skip to content

Instantly share code, notes, and snippets.

@evmcheb
Created October 11, 2019 14:14
Show Gist options
  • Save evmcheb/4fd2857dc4e3c8b08247eef9a89d3578 to your computer and use it in GitHub Desktop.
Save evmcheb/4fd2857dc4e3c8b08247eef9a89d3578 to your computer and use it in GitHub Desktop.
import os
samples = []
labels = []
images_folder = "images/"
for image in os.listdir(images_folder):
samples.append(img_to_array(load_img(images_folder+image, target_size=(100, 100))))
if "normal" in image:
labels.append((0))
else:
labels.append((1))
samples = np.array(samples)
labels = np.array(labels)
eval_x, eval_y = samples[-100:], labels[-100:]
print(samples.shape, labels.shape)
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(samples[:-100], labels[:-100], test_size=0.2, random_state=31)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment