1. 程式人生 > >執行SSD-Tensorflow的eval_ssd_network.py

執行SSD-Tensorflow的eval_ssd_network.py

最近在學SSD-Tensorflow,在測試集上跑eval_ssd_network.py遇到問題:

報錯:TypeError: can not convert a tuple into a tensor or operation:

我的命令列是:

python eval_ssd_network.py 
--dataset_dir=tfrecords\test  
--dataset_split_name=test 
--checkpoint_path=checkpoints\ssd_300_vgg.ckpt 
--dataset_name=pascalvoc_2007 
--model_name=ssd_300_vgg

解決方式:將321和341行的:

eval_op=list(names_to_updates.values())

改為:

eval_op=flatten(list(names_to_updates.values())),

同時別忘記新增:

from compiler.ast import flatten

若提示python3捨棄了flatten函式,則需要自己寫一個:

def flatten(x): 
    result = [] 
    for el in x: 
        if isinstance(el, tuple): 
            result.extend(flatten(el))
        else: 
             result.append(el) 
    return result

親測可行,可以在eval_ssd_network.py上愉快地檢驗SSD模型啦 

參考: https://github.com/balancap/SSD-Tensorflow/issues/154