Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created Nov 25, 2020
Embed
What would you like to do?
import numpy as np
from keras.preprocessing import image
# predicting images
path = "gender-recognition-200k-images-celeba/Dataset/Test/Female/160001.jpg"
img = image.load_img(path, target_size=(64, 64))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
images = np.vstack([x])
classes = model.predict(images, batch_size=1)
print(classes[0])
if classes[0]>0.5:
print("is a man")
else:
print( " is a female")
plt.imshow(img)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment