application_vnd.jupyter.stderr_output_1.png
from tqdm import tqdm

import cv2

import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

test = pd.read_csv('/kaggle/input/lego-dataset/Test.csv')
train = pd.read_csv('/kaggle/input/lego-dataset/Train.csv')

train_img = []
for img_name in tqdm(train['name']):
    image_path = '/kaggle/input/lego-dataset/train/' + str(img_name)
    img = cv2.imread(image_path, 0)
    img = img / 255.0
    img = img.reshape(200, 200, 1)
    img = img.astype('float32')
    train_img.append(img)
train_x = np.array(train_img)
train_y = train['category'].values - 1
train_x.shape

def display_examples(images, labels):
    """
        Display 25 images from the images array with its corresponding labels
    """
    
    fig = plt.figure(figsize=(10,10))
    fig.suptitle("Some examples of images of the dataset", fontsize=16)
    for i in range(25):
        plt.subplot(5,5,i+1)
        plt.xticks([])
        plt.yticks([])
        plt.grid(False)
        plt.imshow(images[i].reshape(200,200), cmap=plt.cm.binary)
        plt.xlabel(labels[i])
    plt.show()

display_examples(train_x, train_y + 1)