suvadityamuk commited on
Commit
471c9f3
1 Parent(s): dc063d8

added new files and made changes in app.py

Browse files

Signed-off-by: Suvaditya Mukherjee <suvadityamuk@gmail.com>

This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. app.py +16 -15
  2. celeb_dataset/Angelina Jolie/006_9135205d.jpg +3 -0
  3. celeb_dataset/Angelina Jolie/007_cabbfcbb.jpg +3 -0
  4. celeb_dataset/Angelina Jolie/008_d1f87068.jpg +3 -0
  5. celeb_dataset/Angelina Jolie/009_fb3e6174.jpg +3 -0
  6. celeb_dataset/Angelina Jolie/010_f99d79e3.jpg +3 -0
  7. celeb_dataset/Brad Pitt/006_87166f38.jpg +3 -0
  8. celeb_dataset/Brad Pitt/007_74ccfb4a.jpg +3 -0
  9. celeb_dataset/Brad Pitt/008_31e90c6b.jpg +3 -0
  10. celeb_dataset/Brad Pitt/009_23c94f29.jpg +3 -0
  11. celeb_dataset/Brad Pitt/010_08c44431.jpg +3 -0
  12. celeb_dataset/Denzel Washington/006_2880115c.jpg +3 -0
  13. celeb_dataset/Denzel Washington/007_1f6f632a.jpg +3 -0
  14. celeb_dataset/Denzel Washington/008_7619a328.jpg +3 -0
  15. celeb_dataset/Denzel Washington/009_817304c7.jpg +3 -0
  16. celeb_dataset/Denzel Washington/010_47031d88.jpg +3 -0
  17. celeb_dataset/Hugh Jackman/006_ff6876d9.jpg +3 -0
  18. celeb_dataset/Hugh Jackman/007_68abd54d.jpg +3 -0
  19. celeb_dataset/Hugh Jackman/008_d5553651.jpg +3 -0
  20. celeb_dataset/Hugh Jackman/009_11c22a3b.jpg +3 -0
  21. celeb_dataset/Hugh Jackman/010_cce39614.jpg +3 -0
  22. celeb_dataset/Jennifer Lawrence/006_2d0dccd4.jpg +3 -0
  23. celeb_dataset/Jennifer Lawrence/007_72ad75ba.jpg +3 -0
  24. celeb_dataset/Jennifer Lawrence/008_35fbbb0c.jpg +3 -0
  25. celeb_dataset/Jennifer Lawrence/009_bcd380a7.jpg +3 -0
  26. celeb_dataset/Jennifer Lawrence/010_34d63b53.jpg +3 -0
  27. celeb_dataset/Johnny Depp/006_8fc31fd7.jpg +3 -0
  28. celeb_dataset/Johnny Depp/007_1bc0bcd6.jpg +3 -0
  29. celeb_dataset/Johnny Depp/008_35d1be70.jpg +3 -0
  30. celeb_dataset/Johnny Depp/009_f4a38fec.jpg +3 -0
  31. celeb_dataset/Johnny Depp/010_610eea60.jpg +3 -0
  32. celeb_dataset/Kate Winslet/006_eda1948f.jpg +3 -0
  33. celeb_dataset/Kate Winslet/007_572cf58c.jpg +3 -0
  34. celeb_dataset/Kate Winslet/008_6c01eb52.jpg +3 -0
  35. celeb_dataset/Kate Winslet/009_07c15c37.jpg +3 -0
  36. celeb_dataset/Kate Winslet/010_6102c83d.jpg +3 -0
  37. celeb_dataset/Leonardo DiCaprio/006_30010640.jpg +3 -0
  38. celeb_dataset/Leonardo DiCaprio/007_6ca7c622.jpg +3 -0
  39. celeb_dataset/Leonardo DiCaprio/008_35daa4bc.jpg +3 -0
  40. celeb_dataset/Leonardo DiCaprio/009_b86449f6.jpg +3 -0
  41. celeb_dataset/Leonardo DiCaprio/010_2f9c83bc.jpg +3 -0
  42. celeb_dataset/Megan Fox/006_4e33c943.jpg +3 -0
  43. celeb_dataset/Megan Fox/007_e3073d58.jpg +3 -0
  44. celeb_dataset/Megan Fox/008_74bda018.jpg +3 -0
  45. celeb_dataset/Megan Fox/009_3283c30e.jpg +3 -0
  46. celeb_dataset/Megan Fox/010_0479e335.jpg +3 -0
  47. celeb_dataset/Natalie Portman/006_51ad8fdd.jpg +3 -0
  48. celeb_dataset/Natalie Portman/007_b82eb947.jpg +3 -0
  49. celeb_dataset/Natalie Portman/008_8fc20495.jpg +3 -0
  50. celeb_dataset/Natalie Portman/009_3300e98f.jpg +3 -0
