text: import seaborn as sn
  import pandas as pd
  import matplotlib.pyplot as plt
  import result_models
  from dnnlib import tflib
  from training import dataset
  import tensorflow as tf
  from training import misc
  from tqdm import tqdm
  import numpy as np
  
  tflib.init_tf()
  dset = dataset.TFRecordDataset('./../../../datasets/car_labels_v7_oversample_filter')
  minibatch_size = 1
  dset.configure(minibatch_size=minibatch_size)
  rotation_offset = 108
  
  classifier = result_models.load_rotation_classifier_euclidean('./../../../results')
  
  x, labels = dset.get_minibatch_tf()
  x = tf.cast(x, tf.float32)
  x = misc.adjust_dynamic_range(x, [0, 255], [-1, 1])
  labels = labels[:, rotation_offset:rotation_offset + 2]
  prediction = classifier.get_output_for(x)
  
  all_rotations = np.array([
      [1.0, 0.0],
      [0.7071, 0.7071],
      [0.0, 1.0],
      [-0.7071, 0.7071],
      [-1.0, 0.0],
      [-0.7071, -0.7071],
      [0.0, -1.0],
      [0.7071, -0.7071]]
  )
  all_rotations = np.tile(np.expand_dims(all_rotations, axis=0), [minibatch_size, 1, 1])
  
  prediction_out_list = []
  label_out_list = []
  iterations = 1000
  removed = 0
  for i in tqdm(range(iterations)):
      prediction_out, label_out = tflib.run([prediction, labels])
      if np.sum(np.abs(label_out)) == 0:
          print('Zero Label')
          removed += 1
          continue
  
      prediction_out = np.tile(np.expand_dims(prediction_out, axis=1), [1, 8, 1])
      distance_pred = np.linalg.norm(all_rotations - prediction_out, axis=-1)
      closest_prediction = np.argmin(distance_pred, axis=-1)
  
      rotation_labels = np.tile(np.expand_dims(label_out, axis=1), [1, 8, 1])
      distance_real = np.linalg.norm(all_rotations - rotation_labels, axis=-1)
      closest_label = np.argmin(distance_real, axis=-1)
  
      prediction_out_list.append(closest_prediction)
      label_out_list.append(closest_label)
  
  indices_labels = np.reshape(np.stack(label_out_list, axis=0), [minibatch_size * len(prediction_out_list)])
  indices_prediction = np.reshape(np.stack(prediction_out_list, axis=0), [minibatch_size * len(prediction_out_list)])
  array = np.zeros([8, 8])
  
  for i in range(indices_labels.shape[0]):
      array[indices_prediction[i], indices_labels[i]] += 1
  
  sum_x_axis = np.tile(np.expand_dims(np.sum(array, axis=1), axis=-1), [1, 8])
  array = array / sum_x_axis
  
  rotations = [
      'Front Center',
      'Front Left',
      'Profile Left',
      'Rear Left',
      'Rear Center',
      'Rear Right',
      'Profile Right',
      'Front Right'
  ]
  df_cm = pd.DataFrame(array, index=[i for i in rotations],
                       columns=[i for i in rotations])
  plt.figure(figsize=(9, 5))
  
  sn.heatmap(df_cm, annot=True, cmap="YlGnBu", cbar=False, fmt='.3f')
  
  plt.title('Confusion Matrix for the Sin/Cos Classifier')
  plt.xlabel('prediction')
  plt.ylabel('label')
  plt.subplots_adjust(bottom=0.15, left=0.15)
  plt.savefig('confusion_matrix_new_annotation.png')
  plt.show()
  