text_plain_output_1.png
import cv2

import matplotlib.image as mpimg

import matplotlib.pyplot as plt

import os

import random

import numpy as np
import pandas as pd
import zipfile
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import cv2
import random
import os

IMAGE_WIDTH = 128
IMAGE_HEIGHT = 128
IMAGE_SIZE = (IMAGE_WIDTH, IMAGE_HEIGHT)
IMAGE_CHANNELS = 3

filenames = os.listdir('/kaggle/working/train')
filenames[:5]

def load_data(filenames):
    i = 50
    X = []
    y = []
    for name in filenames:
        img = mpimg.imread(os.path.join('/kaggle/working/train', name))
        X.append(cv2.resize(img, IMAGE_SIZE))
        cat = name.split('.')[0]
        if cat == 'dog':
            y.append(0)
        else:
            y.append(1)
        i -= 1
        if i <= 0:
            break
    return (X, y)

sample = random.choice(filenames)
print(sample)
plt.imshow(mpimg.imread('/kaggle/working/train/' + sample))
plt.show()