app.py CHANGED
@@ -10,15 +10,15 @@ from sklearn.svm import SVC
10
 
11
  def calc_embeddings(all_files, names):
12
  detector = cv2.dnn.readNetFromCaffe(
13
- "../deploy.prototxt.txt", "../res10_300x300_ssd_iter_140000.caffemodel"
14
  )
15
- embedder = cv2.dnn.readNetFromTorch("../openface.nn4.small2.v1.t7")
16
  knownNames = []
17
  knownEmbeddings = []
18
  total = 0
19
  for file in all_files:
20
  name = names[total]
21
- path = os.path.join(os.getcwd(), name, file)
22
  # f = open(f"/celeb_dataset/'{name}'/{file}", "rb")
23
  f = open(path, "rb")
24
  file_bytes = np.asarray(bytearray(f.read()), dtype=np.uint8)
@@ -57,9 +57,9 @@ def calc_embeddings(all_files, names):
57
  knownNames.append(name)
58
  knownEmbeddings.append(vec.flatten())
59
  total += 1
60
- with open("../unknownEmbeddings.pkl", "rb") as fp:
61
  l = pickle.load(fp)
62
- with open("../unknownNames.pkl", "rb") as fp:
63
  n = pickle.load(fp)
64
  for i in l:
65
  knownEmbeddings.append(i)
@@ -79,27 +79,27 @@ def recognize(embeddings, names):
79
 
80
  def run_inference(myImage):
81
 
82
- os.chdir("celeb_dataset")
83
  celebs = []
84
  scores = dict()
85
 
86
- for celeb in os.listdir():
87
  files = []
88
  names = []
89
  if celeb in celebs:
90
  continue
91
  name = celeb
92
  celebs.append(name)
93
- for file in os.listdir(celeb):
94
  files.append(file)
95
  names.append(name)
96
  embeddings, names = calc_embeddings(files, names)
97
  le, model = recognize(embeddings, names)
98
  detector = cv2.dnn.readNetFromCaffe(
99
- "../deploy.prototxt.txt",
100
- "../res10_300x300_ssd_iter_140000.caffemodel",
101
  )
102
- embedder = cv2.dnn.readNetFromTorch("../openface.nn4.small2.v1.t7")
103
  (h, w) = myImage.shape[:2]
