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
import numpy as np | |
import tensorflow as tf | |
from tensorflow import keras | |
from tensorflow.keras import layers | |
import pandas as pd | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
import wget | |
import os |
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=load_img("dog_photos/test/image4.jpg",target_size=(100,100)) | |
image=img_to_array(image) | |
image=image/255.0 | |
prediction_image=np.array(image) | |
prediction_image= np.expand_dims(image, axis=0) | |
prediction=model.predict(prediction_image) | |
value=np.argmax(prediction) | |
move_name=mapper(value) |
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
load_img("dog_photos/test/image4.jpg",target_size=(180,180)) |
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_generator, validation_data=valid_generator, | |
steps_per_epoch=train_generator.n//train_generator.batch_size, | |
validation_steps=valid_generator.n//valid_generator.batch_size, | |
epochs=120) |
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() | |
model.add(Conv2D(filters=32, kernel_size=(3,3),input_shape=(100,100,3), activation='relu', padding = 'same')) | |
model.add(MaxPooling2D(pool_size=(2, 2))) | |
model.add(Conv2D(filters=64, kernel_size=(3,3), activation='relu', padding = 'same')) | |
model.add(MaxPooling2D(pool_size=(2, 2))) | |
model.add(Conv2D(filters=64, kernel_size=(3,3), activation='relu', padding = 'same')) | |
model.add(MaxPooling2D(pool_size=(2, 2))) |
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
!wget -N "https://cainvas-static.s3.amazonaws.com/media/user_data/AmrutaKoshe/dog_photos.zip" | |
!unzip -qo dog_photos.zip |
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
score = model.evaluate(val_gen, steps= len(val_gen)) | |
for idx, metric in enumerate(model.metrics_names): | |
print('{}:{}'.format(metric, score[idx])) |
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() | |
model.add(Conv2D(filters=32, kernel_size=(3,3),input_shape=(100,100,3), activation='relu', padding = 'same')) | |
model.add(MaxPooling2D(pool_size=(2, 2))) | |
model.add(Conv2D(filters=64, kernel_size=(3,3), activation='relu', padding = 'same')) | |
model.add(MaxPooling2D(pool_size=(2, 2))) | |
model.add(Conv2D(filters=64, kernel_size=(3,3), activation='relu', padding = 'same')) | |
model.add(MaxPooling2D(pool_size=(2, 2))) |
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_datagen = ImageDataGenerator(vertical_flip=True, | |
horizontal_flip=True, | |
rotation_range=40, | |
width_shift_range=0.2, | |
height_shift_range=0.2, | |
zoom_range=0.1, | |
validation_split=0.2) | |
val_datagen = ImageDataGenerator() |
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
from sklearn.model_selection import train_test_split | |
X_train, X_val, y_train, y_val = train_test_split(Train_Imgs, Train_Lbls, shuffle = True, test_size = 0.2, random_state = 42) | |
print('Shape of X_train: {}, y_train: {} '.format(X_train.shape, y_train.shape)) | |
print('Shape of X_val: {}, y_val: {} '.format(X_val.shape, y_val.shape)) |
NewerOlder