Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created November 25, 2020 06:30

Revisions

  1. amankharwal created this gist Nov 25, 2020.
    17 changes: 17 additions & 0 deletions gender.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    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)