This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model.save('math.h5') | |
!deepCC math.h5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image = Single_Image_Prediction(valid_gen[0][0][17]) | |
pred_value = model.predict(image) | |
#print(pred_value) | |
index_value = np.argmax(pred_value,axis=1) #For categorical model | |
print("Prediction=",dev[index_value[0]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image = Single_Image_Prediction(valid_gen[0][0][8]) | |
pred_value = model.predict(image) | |
#print(pred_value) | |
index_value = np.argmax(pred_value,axis=1) #For categorical model | |
print("Prediction=",dev[index_value[0]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dev= ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'add', 'dec', 'div', 'eq', 'mul', 'sub', 'x', 'y', 'z'] | |
def Single_Image_Prediction(file): | |
#image = load_img(file, color_mode='rgb', target_size=(128, 128)) | |
image= file | |
print("Actual Letter") | |
plt.imshow((image * .255).astype(np.uint8), cmap='gray') | |
plt.show() | |
print(image.shape) | |
# cv.imshow('image',file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dev= ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'add', 'dec', 'div', 'eq', 'mul', 'sub', 'x', 'y', 'z'] | |
def Single_Image_Prediction(file): | |
#image = load_img(file, color_mode='rgb', target_size=(128, 128)) | |
image= file | |
print("Actual Letter") | |
plt.imshow((image * .255).astype(np.uint8), cmap='gray') | |
plt.show() | |
print(image.shape) | |
# cv.imshow('image',file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plt.plot(history.history['loss']) | |
plt.plot(history.history['val_loss']) | |
plt.title('Model Loss') | |
plt.xlabel('Epoch') | |
plt.ylabel('Loss') | |
plt.legend(['Train','Test'], loc= 'upper right'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plt.plot(history.history['accuracy']) | |
plt.plot(history.history['val_accuracy']) | |
plt.title("Model Accuracy") | |
plt.xlabel("Epoch") | |
plt.ylabel("Accuracy") | |
plt.legend(["Train", "Test"], loc= "lower right"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model.compile(optimizer= 'adam', loss= 'categorical_crossentropy', metrics= ['accuracy']) | |
history= model.fit(train_gen, epochs= 25, validation_data= valid_gen) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model= Sequential([ | |
layers.Conv2D(32, (3,3), activation= 'relu', input_shape= (50,50,1)), | |
layers.MaxPooling2D(pool_size= (2,2), padding= 'same'), | |
layers.Dropout(0.2), | |
layers.Conv2D(16, (3,3), activation= 'relu'), | |
layers.MaxPooling2D(pool_size= (2,2), padding= 'same'), | |
layers.Flatten(), | |
layers.Dense(120, activation= 'relu'), | |
layers.Dropout(0.2), | |
layers.Dense(75, activation= 'relu'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
train_dir= './trainn/' | |
train_datagen= tf.keras.preprocessing.image.ImageDataGenerator(rescale= 1/.255, validation_split= 0.2) | |
train_gen= train_datagen.flow_from_directory(train_dir, target_size= (50,50), color_mode= 'grayscale', class_mode= 'categorical', batch_size= 32, subset= 'training') | |
valid_gen= train_datagen.flow_from_directory(train_dir, target_size= (50,50), color_mode= 'grayscale', class_mode= 'categorical', batch_size= 32, subset= 'validation') |
NewerOlder