main.py中的测试函数
import os.path as osp
import pickle
import model
import weights
import test
def get_tf_implementation(weights_path, all_layer_outs=False):
print("Making Structure")
tf_model = model.make_deng_tf_test(verbose=True, all_layer_outs=all_layer_outs)
print("Loading Weights")
tf_model = weights.load_weights(tf_model, weights_path, verbose=True)
return tf_model
def get_test_data(cache_file):
print("Loading Test Data")
if osp.exists(cache_file):
with open(cache_file, 'rb') as fid:
roidb = pickle.load(fid)
print('data is loaded from {}'.format(cache_file))
print(f"Number of Images to test: {len(roidb)}")
return roidb
def get_weighted_tf_implementation(weights_path, all_layer_outs=False):
tf_model = get_tf_implementation(weights_path, all_layer_outs)
model.show_model_info(tf_model)
return tf_model
def test_tf_implementation(cache_file, weights_path, all_layer_outs=False):
# Get Weighted Model
tf_model = get_weighted_tf_implementation(weights_path, all_layer_outs)
# Load Cached Test Data
roidb = get_test_data(cache_file)
# Test Network
results = test.test_net(tf_model, roidb)
return results
if name == "__main__ 代码段:
if __name__ == "__main__":
results = test_tf_implementation(cache_file="roidb_test_19_smol.pkl", weights_path="rgbd_det_iter_40000.h5")
Terminal运行一切正常,给cache-file和weights-path赋值,然后正常执行test_tf_implementation.
不知道问题出在哪里
错误提示:
Using TensorFlow backend.
EE
ERROR: main.get_test_data
Traceback (most recent call last):
File "/Users/xijiejiao/anaconda2/envs/python3/lib/python3.6/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
TypeError: get_test_data() missing 1 required positional argument: 'cache_file'
-------------------- >> begin captured logging << --------------------
tensorflow: Level 1: Registering FakeQuantWithMinMaxArgs () in gradient.
tensorflow: Level 1: Registering FakeQuantWithMinMaxVars () in gradient.
Error
Traceback (most recent call last):
File "/Users/xijiejiao/anaconda2/envs/python3/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
yield
File "/Users/xijiejiao/anaconda2/envs/python3/lib/python3.6/unittest/case.py", line 605, in run
testMethod()
File "/Users/xijiejiao/anaconda2/envs/python3/lib/python3.6/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
Exception: get_test_data() missing 1 required positional argument: 'cache_file'
-------------------- >> begin captured logging << --------------------
tensorflow: Level 1: Registering FakeQuantWithMinMaxArgs () in gradient.
tensorflow: Level 1: Registering FakeQuantWithMinMaxVars () in gradient.
Error
Traceback (most recent call last):
File "/Users/xijiejiao/anaconda2/envs/python3/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
yield
File "/Users/xijiejiao/anaconda2/envs/python3/lib/python3.6/unittest/case.py", line 605, in run
testMethod()
File "/Users/xijiejiao/anaconda2/envs/python3/lib/python3.6/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
TypeError: test_tf_implementation() missing 2 required positional arguments: 'cache_file' and 'weights_path'
tensorflow: Level 1: Registering NcclAllReduce () in gradient.
tensorflow: Level 1: Registering NcclReduce () in gradient.
tensorflow: Level 1: Registering NcclBroadcast () in gradient.
ERROR: main.test_tf_implementation
Traceback (most recent call last):
File "/Users/xijiejiao/anaconda2/envs/python3/lib/python3.6/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
TypeError: test_tf_implementation() missing 2 required positional arguments: 'cache_file' and 'weights_path'
Ran 2 tests in 0.020s
FAILED (errors=2)
Process finished with exit code 1
Assertion failed
Assertion failed
Assertion failed
Assertion failed