Import Libraries


In [1]:
import matplotlib.pyplot as plt
import urllib
from bs4 import BeautifulSoup
from selenium import webdriver
import re
import os,sys
import time
from datetime import date
try:
    import cPickle as pickle
except:
    import pickle
import pprint
from collections import deque
from shutil import copyfile
import random
import glob
# Import the required modules
import cv2, os
import numpy as np
from PIL import Image

In [2]:
pkl_fl = open("linkedin_profiles.pickle","rb")
my_original_list=pickle.load(pkl_fl) # errors out here
pkl_fl.close()

In [124]:
fileList = glob.glob("./Images/*.*")

In [ ]:
directory = "Male"
    
if not os.path.exists(directory):
    os.makedirs(directory)

directory1 = "Female"

if not os.path.exists(directory1):
    os.makedirs(directory1)    

    
for id,fp in enumerate(fileList):
    filename, file_extension = os.path.splitext(fp)
    uid = filename.split('/')[-1]
    #print fp
    for prof in my_original_list:
        if prof['User_ID'] == uid:
            new_file_extension = prof['Gender']
            new_file_extension = new_file_extension.title()
            #os.rename(fp, filename+"."+new_file_extension)
            copyfile(filename+".jpg", './Lable_Images1/'+ uid + '.' + str(id) + "."+new_file_extension+'.jpg')
            #copyfile(filename+".jpg", new_file_extension +'/'+uid+"."+new_file_extension)

In [ ]:
import os
for file in os.listdir("Lable_Images1"):
    file_path = os.path.join("Lable_Images1", file)
    try:
        if not file.endswith('.jpg'):
            os.unlink(file_path)
        #elif os.path.isdir(file_path): shutil.rmtree(file_path)
    except Exception as e:
        print(e)

In [3]:
# For face detection we will use the Haar Cascade provided by OpenCV.
cascadePath = "haarcascade_frontalface_default.xml"
faceCascade = cv2.CascadeClassifier(cascadePath)

# For face recognition we will the the LBPH Face Recognizer 
recognizer = cv2.createLBPHFaceRecognizer()

In [13]:
def get_images_and_labels(path):
    # Append all the absolute image paths in a list image_paths
    
    image_paths = [os.path.join(path, f) for f in os.listdir(path)]
    # images will contains face images
    images = []
    # labels will contains the label that is assigned to the image
    labels = []
    #gender will contains 1 or 0 indecating male or female
    gender =[]
    
    for image_path in image_paths:
        # Read the image and convert to grayscale
        try:
            image_pil = Image.open(image_path).convert('L')
            # Convert the image format into numpy array
            image = np.array(image_pil, 'uint8')
            # Get the label of the image
        except:
            pass
        
        nbr = int(os.path.split(image_path)[1].split(".")[1])
        gender_current = os.path.split(image_path)[1].split(".")[2]
        print nbr
        
        # Detect the face in the image
        faces = faceCascade.detectMultiScale(image)
        # If face is detected, append the face to images and the label to labels
        try:
            for (x, y, w, h) in faces:

                ref_image = image[y: y + h, x: x + w]
                resized = cv2.resize(ref_image, (100, 100), interpolation = cv2.INTER_AREA)
                images.append(resized)
                labels.append(nbr)

                if gender_current == 'Male':
                    gender.append(1)
                else:
                    gender.append(0)

                cv2.imshow("Adding faces to traning set...", resized)
                cv2.waitKey(50)
        except:
            pass
    # return the images list and labels list
    print "lables"
    print labels
    print "gender_current"
    print gender
    
    return images, labels, gender

In [78]:
images, labels, gender = get_images_and_labels('Lable_Images1')

cv2.destroyAllWindows()


