Pallavi Bhoj commited on
Commit
6bdc76e
·
1 Parent(s): 13ca877

Update face_recognition.py

Browse files
app/Hackathon_setup/face_recognition.py CHANGED
@@ -113,4 +113,16 @@ def get_face_class(img1):
113
  ##YOUR CODE HERE, return face class here
114
  ##Hint: you need a classifier finetuned for your classes, it takes o/p of siamese as i/p to it
115
  ##Better Hint: Siamese experiment is covered in one of the labs
116
- return "YET TO BE CODED"
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  ##YOUR CODE HERE, return face class here
114
  ##Hint: you need a classifier finetuned for your classes, it takes o/p of siamese as i/p to it
115
  ##Better Hint: Siamese experiment is covered in one of the labs
116
+ face1 = trnscm(det_img1).unsqueeze(0)
117
+
118
+ feature_net = SiameseNetwork().to(device)
119
+ model = torch.load(current_path + '/siamese_model.t7', map_location=device) ##
120
+ feature_net.load_state_dict(model['net_dict'])
121
+ feature_net.eval()
122
+
123
+ output1, output2 = feature_net(face1.to(device), face1.to(device))
124
+ output1 = output1.detach().numpy()
125
+
126
+ clf_model = load(current_path + '/clf_model.joblib')
127
+ label = clf_model.predict(output1)
128
+ return label