tensorflow利用預訓練模型進行目標檢測(四):檢測中的精度問題以及evaluation
一、tensorflow提供的evaluation
Inference and evaluation on the Open Images dataset:https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/oid_inference_and_evaluation.md
該連結中詳細介紹瞭如何針對Open Images dataset資料集進行inference和evaluation,按照此教程,在models/research目錄下新建oid資料夾,並將資料集以及驗證集下載並放在此資料夾下。後續可能不會用到,待刪除。
tensorflow提供的官方detection demo可參考:https://github.com/tensorflow/models/blob/master/research/object_detection/object_detection_tutorial.ipynb
但是後來發現在~/rdshare/detection/detection/py的指令碼中,檢測結果中有類別,目標框的位置等,可據此計算map,recall等,所以沒有繼續根據上邊的連結繼續做。
二、自主計算
在~/rdshare/detection/detection/py指令碼中,通過 boxes = detection_graph.get_tensor_by_name('
結果中應該是兩個物體的座標。
然後參考https://blog.csdn.net/qq_17550379/article/details/79875784 中的程式碼,可以計算map
def voc_ap(rec, prec, use_07_metric=False): if use_07_metric: # 11 point metric ap = 0. for t in np.arange(0., 1.1, 0.1):View Codeif np.sum(rec >= t) == 0: p = 0 else: p = np.max(prec[rec >= t]) ap = ap + p / 11. else: mrec = np.concatenate(([0.], rec, [1.])) mpre = np.concatenate(([0.], prec, [0.])) for i in range(mpre.size - 1, 0, -1): mpre[i - 1] = np.maximum(mpre[i - 1], mpre[i]) i = np.where(mrec[1:] != mrec[:-1])[0] ap = np.sum((mrec[i + 1] - mrec[i]) * mpre[i + 1]) return ap
另外可參考的連結
https://blog.csdn.net/ziliwangmoe/article/details/81415943
https://zhuanlan.zhihu.com/p/37910324
本論文中可考慮不用maP,只計算目標是否出現等方式,或者用yolo做ground truth。