|
import streamlit as st |
|
import numpy as np |
|
import matplotlib.pyplot as plt |
|
from PIL import Image |
|
|
|
|
|
|
|
|
|
st.title('Rick & Morty Classification Vis 3') |
|
st.image('rm_title.jpeg') |
|
|
|
|
|
st.set_option('deprecation.showPyplotGlobalUse', False) |
|
|
|
|
|
|
|
class_names = ['jerry', 'morty', 'rick', 'summer'] |
|
|
|
|
|
all_images_train_ds = np.load('all_images_train_ds.npy') |
|
all_labels_train_ds = np.load('all_labels_train_ds.npy') |
|
all_images_test_ds = np.load('all_images_test_ds.npy') |
|
all_labels_test_ds = np.load('all_labels_test_ds.npy') |
|
|
|
|
|
_, ax = plt.subplots(ncols=3, figsize=(20, 14)) |
|
|
|
|
|
class_counts_train = [list(all_labels_train_ds).count(label) for label in set(all_labels_train_ds)] |
|
ax[0].set_title('Training Data') |
|
ax[0].pie( |
|
class_counts_train, |
|
labels=class_names, |
|
colors=['#ccff00','#fdff00','#b9f2ff', '#e6e6fa'], |
|
autopct=lambda p: '{:.2f}%\n{:,.0f}'.format(p, p * sum(class_counts_train) / 100), |
|
explode=(0.01, 0.01,0.01,0.01), |
|
textprops={'fontsize': 13} |
|
) |
|
|
|
|
|
ax[1].set_title('Train Test Split') |
|
ax[1].pie( |
|
[len(all_images_train_ds), len(all_images_test_ds)], |
|
labels=['Train','Test'], |
|
colors=['#318ce7', '#ff9f00'], |
|
autopct=lambda p: '{:.2f}%\n{:,.0f}'.format(p, p * sum([len(all_images_train_ds), len(all_images_test_ds)]) / 100), |
|
explode=(0.1, 0), |
|
startangle=85, |
|
textprops={'fontsize': 13} |
|
) |
|
|
|
|
|
class_counts_test = [list(all_labels_test_ds).count(label) for label in set(all_labels_test_ds)] |
|
ax[2].set_title('Testing Data') |
|
ax[2].pie( |
|
class_counts_test, |
|
labels=class_names, |
|
colors=['#ccff00','#fdff00','#b9f2ff', '#e6e6fa'], |
|
autopct=lambda p: '{:.2f}%\n{:,.0f}'.format(p, p * sum(class_counts_test) / 100), |
|
explode=(0.01, 0.01,0.01,0.01), |
|
textprops={'fontsize': 13} |
|
) |
|
|
|
st.pyplot(plt.show()) |
|
|
|
|
|
|
|
|