-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
58 lines (39 loc) · 1.04 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# coding: utf-8
# In[1]:
from Res import *
from ResNeXtc import *
from tfdata import *
import numpy as np
# In[2]:
import tensorflow as tf
# In[3]:
import cv2
import time
# In[4]:
# Dataset path
train_tfrecords = 'train.tfrecords'
test_tfrecords = 'test.tfrecords'
batch_size = 20
# In[5]:
img, label = input_pipeline(test_tfrecords, batch_size, is_shuffle=False, is_train=False)
with tf.variable_scope('model_definition'):
prediction = ResNeXt50(img, is_training=False)
accuracy = accuracy_of_batch(prediction, label)
# In[6]:
saver = tf.train.Saver()
# In[7]:
with tf.Session() as sess:
saver.restore(sess, 'checkpoint/my-model.ckpt-42000')
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(sess=sess, coord=coord)
acc2=0
start = time.clock()
for i in range(21):
acc = sess.run(accuracy)
print(acc)
acc2+=acc
elapsed = (time.clock() - start)
print("Time used:", elapsed)
print('OA={:.2f}%'.format(acc2*100/21))
coord.request_stop()
coord.join(threads)