Skip to content

Commit 2118854

Browse files
author
Shashank Tyagi
committed
results
1 parent d369632 commit 2118854

File tree

5 files changed

+44
-3
lines changed

5 files changed

+44
-3
lines changed

main_prediction.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import tensorflow as tf
22
import os
3-
from model import *
3+
from model_prediction import *
44

55

66

model_prediction.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def network(self,inputs,reuse=False):
206206
conv_all = slim.conv2d(concat_feat, 192, [1,1], 1, padding= 'VALID', scope='conv_all')
207207

208208
shape = int(np.prod(conv_all.get_shape()[1:]))
209-
fc_full = slim.fully_connected(tf.reshape(conv_all, [-1, shape]), 3072, scope='fc_full')
209+
fc_full = slim.fully_connected(tf.reshape(tf.transpose(conv_all, [0,3,1,2]), [-1, shape]), 3072, scope='fc_full')
210210

211211
fc_detection = slim.fully_connected(fc_full, 512, scope='fc_detection1')
212212
fc_landmarks = slim.fully_connected(fc_full, 512, scope='fc_landmarks1')
@@ -239,7 +239,6 @@ def predict(self):
239239
print count
240240
batch_imgs, batch_labels, batch_landmarks, batch_visibility, batch_pose, batch_gender = self.sess.run([self.images,self.labels,self.land, self.vis, self.po, self.gen])
241241
batch_imgs = (batch_imgs - 127.5) / 128.0
242-
# input_feed={self.X: batch_imgs, self.detection: batch_labels, self.landmarks: batch_landmarks, self.visibility: batch_visibility, self.pose: batch_pose, self.gender: np.squeeze(batch_gender)}
243242

244243
net_preds = self.sess.run(self.net_output, feed_dict={self.X: batch_imgs})
245244
result.append(np.concatenate(net_preds, axis=1))

results_analysis.py

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import numpy as np
2+
np.set_printoptions(linewidth=200)
3+
from sklearn.metrics import roc_curve, precision_recall_curve
4+
import matplotlib.pyplot as plt
5+
6+
7+
def softmax(x):
8+
return np.exp(x) / np.sum(np.exp(x), axis=1, keepdims=True)
9+
10+
11+
pred = np.load('test_results.npy')
12+
truth = np.load('truth.npy')
13+
14+
print pred.shape, truth.shape
15+
16+
17+
prob = softmax(pred[:,:2])
18+
# print prob.sum(axis = 1)
19+
print pred
20+
21+
22+
print 'Detection accuracy: ', np.sum(np.argmax(prob, axis = 1) == truth[:,0].astype(np.bool))/float(prob.shape[0])
23+
24+
print 'Gender accuracy: ', np.sum(np.argmax(softmax(pred[:,68:70]), axis = 1) == truth[:,-1].astype(np.bool))/float(prob.shape[0])
25+
26+
# detection
27+
fpr, tpr, thresholds = roc_curve(truth[:,0], prob[:,1])
28+
precision, recall, th = precision_recall_curve(truth[:,0], prob[:,1])
29+
30+
# plt.plot(recall, precision)
31+
# plt.xlabel('Recall')
32+
# plt.ylabel('Precision')
33+
# # plt.savefig('detection_pr_re.eps', format='eps', dpi=1000)
34+
# plt.show()
35+
36+
37+
# plt.plot(fpr, tpr)
38+
# plt.xlabel('False positive rate')
39+
# plt.ylabel('True positive rate')
40+
# # plt.savefig('detection_roc.eps', format='eps', dpi=1000)
41+
# plt.show()
42+

test_results.npy

23.3 MB
Binary file not shown.

truth.npy

45.3 MB
Binary file not shown.

0 commit comments

Comments
 (0)