104
  imageBlob = cv2.dnn.blobFromImage(
105
  cv2.resize(myImage, (300, 300)),
@@ -130,10 +130,11 @@ def run_inference(myImage):
130
  j = np.argmax(preds)
131
  proba = preds[j]
132
  name = le.classes_[j]
133
- # text = "{}: {:.2f}%".format(name, proba * 100)
134
- scores[name] = proba * 100
135
- result = sorted(scores.items(), key=lambda x: x[1], reverse=True)
136
- return result
 
137
 
138
 
139
  iface = gr.Interface(
 
10
 
11
  def calc_embeddings(all_files, names):
12
  detector = cv2.dnn.readNetFromCaffe(
13
+ "deploy.prototxt.txt", "res10_300x300_ssd_iter_140000.caffemodel"
14
  )
15
+ embedder = cv2.dnn.readNetFromTorch("openface.nn4.small2.v1.t7")
16
  knownNames = []
17
  knownEmbeddings = []
18
  total = 0
19
  for file in all_files:
20
  name = names[total]
21
+ path = os.path.join(os.getcwd(), 'celeb_dataset', name, file)
22
  # f = open(f"/celeb_dataset/'{name}'/{file}", "rb")
23
  f = open(path, "rb")
24
  file_bytes = np.asarray(bytearray(f.read()), dtype=np.uint8)
 
57
  knownNames.append(name)
58
  knownEmbeddings.append(vec.flatten())
59
  total += 1
60
+ with open("unknownEmbeddings.pkl", "rb") as fp:
61
  l = pickle.load(fp)
62
+ with open("unknownNames.pkl", "rb") as fp:
63
  n = pickle.load(fp)
64
  for i in l:
65
  knownEmbeddings.append(i)
 
79
 
80
  def run_inference(myImage):
81
 
82
+ # os.chdir("./celeb_dataset")
83
  celebs = []
84
  scores = dict()
85
 
86
+ for celeb in os.listdir("./celeb_dataset"):
87
  files = []
88
  names = []
89
  if celeb in celebs:
90
  continue
91
  name = celeb
92
  celebs.append(name)
93
+ for file in os.listdir(os.path.join(os.getcwd(), 'celeb_dataset', celeb)):
94
  files.append(file)
95
  names.append(name)
96
  embeddings, names = calc_embeddings(files, names)
97
  le, model = recognize(embeddings, names)
98
  detector = cv2.dnn.readNetFromCaffe(
99
+ "deploy.prototxt.txt",
100
+ "res10_300x300_ssd_iter_140000.caffemodel",
101
  )
102
+ embedder = cv2.dnn.readNetFromTorch("openface.nn4.small2.v1.t7")
103
  (h, w) = myImage.shape[:2]
104
  imageBlob = cv2.dnn.blobFromImage(
105
  cv2.resize(myImage, (300, 300)),
 
130
  j = np.argmax(preds)
131
  proba = preds[j]
132
  name = le.classes_[j]
133
+ text = "{}: {:.2f}%".format(name, proba * 100)
134
+ scores[name] = proba
135
+ if len(scores)>1:
136
+ del scores["Unknown"]
137
+ return scores
138
 
139
 
140
  iface = gr.Interface(
celeb_dataset/Angelina Jolie/006_9135205d.jpg ADDED

Git LFS Details

  • SHA256: c38f4dd964850d29857d0b47f94345ec4661e0665547e3070901af1b664ddff8
  • Pointer size: 130 Bytes
  • Size of remote file: 45.1 kB
celeb_dataset/Angelina Jolie/007_cabbfcbb.jpg ADDED

Git LFS Details

  • SHA256: 47faa2f5c290fc346361d237de0bdd619c76c817119d9f5adafe066a9da9852f
  • Pointer size: 130 Bytes
  • Size of remote file: 21.7 kB
celeb_dataset/Angelina Jolie/008_d1f87068.jpg ADDED

Git LFS Details

  • SHA256: 081e4dff3ac92b83f0d954d9c19df5c2e58bb341bb49ec8ed72876bf5ff4ab28
  • Pointer size: 130 Bytes
  • Size of remote file: 33.3 kB
celeb_dataset/Angelina Jolie/009_fb3e6174.jpg ADDED

Git LFS Details

  • SHA256: cc18496be41c8d8c530df7014679294c5037209098dbc4201e91bd71d831e9f0
  • Pointer size: 130 Bytes
  • Size of remote file: 35.3 kB
celeb_dataset/Angelina Jolie/010_f99d79e3.jpg ADDED

Git LFS Details

  • SHA256: 5573a0edd56d0104ec43cdb9310458f5a5cef60db86c8c53efeb1e7931521a93
  • Pointer size: 130 Bytes
  • Size of remote file: 49 kB
celeb_dataset/Brad Pitt/006_87166f38.jpg ADDED

Git LFS Details

  • SHA256: 3aa7275ab73b4aae62e30737a443a25a357a4489fbde9ebe62b6244c31b542b7
  • Pointer size: 129 Bytes
  • Size of remote file: 8.51 kB
celeb_dataset/Brad Pitt/007_74ccfb4a.jpg ADDED

Git LFS Details

  • SHA256: 6ced2e7bc8cd1f8074340e18dddfb05214265fd060257fc5d329c58bf803ec39
  • Pointer size: 130 Bytes
  • Size of remote file: 10.8 kB
celeb_dataset/Brad Pitt/008_31e90c6b.jpg ADDED

Git LFS Details

  • SHA256: 5b5763b8de150ae599082e8dce38e9d977dca14a455c9f80746c7f2db73854fa
  • Pointer size: 130 Bytes
  • Size of remote file: 27.2 kB
celeb_dataset/Brad Pitt/009_23c94f29.jpg ADDED

Git LFS Details

  • SHA256: abfc581e160b367e1a35985f452f6bd0c182620970c906537db2f8ba0a2694bc
  • Pointer size: 129 Bytes
  • Size of remote file: 4.78 kB
celeb_dataset/Brad Pitt/010_08c44431.jpg ADDED

Git LFS Details

  • SHA256: d9375f12feef04e44e3e5021b401cff43ef15d900282090c23885b342af94661
  • Pointer size: 130 Bytes
  • Size of remote file: 26.1 kB
celeb_dataset/Denzel Washington/006_2880115c.jpg ADDED

Git LFS Details

  • SHA256: 1ad58078c96843764ddf4792852f171315c8cfcfaa0526a836106bc1519bef43
  • Pointer size: 130 Bytes
  • Size of remote file: 32 kB
celeb_dataset/Denzel Washington/007_1f6f632a.jpg ADDED

Git LFS Details

  • SHA256: e9ecdd619765fa81d5567194439bb210c2ef2728bfccdf6efeb76accb8b5a801
  • Pointer size: 130 Bytes
  • Size of remote file: 27 kB
celeb_dataset/Denzel Washington/008_7619a328.jpg ADDED

Git LFS Details

  • SHA256: 77cf5ee7c73ee7d5bf6176912d0505edcc7d096178fc4ce5b8306f60b49efc0e
  • Pointer size: 130 Bytes
  • Size of remote file: 33.7 kB
celeb_dataset/Denzel Washington/009_817304c7.jpg ADDED

Git LFS Details

  • SHA256: c3d61c18f6e62982a19af2ee97282b15ee1631bc8629768e5813f37e78a28fe0
  • Pointer size: 130 Bytes
  • Size of remote file: 47 kB
celeb_dataset/Denzel Washington/010_47031d88.jpg ADDED

Git LFS Details

  • SHA256: 48f4ac882d95e85a2d832a29968fbeb18195b89dba704c018f8c0b449f500065
  • Pointer size: 130 Bytes
  • Size of remote file: 45.4 kB
celeb_dataset/Hugh Jackman/006_ff6876d9.jpg ADDED

Git LFS Details

  • SHA256: 0a78aca97462da351ff59c11faf65c12bba167b39ef345317a7c27471e533c42
  • Pointer size: 130 Bytes
  • Size of remote file: 27.5 kB
celeb_dataset/Hugh Jackman/007_68abd54d.jpg ADDED

Git LFS Details

  • SHA256: 3985e6c1cc527bcdeb70ac21ba9ded98471f83ba0b4c00b1e6ae4d34f552159a
  • Pointer size: 130 Bytes
  • Size of remote file: 42.4 kB
celeb_dataset/Hugh Jackman/008_d5553651.jpg ADDED

Git LFS Details

  • SHA256: d8b15c27d1a77f75b4526e6de323ed3f355b6234e8210c5269c73097c8968662
  • Pointer size: 130 Bytes
  • Size of remote file: 44.7 kB
celeb_dataset/Hugh Jackman/009_11c22a3b.jpg ADDED

Git LFS Details

  • SHA256: 3ec27c22e2d22ea6d9f3b26b204b92088cfe24f6f7ffbe13c2de55a0b18c74be
  • Pointer size: 130 Bytes
  • Size of remote file: 38.7 kB
celeb_dataset/Hugh Jackman/010_cce39614.jpg ADDED

Git LFS Details

  • SHA256: fe184251c0d5e5af42d6401483c97d022d3762f04c9078f2aff45edd12c6e0f0
  • Pointer size: 130 Bytes
  • Size of remote file: 30.8 kB
celeb_dataset/Jennifer Lawrence/006_2d0dccd4.jpg ADDED

Git LFS Details

  • SHA256: 75ccd16c3ce7cf95e7e2db418622c4f04b249e1a96540f59424fd46018dd7a99
  • Pointer size: 130 Bytes
  • Size of remote file: 23.3 kB
celeb_dataset/Jennifer Lawrence/007_72ad75ba.jpg ADDED

Git LFS Details

  • SHA256: 096df63aacea7205e5a5d335a618641ebc5c6dd63d7f1a963e671ecf5a365c33
  • Pointer size: 130 Bytes
  • Size of remote file: 32.6 kB
celeb_dataset/Jennifer Lawrence/008_35fbbb0c.jpg ADDED

Git LFS Details

  • SHA256: 06dcfb4205e62a900fae8402ea6c9871c158bdfaee023d37815c7503ff59501a
  • Pointer size: 130 Bytes
  • Size of remote file: 42.7 kB
celeb_dataset/Jennifer Lawrence/009_bcd380a7.jpg ADDED

Git LFS Details

  • SHA256: cf66a4a6bcc6346da56115f26af2be5bce50768a15b1ab2c1de21506c5ce920e
  • Pointer size: 130 Bytes
  • Size of remote file: 61.4 kB
celeb_dataset/Jennifer Lawrence/010_34d63b53.jpg ADDED

Git LFS Details

  • SHA256: b1439933e7ab52c7984f2216ea6b33173d5f9114b278ef65a75c2d14854a0314
  • Pointer size: 130 Bytes
  • Size of remote file: 57.3 kB
celeb_dataset/Johnny Depp/006_8fc31fd7.jpg ADDED

Git LFS Details

  • SHA256: fc3d20b7b3d8665cf22644a0c8e09492c4630db008a95bfc5f0b555b4ebd7322
  • Pointer size: 130 Bytes
  • Size of remote file: 27.7 kB
celeb_dataset/Johnny Depp/007_1bc0bcd6.jpg ADDED

Git LFS Details

  • SHA256: d199ea7b07c3d71cdfc263eb1837e2a47ad8613e7f11283d654910c4ff512ef9
  • Pointer size: 130 Bytes
  • Size of remote file: 49.5 kB
celeb_dataset/Johnny Depp/008_35d1be70.jpg ADDED

Git LFS Details

  • SHA256: bc176941977787598983011d760c160d4212e323756134ab9d0340ee75d84c18
  • Pointer size: 130 Bytes
  • Size of remote file: 30.6 kB
celeb_dataset/Johnny Depp/009_f4a38fec.jpg ADDED

Git LFS Details

  • SHA256: 684c2bfb5fbb9a95bb81966037938f659ae4cf3e209520614e305d1c4a93a802
  • Pointer size: 130 Bytes
  • Size of remote file: 30.1 kB
celeb_dataset/Johnny Depp/010_610eea60.jpg ADDED

Git LFS Details

  • SHA256: d9877538f588819f6604d95f2f801f53df908bdbe0980cf9f07241af7ba8738d
  • Pointer size: 130 Bytes
  • Size of remote file: 22.6 kB
celeb_dataset/Kate Winslet/006_eda1948f.jpg ADDED

Git LFS Details

  • SHA256: cfb6cb327f64ddf1b49fc25ac9c418308506ad68cd9e208248fcdcedb7517e80
  • Pointer size: 130 Bytes
  • Size of remote file: 34.2 kB
celeb_dataset/Kate Winslet/007_572cf58c.jpg ADDED

Git LFS Details

  • SHA256: 602bcf406ddc106a9b9d98e449ba205fa8c30e92fa7bb47fef4ee73445cb9015
  • Pointer size: 130 Bytes
  • Size of remote file: 41.1 kB
celeb_dataset/Kate Winslet/008_6c01eb52.jpg ADDED

Git LFS Details

  • SHA256: dc5be7cc4b2bbce47cdb8f69d6c6ab07d1c9c93d226b53117c8b3449e727ff8b
  • Pointer size: 130 Bytes
  • Size of remote file: 43 kB
celeb_dataset/Kate Winslet/009_07c15c37.jpg ADDED

Git LFS Details

  • SHA256: 085b880000089c02e920af873349c0b35acfc9e1ca838fde3d22185b5ad4243b
  • Pointer size: 130 Bytes
  • Size of remote file: 24.2 kB
celeb_dataset/Kate Winslet/010_6102c83d.jpg ADDED

Git LFS Details

  • SHA256: bb3db2d836f033b46abbcdd2605b9ac66d4a3cbca4d15ca7d81a4cee3f2c053f
  • Pointer size: 130 Bytes
  • Size of remote file: 32.6 kB
celeb_dataset/Leonardo DiCaprio/006_30010640.jpg ADDED

Git LFS Details

  • SHA256: 280e6280c0685b009e531718ffcc452788901a12c39b821eb0966a764d8292cc
  • Pointer size: 130 Bytes
  • Size of remote file: 28.9 kB
celeb_dataset/Leonardo DiCaprio/007_6ca7c622.jpg ADDED

Git LFS Details

  • SHA256: 1af31139adba1ba15a06d355bea38c342d94520b02e61d9c0ab20e1030e21317
  • Pointer size: 130 Bytes
  • Size of remote file: 29.6 kB
celeb_dataset/Leonardo DiCaprio/008_35daa4bc.jpg ADDED

Git LFS Details

  • SHA256: 91eecd38e7c29315d4c022b9ee6c04ab8f7d99e496de544880f77be5d519ab97
  • Pointer size: 130 Bytes
  • Size of remote file: 28 kB
celeb_dataset/Leonardo DiCaprio/009_b86449f6.jpg ADDED

Git LFS Details

  • SHA256: f154861c08a9b8f0e05aa8bbfc0851e2ad878d9a4a45bf54b620596498569f54
  • Pointer size: 130 Bytes
  • Size of remote file: 25.7 kB
celeb_dataset/Leonardo DiCaprio/010_2f9c83bc.jpg ADDED

Git LFS Details

  • SHA256: 24176ec35e39b34786ecb4c6210d429f94bc6aa3ffaaee20a5169b55a6a36fc1
  • Pointer size: 130 Bytes
  • Size of remote file: 29.1 kB
celeb_dataset/Megan Fox/006_4e33c943.jpg ADDED

Git LFS Details

  • SHA256: 3e790b52980fe1d9c73b5843a902bacbce59a68c43ae39a56bbb2c951eac3a4e
  • Pointer size: 130 Bytes
  • Size of remote file: 41.7 kB
celeb_dataset/Megan Fox/007_e3073d58.jpg ADDED

Git LFS Details

  • SHA256: 224df30be5949ef1000070e5f9dee029e3c81a7e9b6c564e613042e3a375866b
  • Pointer size: 130 Bytes
  • Size of remote file: 37.2 kB
celeb_dataset/Megan Fox/008_74bda018.jpg ADDED

Git LFS Details

  • SHA256: 3e7f63a184b815f04e2abc592705bda931fd00646c42cb698d13e1ab6076017e
  • Pointer size: 130 Bytes
  • Size of remote file: 40.2 kB
celeb_dataset/Megan Fox/009_3283c30e.jpg ADDED

Git LFS Details

  • SHA256: 7b093fe9d834860d8bc5db38825aa8009a85393d828328e1410a554acbb0a808
  • Pointer size: 129 Bytes
  • Size of remote file: 6.57 kB
celeb_dataset/Megan Fox/010_0479e335.jpg ADDED

Git LFS Details

  • SHA256: def801f94093cc2dd629aac19fe796e2ead81738df7e781b21457dd6bc4f98d9
  • Pointer size: 130 Bytes
  • Size of remote file: 27.4 kB
celeb_dataset/Natalie Portman/006_51ad8fdd.jpg ADDED

Git LFS Details

  • SHA256: 4548a3e8c537de2ec48de70dc94df39037af5c075eb23c072120ea72824ea553
  • Pointer size: 130 Bytes
  • Size of remote file: 68.4 kB
celeb_dataset/Natalie Portman/007_b82eb947.jpg ADDED

Git LFS Details

  • SHA256: a380935bd54ba2fcdfab7850cc47e2d63516cbb6ed884d10c8ad45a32e442e2d
  • Pointer size: 130 Bytes
  • Size of remote file: 42.9 kB
celeb_dataset/Natalie Portman/008_8fc20495.jpg ADDED

Git LFS Details

  • SHA256: 5891d516aced4772355f11e19b44c7bae2eac92222d6b55cf2b0f374a9363cc0
  • Pointer size: 129 Bytes
  • Size of remote file: 5.32 kB
celeb_dataset/Natalie Portman/009_3300e98f.jpg ADDED

Git LFS Details

  • SHA256: 5973e98f33e6d0cd88b77ed1bfdb0631fd005db4028a2ddf6a5ccb75f8c5dafe
  • Pointer size: 130 Bytes
  • Size of remote file: 44.8 kB