text_plain_output_1.png image_output_1.png
from keras.preprocessing import image

from keras.utils import np_utils

from sklearn.preprocessing import LabelEncoder

from tqdm import tqdm

import cv2

import matplotlib.pyplot as plt

import os

import os

import numpy as np
import pandas as pd
import os
imagePaths = []
for dirname, _, filenames in os.walk('/kaggle/input'):
    for filename in filenames:
        if filename[-3:] == 'png':
            imagePaths.append(os.path.join(dirname, filename))

image = cv2.imread(imagePaths[0])

image.shape

Data = []
Target = []
resize = 224
for imagePath in tqdm(imagePaths):
    label = imagePath.split(os.path.sep)[-2]
    image = cv2.imread(imagePath)
    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
    image = cv2.resize(image, (resize, resize)) / 255
    Data.append(image)
    Target.append(label)

encoder = LabelEncoder()
encoder.fit(Target)
encoded_Target = encoder.transform(Target)
encoded_Target = np_utils.to_categorical(encoded_Target)

encoded_Target[0]