701
1019
730
587
390
588
900
1018
396
887
1173
430
1076
49
780
961
571
496
965
647
77
378
210
983
132
397
81
363
1033
193
445
687
417
1080
1079
93
676
466
739
487
416
987
434
313
1117
114
164
778
471
959
699
41
284
1090
273
419
538
1166
1108
750
744
1066
1036
1035
525
1109
796
1068
451
152
964
161
460
1037
1120
826
1100
654
399
189
446
1046
404
306
209
945
83
767
1136
664
988
650
625
928
989
109
108
723
657
213
264
427
301
1089
612
1016
1121
985
62
178
721
764
876
320
846
194
295
726
23
212
151
394
156
249
1015
492
228
711
97
241
1130
325
470
968
1010
115
670
265
560
848
909
237
1103
339
300
290
656
986
1145
1027
107
355
698
745
729
1097
578
106
845
595
103
1058
854
828
883
134
1161
457
692
757
188
1072
142
1168
409
1044
856
901
1083
747
160
80
785
346
552
537
424
892
304
260
225
759
517
1078
519
580
177
1158
458
24
495
641
820
414
1086
627
877
253
1167
1087
749
691
873
954
11
798
170
797
319
779
251
1155
535
748
342
534
1062
616
832
379
1092
546
205
831
46
863
722
896
1149
570
867
626
1023
1147
719
48
1153
899
605
44
761
307
1084
851
413
653
515
708
39
326
898
59
579
1095
821
718
463
501
955
1051
444
808
94
1131
4
1006
442
291
1002
944
602
728
709
1071
998
598
335
825
697
388
927
184
645
756
377
746
328
1
788
981
303
1021
607
646
385
633
437
352
852
505
882
686
195
586
99
139
875
238
1038
803
171
138
510
236
135
975
146
623
630
784
120
783
572
224
564
807
333
344
1012
794
782
187
258
20
679
422
549
581
870
531
21
482
36
597
165
66
695
528
548
1013
500
1024
504
275
860
311
672
774
450
503
523
86
347
532
361
426
483
754
277
914
1139
799
735
919
185
540
857
211
196
168
206
231
17
972
888
343
158
316
247
606
183
439
341
1055
128
7
929
555
675
940
65
405
1119
1115
75
477
3
585
90
58
1049
841
700
936
895
70
79
533
159
621
541
1069
1098
942
31
324
50
101
1140
1064
1099
32
372
566
1003
891
465
771
614
693
428
369
1105
776
522
283
952
562
906
1126
215
838
777
908
1000
190
960
915
26
61
806
843
202
576
449
511
539
497
743
768
530
995
425
703
916
72
618
840
145
1127
938
923
69
321
1107
1159
293
507
795
271
677
648
1144
176
1030
52
751
420
937
447
1094
512
122
953
651
359
266
479
314
732
963
753
513
1134
731
1118
966
734
999
789
68
791
53
406
368
984
436
25
285
1041
736
133
561
387
716
1124
167
1057
1039
1061
930
144
926
830
27
317
222
1132
577
453
950
688
116
547
489
689
712
473
455
1170
57
296
554
931
781
639
980
102
678
454
949
1011
464
432
969
216
1157
356
485
706
415
1052
982
268
472
844
951
15
111
323
1048
741
667
1125
279
244
392
400
143
604
30
157
33
943
1045
223
370
350
269
563
353
1162
1001
740
704
281
248
1164
613
710
329
82
603
35
632
130
864
714
338
286
970
366
1009
707
312
240
569
925
462
755
43
790
60
1152
169
824
762
131
823
550
360
878
292
149
1129
967
1014
815
85
545
110
737
433
441
1034
389
287
922
380
272
556
474
67
100
1135
871
683
192
529
175
331
227
994
362
837
869
42
787
567
509
336
219
174
401
410
351
868
1081
913
1146
92
996
705
890
1122
1020
526
289
250
903
904
1043
617
557
1047
200
715
1070
398
822
833
1163
853
801
702
84
912
663
180
232
1160
207
918
652
601
924
1156
662
104
717
644
802
805
514
73
229
669
775
763
476
817
407
629
773
1093
456
1138
469
226
849
376
386
631
991
1065
1116
278
297
911
340
971
121
435
809
233
880
634
1137
518
56
280
1077
429
1165
591
421
1151
411
583
105
113
1054
334
1063
1017
886
197
1141
786
129
245
668
480
12
624
894
636
298
502
254
423
1150
71
1128
19
859
1060
524
494
1008
520
643
54
814
234
412
348
527
491
544
1028
933
804
1171
1110
395
819
1085
685
18
885
660
694
811
322
148
137
508
1075
488
990
619
305
98
126
889
1074
690
1031
1022
443
609
282
696
259
230
1073
1101
516
671
584
1142
659
958
622
1133
810
974
993
792
198
642
818
337
391
543
0
1091
140
666
1169
481
365
1082
920
lables
[701, 1019, 730, 390, 588, 900, 1018, 887, 1173, 1173, 430, 49, 780, 780, 961, 571, 496, 965, 647, 77, 378, 378, 210, 983, 983, 132, 397, 81, 81, 363, 1033, 1033, 193, 445, 687, 417, 1080, 1079, 93, 676, 676, 466, 739, 487, 416, 987, 434, 313, 1117, 1117, 1117, 114, 778, 471, 959, 699, 41, 284, 1090, 1090, 273, 419, 419, 538, 1166, 1108, 1108, 750, 744, 1066, 1036, 1035, 796, 1068, 451, 152, 964, 161, 460, 1037, 1120, 826, 1100, 1100, 654, 399, 189, 446, 1046, 404, 209, 945, 83, 767, 1136, 664, 988, 650, 625, 625, 928, 109, 108, 108, 657, 264, 427, 301, 1089, 1089, 612, 612, 1016, 985, 62, 62, 178, 721, 764, 876, 320, 320, 846, 846, 194, 295, 726, 23, 212, 151, 394, 156, 156, 249, 249, 1015, 492, 228, 711, 711, 97, 241, 1130, 325, 470, 968, 1010, 115, 670, 265, 560, 848, 848, 848, 848, 909, 909, 237, 1103, 1103, 339, 339, 300, 300, 290, 656, 1145, 1027, 1027, 107, 107, 355, 698, 745, 729, 1097, 578, 106, 845, 845, 595, 595, 595, 103, 1058, 854, 828, 828, 883, 134, 1161, 457, 457, 692, 692, 757, 188, 1072, 142, 1168, 409, 1044, 856, 1083, 747, 160, 80, 785, 346, 552, 537, 424, 892, 304, 304, 260, 759, 517, 1078, 519, 580, 177, 1158, 24, 495, 641, 820, 820, 414, 1086, 1086, 627, 627, 627, 877, 877, 253, 253, 1087, 749, 691, 873, 954, 11, 170, 797, 319, 779, 251, 1155, 535, 535, 748, 342, 534, 1062, 616, 832, 832, 379, 1092, 546, 205, 831, 46, 46, 863, 722, 722, 1149, 1149, 570, 867, 626, 1023, 1147, 719, 48, 48, 1153, 1153, 899, 605, 44, 761, 307, 307, 1084, 851, 413, 413, 653, 515, 708, 708, 39, 326, 898, 898, 898, 59, 579, 579, 1095, 821, 718, 463, 501, 955, 1051, 444, 808, 94, 1131, 1131, 1006, 291, 291, 1002, 944, 602, 728, 709, 1071, 998, 598, 335, 825, 697, 697, 388, 388, 927, 184, 645, 756, 377, 746, 328, 1, 788, 981, 303, 1021, 607, 646, 385, 633, 437, 352, 852, 505, 882, 686, 686, 686, 195, 195, 99, 875, 1038, 803, 138, 510, 135, 975, 975, 623, 623, 630, 120, 783, 572, 224, 564, 807, 333, 344, 1012, 794, 782, 782, 258, 20, 679, 422, 549, 581, 870, 531, 21, 482, 597, 165, 66, 695, 528, 548, 1013, 500, 1024, 1024, 504, 275, 860, 860, 860, 311, 672, 774, 450, 503, 503, 523, 86, 347, 361, 426, 483, 483, 754, 277, 914, 1139, 735, 919, 185, 857, 211, 196, 168, 206, 231, 17, 972, 888, 888, 888, 888, 343, 343, 158, 316, 247, 247, 606, 183, 439, 341, 1055, 128, 7, 929, 555, 940, 65, 405, 1119, 1115, 75, 477, 3, 585, 90, 58, 1049, 841, 700, 936, 895, 70, 79, 533, 533, 159, 621, 541, 1069, 1098, 942, 942, 324, 101, 1140, 1140, 1140, 1064, 1099, 32, 32, 372, 566, 1003, 891, 891, 771, 614, 693, 428, 369, 1105, 776, 776, 776, 522, 283, 952, 562, 906, 1126, 1126, 215, 838, 777, 908, 908, 908, 1000, 190, 190, 915, 26, 806, 843, 202, 576, 449, 449, 511, 539, 497, 497, 497, 743, 768, 530, 995, 425, 425, 425, 916, 916, 72, 618, 840, 145, 1127, 938, 923, 69, 321, 1107, 1159, 293, 507, 795, 271, 271, 677, 648, 1144, 176, 1030, 52, 751, 420, 937, 447, 1094, 512, 122, 953, 651, 651, 359, 266, 266, 479, 314, 732, 963, 753, 513, 1134, 731, 1118, 734, 999, 789, 789, 68, 791, 53, 406, 368, 984, 436, 25, 285, 1041, 736, 133, 133, 133, 133, 561, 387, 716, 716, 716, 1124, 167, 1057, 1039, 1061, 930, 144, 144, 926, 830, 27, 27, 317, 222, 1132, 577, 453, 950, 688, 116, 547, 489, 689, 712, 473, 455, 1170, 57, 57, 296, 554, 931, 781, 639, 980, 102, 102, 678, 454, 949, 1011, 1011, 464, 432, 969, 216, 1157, 356, 485, 485, 415, 1052, 1052, 982, 268, 472, 844, 951, 15, 15, 111, 323, 1048, 1048, 741, 741, 667, 1125, 279, 279, 244, 392, 400, 143, 604, 30, 157, 33, 943, 1045, 1045, 223, 370, 350, 269, 269, 563, 353, 1162, 1001, 740, 704, 704, 281, 248, 1164, 613, 710, 329, 82, 603, 35, 632, 130, 864, 864, 714, 338, 286, 970, 366, 1009, 707, 312, 240, 240, 569, 925, 462, 755, 43, 790, 60, 1152, 169, 824, 762, 131, 823, 823, 550, 360, 878, 292, 149, 1129, 967, 1014, 815, 85, 545, 545, 110, 737, 433, 433, 441, 1034, 389, 389, 287, 922, 380, 380, 272, 556, 474, 474, 67, 67, 100, 1135, 871, 683, 192, 529, 529, 175, 331, 331, 227, 994, 362, 837, 869, 42, 787, 787, 567, 509, 509, 336, 219, 174, 401, 410, 351, 351, 868, 868, 1081, 913, 1146, 92, 92, 996, 705, 890, 1122, 1020, 526, 289, 250, 903, 903, 1043, 1043, 617, 617, 557, 1047, 200, 715, 1070, 398, 822, 833, 801, 702, 84, 663, 663, 663, 180, 232, 207, 918, 652, 924, 1156, 662, 104, 717, 644, 802, 802, 802, 802, 805, 805, 514, 73, 229, 669, 775, 775, 763, 476, 817, 407, 407, 629, 629, 773, 1093, 456, 1138, 469, 226, 849, 376, 386, 386, 631, 991, 1065, 1116, 278, 297, 911, 911, 340, 971, 121, 121, 435, 233, 880, 634, 1137, 518, 280, 1077, 1077, 429, 1165, 591, 421, 1151, 411, 583, 105, 113, 1054, 334, 1063, 1017, 886, 197, 786, 786, 129, 245, 245, 480, 12, 12, 624, 624, 894, 636, 298, 298, 502, 254, 254, 423, 1150, 71, 1128, 19, 19, 859, 1060, 524, 524, 524, 494, 1008, 520, 643, 54, 814, 234, 412, 348, 348, 527, 527, 491, 544, 1028, 933, 804, 1171, 1171, 1171, 1110, 395, 819, 819, 1085, 685, 885, 885, 660, 694, 811, 811, 322, 148, 137, 508, 1075, 488, 488, 488, 990, 990, 619, 305, 98, 98, 126, 126, 889, 1074, 1031, 1022, 443, 609, 282, 696, 259, 230, 1073, 1101, 1101, 516, 671, 584, 1142, 659, 958, 958, 622, 1133, 810, 810, 974, 993, 993, 792, 198, 642, 642, 818, 818, 818, 337, 391, 543, 0, 0, 1091, 666, 481, 365, 365, 365, 1082, 920]
gender_current
[0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 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 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1]

