Skip to content

Commit 8e97a75

Browse files
author
Ubuntu
committed
Evaluate working with TensorBox.eval().
1 parent a8158f4 commit 8e97a75

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

evaluate.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
import tensorflow as tf
21
import os
32
import json
43
import subprocess
5-
from scipy.misc import imread, imresize
6-
from scipy import misc
74

85
from model import TensorBox
9-
from utils.annolist import AnnotationLib as al
10-
from utils.train_utils import add_rectangles, rescale_boxes
116

12-
import cv2
137
import argparse
148

159
def main():
@@ -33,7 +27,12 @@ def main():
3327
true_boxes = '%s.gt_%s%s' % (args.weights, expname, os.path.basename(args.test_boxes))
3428

3529
tensorbox = TensorBox(H)
36-
pred_annolist, true_annolist = tensorbox.eval(weights, test_boxes, min_conf, tau, show_supressed, expname)
30+
pred_annolist, true_annolist = tensorbox.eval(args.weights,
31+
args.test_boxes,
32+
args.min_conf,
33+
args.tau,
34+
args.show_suppressed,
35+
expname)
3736
pred_annolist.save(pred_boxes)
3837
true_annolist.save(true_boxes)
3938

@@ -43,7 +42,7 @@ def main():
4342
rpc_output = subprocess.check_output(rpc_cmd, shell=True)
4443
print(rpc_output)
4544
txt_file = [line for line in rpc_output.split('\n') if line.strip()][-1]
46-
output_png = '%s/results.png' % get_image_dir(args)
45+
output_png = '%s/results.png' % tensorbox.get_image_dir(args.weights, expname, args.test_boxes)
4746
plot_cmd = './utils/annolist/plotSimple.py %s --output %s' % (txt_file, output_png)
4847
print('$ %s' % plot_cmd)
4948
plot_output = subprocess.check_output(plot_cmd, shell=True)

model.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
import tensorflow.contrib.slim as slim
44
import random
55
import time
6+
import subprocess
67
import string
78
import os
89
import threading
9-
from scipy import misc
1010
import tensorflow as tf
1111
import numpy as np
12+
from scipy import misc
13+
from scipy.misc import imread, imresize
1214
from distutils.version import LooseVersion
1315
if LooseVersion(tf.__version__) >= LooseVersion('1.0'):
1416
rnn_cell = tf.contrib.rnn
@@ -24,6 +26,8 @@
2426
np.random.seed(0)
2527

2628
from utils import train_utils, googlenet_load, tf_concat
29+
from utils.annolist import AnnotationLib as al
30+
from utils.train_utils import add_rectangles, rescale_boxes
2731

2832
@ops.RegisterGradient("Hungarian")
2933
def _hungarian_grad(op, *args):
@@ -536,7 +540,7 @@ def get_image_dir(self, weights, expname, test_boxes):
536540
image_dir = '%s/images_%s_%d%s' % (os.path.dirname(weights), os.path.basename(test_boxes)[:-5], weights_iteration, expname)
537541
return image_dir
538542

539-
def eval(self, weights, test_boxes, min_conf, tau, show_supressed, expname):
543+
def eval(self, weights, test_boxes, min_conf, tau, show_suppressed, expname):
540544
self.H["grid_width"] = self.H["image_width"] / self.H["region_size"]
541545
self.H["grid_height"] = self.H["image_height"] / self.H["region_size"]
542546
x_in = tf.placeholder(tf.float32, name='x_in', shape=[self.H['image_height'], self.H['image_width'], 3])
@@ -548,7 +552,7 @@ def eval(self, weights, test_boxes, min_conf, tau, show_supressed, expname):
548552
if self.H['reregress']:
549553
pred_boxes = pred_boxes + pred_boxes_deltas
550554
else:
551-
pred_boxes, pred_logits, pred_confidences = tensorbox.build_forward(tf.expand_dims(x_in, 0), 'test', reuse=None)
555+
pred_boxes, pred_logits, pred_confidences = self.build_forward(tf.expand_dims(x_in, 0), 'test', reuse=None)
552556
saver = tf.train.Saver()
553557
with tf.Session() as sess:
554558
sess.run(tf.global_variables_initializer())

0 commit comments

Comments
 (0)