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('detection_boxes:0') 可獲得目標框的坐標。print之后結果如下

結果中應該是兩個物體的坐標。

然后參考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):
            if 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
View Code

另外可參考的鏈接

https://blog.csdn.net/ziliwangmoe/article/details/81415943

https://zhuanlan.zhihu.com/p/37910324

本論文中可考慮不用maP,只計算目標是否出現等方式,或者用yolo做ground truth。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM