application_vnd.jupyter.stderr_output_1.png
from keras.preprocessing.image import img_to_array

from keras.preprocessing.image import load_img

from tensorflow.keras.preprocessing.image import load_img,img_to_array

import numpy as np

import os

stored_data_path = '../input/magnetictiledefect'
CLASS_NAME = ['Blowhole', 'Free', 'Break', 'Fray', 'Uneven', 'Crack']
CLASS_NAME_NUM = [0, 1, 2, 3, 4, 5]

file_path = '../input/magneticTileDefect/'
X_all_raw = []
y_all = []
for ani_class in CLASS_NAME:
    for filename in os.listdir(file_path + ani_class):
        for subfilename in os.listdir(file_path + ani_class + '/' + filename + '/Imgs'):
            img = load_img(file_path + ani_class + '/' + filename + '/Imgs/' + subfilename, target_size=(224, 224))
            img_array = img_to_array(img)
            X_all_raw.append(img_array)
            y_all.append(CLASS_NAME.index(ani_class))
X_all_raw = np.array(X_all_raw)
X_all_raw.shape

y_all = np.array(y_all)
y_all