<jupyter_start><jupyter_text>Model ApplicationThis IPython Notebook contains the code for testing our trained Galaxy Classifier CNN architecture model on some new images of the 3 corresponding classes - Irregular, Elliptical and Spiral. After testing and calculation, it was found out that the testing accuracy achieved was 96.67%. For testing, 25 images were used and were distributed into 3 classes as follows: 1. Elliptical- 11 images (Label - 0)2. Irregular - 4 images (Label - 1)3. Spiral - 10 images (Label - 2)The test accuracies for individual classes were as follows: 1. Elliptical :        Total Number of Images- 64       Correctly Predicted - 63       Incorrect Predictions - 1       Accuracy - 98.437%          2. Spiral :        Total Number of Images- 64       Correctly Predicted - 52       Incorrect Predictions- 12       Accuracy- 81.25%       3. Irregular :       Total Number of Images- 4       Correctly Predicted- 4       Incorrect Predictions- 0       Accuracy- 100%              Hence, the cummulative average testing accuracy was calculated to be "93.229%".<jupyter_code>#importing relevant packages and modules
import keras
import keras.preprocessing.image
import h5py
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten, Conv2D, MaxPooling2D
import os
from keras.models import Sequential
import warnings
warnings.filterwarnings('ignore')
#Defining Network Parameters
num_classes=3
input_shape=(256,256,3)
#Constructing our CNN architecture
model = Sequential()
model.add(Conv2D(16, kernel_size=(3, 3), activation='tanh', input_shape=input_shape))
model.add(Conv2D(32, (3, 3), activation='tanh'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, (3, 3), activation='tanh'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, (3, 3), activation='tanh'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, (3, 3), activation='tanh'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(32, activation='tanh'))
model.add(Dropout(0.5))
model.add(Dense(num_classes, activation='softmax'))
model.summary()
#Importing the already saved weights from the previous trained model.
model.load_weights("C:/Users/Diganta/Desktop/Courses_and_Projects/Projects/Bennet/model.h5")<jupyter_output><empty_output><jupyter_text>Prediction for Elliptical Test Data<jupyter_code>#Loading up the test data for Elliptical Image Type.
test_datagen = keras.preprocessing.image.ImageDataGenerator(rescale=1./255)
test_set = test_datagen.flow_from_directory(
        'C:/Users/Diganta/Desktop\Courses_and_Projects/Projects/Galaxy Classifier/efigi-1.6/data',
        target_size=(256, 256),
        batch_size=4458,
        class_mode='categorical')
X,y=test_set.next()
#Predictions
model.predict_classes(X, batch_size=4458, verbose=1)<jupyter_output><empty_output><jupyter_text>Prediction for Irregular Galaxy Type Test Data<jupyter_code>#Loading up the test data for Irregular Image Type.
test_datagen = keras.preprocessing.image.ImageDataGenerator(rescale=1./255)
test_set = test_datagen.flow_from_directory(
        'Category1',
        target_size=(256, 256),
        batch_size=64,
        class_mode='categorical')
X,y=test_set.next()
#Predictions
model.predict_classes(X, batch_size=32, verbose=1)<jupyter_output>64/64 [==============================] - 5s 86ms/step<jupyter_text>Prediction for Spiral Galaxy Type Test Data<jupyter_code>#Loading up the test data for Spiral Image Type.
test_datagen = keras.preprocessing.image.ImageDataGenerator(rescale=1./255)
test_set = test_datagen.flow_from_directory(
        'Category2',
        target_size=(256, 256),
        batch_size=64,
        class_mode='categorical')
X,y=test_set.next()
#Predictions
model.predict_classes(X, batch_size=32, verbose=1)<jupyter_output>64/64 [==============================] - 5s 77ms/step
{'fraction_non_alphanumeric': 0.12118100128369705, 'fraction_numerical': 0.04518613607188703, 'mean_word_length': 5.04031007751938, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '600419', 'license': 'MIT', 'n_tokens_mistral': 1358, 'n_tokens_neox': 1233, 'n_words': 315, 'path': 'Model_Application.ipynb', 'repo_name': 'mads5/Galaxy-Classifier', 'size': '3895'}