text_plain_output_1.png image_output_1.png
import cv2

import matplotlib.pyplot as plt

import numpy as np # linear algebra

import os

train_cats = '../input/cat-and-dogs/dataset/training_set/cats'
train_dogs = '../input/cat-and-dogs/dataset/training_set/dogs'
test_cats = '../input/cat-and-dogs/dataset/training_set/cats'
test_dogs = '../input/cat-and-dogs/dataset/training_set/dogs'
simgle_image = '../input/cat-and-dogs/dataset/single_prediction'

image_size = 128
for image1 in os.listdir(train_cats):
    path = os.path.join(train_cats, image1)
    img1 = cv2.imread(path, cv2.IMREAD_GRAYSCALE)
    img1 = cv2.resize(img1, (image_size, image_size)).flatten()
    np_img1 = np.asarray(img1)
for image2 in os.listdir(train_dogs):
    path = os.path.join(train_dogs, image2)
    img2 = cv2.imread(path, cv2.IMREAD_GRAYSCALE)
    img2 = cv2.resize(img2, (image_size, image_size)).flatten()
    np_img2 = np.asarray(img2)
plt.figure(figsize=(10, 10))
plt.subplot(1, 2, 1)
plt.imshow(np_img1.reshape(image_size, image_size))
plt.axis('off')
plt.subplot(1, 2, 2)
plt.imshow(np_img2.reshape(image_size, image_size))
plt.axis('off')