Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created November 25, 2020 06:30
Show Gist options
  • Save amankharwal/fa7d699e43f33247fb42b490ffc70fff to your computer and use it in GitHub Desktop.
Save amankharwal/fa7d699e43f33247fb42b490ffc70fff to your computer and use it in GitHub Desktop.
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