text: 
  # Installing `caer` and `canaro` since they don't come pre-installed
  # Uncomment the following line:
  # !pip install --upgrade caer canaro
  
  import os
  import caer
  import canaro
  import numpy as np
  import cv2 as cv
  import gc
  import matplotlib.pyplot as plt
  from tensorflow.keras.utils import to_categorical
  from tensorflow.keras.callbacks import LearningRateScheduler
  
  
  IMG_SIZE = (80,80)
  channels = 1
  char_path = r'../input/the-simpsons-characters-dataset/simpsons_dataset'
  
  # Creating a character dictionary, sorting it in descending order
  char_dict = {}
  for char in os.listdir(char_path):
      char_dict[char] = len(os.listdir(os.path.join(char_path,char)))
  
  # Sort in descending order
  char_dict = caer.sort_dict(char_dict, descending=True)
  char_dict
  
  #  Getting the first 10 categories with the most number of images
  characters = []
  count = 0
  for i in char_dict:
      characters.append(i[0])
      count += 1
      if count >= 10:
          break
  characters
  
  # Create the training data
  train = caer.preprocess_from_dir(char_path, characters, channels=channels, IMG_SIZE=IMG_SIZE, isShuffle=True)
  
  # Number of training samples
  len(train)
  
  # Visualizing the data (OpenCV doesn't display well in Jupyter notebooks)
  plt.figure(figsize=(30,30))
  plt.imshow(train[0][0], cmap='gray')
  plt.show()
  
  # Separating the array and corresponding labels
  featureSet, labels = caer.sep_train(train, IMG_SIZE=IMG_SIZE)
  
  
  # Normalize the featureSet ==> (0,1)
  featureSet = caer.normalize(featureSet)
  # Converting numerical labels to binary class vectors
  labels = to_categorical(labels, len(characters))
  
  # Creating train and validation data
  x_train, x_val, y_train, y_val = caer.train_val_split(featureSet, labels, val_ratio=.2)
  
  # Deleting variables to save memory
  del train
  del featureSet
  del labels 
  gc.collect()
  
  # Useful variables when training
  BATCH_SIZE = 32
  EPOCHS = 10
  
  # Image data generator (introduces randomness in network ==> better accuracy)
  datagen = canaro.generators.imageDataGenerator()
  train_gen = datagen.flow(x_train, y_train, batch_size=BATCH_SIZE)
  
  # Create our model
  model = canaro.models.createSimpsonsModel(IMG_SIZE=IMG_SIZE, channels=channels, output_dim=len(characters), 
                                           loss='binary_crossentropy', decay=1e-7, learning_rate=0.001, momentum=0.9,
                                           nesterov=True)
  
  ##### (OPTIONAL) If you solely want the model architecture, go to <https://github.com/jasmcaus/canaro/blob/master/canaro/models/simpsons.py> 
  # and then uncomment the following to compile the model
  
  # # Compiling the model
  # from tensorflow.keras.optimizers import SGD
  # optimizer = SGD(lr=0.001, decay=1e-8, momentum=.9, nesterov=True)
  # model.compile(loss='binary_crossentropy', optimizer=optimizer, metrics=['accuracy'])
  
  model.summary()
  
  # Training the model
  
  callbacks_list = [LearningRateScheduler(canaro.lr_schedule)]
  training = model.fit(train_gen,
                      steps_per_epoch=len(x_train)//BATCH_SIZE,
                      epochs=EPOCHS,
                      validation_data=(x_val,y_val),
                      validation_steps=len(y_val)//BATCH_SIZE,
                      callbacks = callbacks_list)
  
  characters
  
  """## Testing"""
  
  test_path = r'../input/the-simpsons-characters-dataset/kaggle_simpson_testset/kaggle_simpson_testset/charles_montgomery_burns_0.jpg'
  
  img = cv.imread(test_path)
  
  plt.imshow(img)
  plt.show()
  
  def prepare(image):
      image = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
      image = cv.resize(image, IMG_SIZE)
      image = caer.reshape(image, IMG_SIZE, 1)
      return image
  
  predictions = model.predict(prepare(img))
  
  # Getting class with the highest probability
  print(characters[np.argmax(predictions[0])])