In [80]:
images[0].shape


Out[80]:
(100, 100)

In [ ]:

Making the Dataset


In [119]:
res_images = []
res_gender = []

for img in images:
    res_images.append(img.reshape(1,10000))    # (100*100 image size)

for gen in gender:
    res_gender.append(np.array(gen).reshape(1,))
    
res_images = np.concatenate(res_images, axis=0)
res_gender = np.concatenate(res_gender,axis=0)

In [122]:
res_images.shape


Out[122]:
(1032, 10000)

In [123]:
res_gender.shape


Out[123]:
(1032,)

In [ ]:


In [ ]:


In [113]:
X,y = res_images,res_gender

In [ ]:


In [117]:
X_Train, X_Test = X[:1000], X[1000:]
y_Train, y_Test = y[:1000], y[1000:]


print y_Train.shape,y_Test.shape


(1000,) (32,)

In [ ]:


In [118]:
# Logistic Regression
from sklearn import datasets
from sklearn import metrics
from sklearn.linear_model import LogisticRegression
# load the iris datasets
#dataset = datasets.load_iris()
# fit a logistic regression model to the data
model = LogisticRegression(C=1e5)
model.fit(X_Train,y_Train)
print(model)
# make predictions
expected = y_Test
predicted = model.predict(X_Test)
# summarize the fit of the model
print(metrics.classification_report(expected, predicted))
print(metrics.confusion_matrix(expected, predicted))


LogisticRegression(C=100000.0, class_weight=None, dual=False,
          fit_intercept=True, intercept_scaling=1, max_iter=100,
          multi_class='ovr', n_jobs=1, penalty='l2', random_state=None,
          solver='liblinear', tol=0.0001, verbose=0, warm_start=False)
             precision    recall  f1-score   support

          0       0.64      0.75      0.69        12
          1       0.83      0.75      0.79        20

avg / total       0.76      0.75      0.75        32

[[ 9  3]
 [ 5 15]]

In [ ]:


In [ ]: