Skip to content

Instantly share code, notes, and snippets.

View ajaymuktha's full-sized avatar
💻

Sai Ajay ajaymuktha

💻
View GitHub Profile
x = Flatten()(vgg.output)
prediction = Dense(len(folders), activation='softmax')(x)
folders = glob('Datasets/train/*')
# don't train existing weights
for layer in vgg.layers:
layer.trainable = False
vgg = VGG16(input_shape=IMAGE_SIZE + [3], weights='imagenet', include_top=False)
train_path = 'Datasets/train'
valid_path = 'Datasets/test'
# re-size all the images
IMAGE_SIZE = [224, 224]
from keras.layers import Input, Lambda, Dense, Flatten
from keras.models import Model
from keras.applications.vgg16 import VGG16
from keras.applications.vgg16 import preprocess_input
from keras.preprocessing import image
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
import numpy as np
from glob import glob
import matplotlib.pyplot as plt
result = cnn.predict(test_image)
training_set.class_indicies
if result[0][0] == 1
prediction = 'dog'
else
prediction = 'cat'
print(prediction)
import numpy as np
from keras.preprocessing import image
test_image = image.load_img('dataset/prediction/image1.jpg', target_size = (64,64))
test_image = image.img_to_array(test_image)
test_image = np.expand_dims(test_image, axis = 0)
cnn.fit(x = training_set, validation_data = test_set, epochs =25)