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
prediction=model.predict(prediction_image) | |
value=np.argmax(prediction) | |
move_name=mapper(value) | |
print("Prediction is {}.".format(move_name)) |
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("fruits/test/test/0030.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) |
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=10) |
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_generator = img_datagen.flow_from_directory(directory, | |
shuffle=True, | |
batch_size=32, | |
subset='training', | |
target_size=(100, 100)) | |
valid_generator = img_datagen.flow_from_directory(directory, | |
shuffle=True, | |
batch_size=16, | |
subset='validation', |
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
img_datagen = ImageDataGenerator(rescale=1./255, | |
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) | |
test_datagen = ImageDataGenerator(rescale=1./255) |
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
Name=[] | |
for file in os.listdir(directory): | |
Name+=[file] | |
fruit_map = dict(zip(Name, [t for t in range(len(Name))])) | |
print(fruit_map) | |
r_fruit_map=dict(zip([t for t in range(len(Name))],Name)) |
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/fruits.zip" | |
!unzip -qo fruits.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
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)) |