text_plain_output_56.png text_plain_output_35.png text_plain_output_43.png text_plain_output_37.png text_plain_output_5.png text_plain_output_48.png text_plain_output_30.png text_plain_output_15.png text_plain_output_9.png text_plain_output_44.png text_plain_output_40.png text_plain_output_31.png text_plain_output_20.png text_plain_output_4.png text_plain_output_13.png text_plain_output_52.png text_plain_output_45.png text_plain_output_14.png text_plain_output_32.png text_plain_output_29.png text_plain_output_58.png text_plain_output_49.png text_plain_output_27.png text_plain_output_54.png text_plain_output_10.png text_plain_output_6.png text_plain_output_57.png text_plain_output_24.png text_plain_output_21.png text_plain_output_47.png text_plain_output_25.png text_plain_output_18.png text_plain_output_50.png text_plain_output_36.png text_plain_output_3.png text_plain_output_22.png text_plain_output_38.png text_plain_output_7.png text_plain_output_16.png text_plain_output_8.png text_plain_output_26.png text_plain_output_41.png text_plain_output_34.png text_plain_output_42.png text_plain_output_53.png text_plain_output_23.png text_plain_output_51.png text_plain_output_28.png text_plain_output_2.png text_plain_output_1.png text_plain_output_33.png text_plain_output_39.png text_plain_output_55.png text_plain_output_19.png text_plain_output_17.png text_plain_output_11.png text_plain_output_12.png text_plain_output_46.png
from keras.layers import BatchNormalization, Activation, Dropout

from keras.layers import Conv2D, Dense, Flatten, MaxPooling2D

from keras.models import Sequential

from sklearn.preprocessing import MultiLabelBinarizer

import cv2 as cv

import numpy as np

import os

import re

X = []
Y = []
input_shape = (96, 96, 3)
path_to_subset = f'../input/apparel-images-dataset/'
for folder in os.listdir(path_to_subset):
    for image in os.listdir(os.path.join(path_to_subset, folder)):
        path_to_image = os.path.join(path_to_subset, folder, image)
        image = cv.imread(path_to_image)
        image = cv.resize(image, (input_shape[1], input_shape[0]))
        label = re.findall('\\w+\\_\\w+', path_to_image)[0].split('_')
        X.append(image)
        Y.append(label)
X = np.array(X) / 255.0
Y = np.array(Y)
mlb = MultiLabelBinarizer()
Y = mlb.fit_transform(Y)

model = Sequential()
model.add(Conv2D(32, 3, padding='same', input_shape=input_shape, kernel_initializer='he_normal', activation='relu'))
model.add(BatchNormalization())
model.add(MaxPooling2D(3))
model.add(Dropout(0.25))
model.add(Conv2D(64, 3, padding='same', kernel_initializer='he_normal', activation='relu'))
model.add(BatchNormalization())
model.add(Conv2D(64, 3, padding='same', kernel_initializer='he_normal', activation='relu'))
model.add(BatchNormalization())
model.add(MaxPooling2D())
model.add(Dropout(0.25))
model.add(Conv2D(128, 3, padding='same', kernel_initializer='he_normal', activation='relu'))
model.add(BatchNormalization())
model.add(Conv2D(128, 2, padding='same', kernel_initializer='he_normal', activation='relu'))
model.add(BatchNormalization())
model.add(MaxPooling2D())
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(1024, activation='relu', kernel_initializer='he_normal'))
model.add(BatchNormalization())
model.add(Dropout(0.5))
model.summary()
model.add(Dense(len(mlb.classes_), activation='sigmoid'))