zoukankan      html  css  js  c++  java
  • Python Script --- eval_single_video_SR and plot the curve

    import numpy as np
    import pdb

    resScore = np.loadtxt("/home/wangxiao/Downloads/pysot/experiments/siamrpn_r50_l234_dwxcorr_otb/results/response_score/responseScore.txt")

    res = np.loadtxt("/home/wangxiao/Downloads/pysot/experiments/siamrpn_r50_l234_dwxcorr_otb/results/siamrpn_resnet50_dwxcorr_otb/Assian_video_Z03_done.txt")
    gt_rects = np.loadtxt("/home/wangxiao/Downloads/pysot/experiments/siamrpn_r50_l234_dwxcorr_otb/results/siamrpn_resnet50_dwxcorr_otb/groundtruth.txt")

    # pdb.set_trace()

    def overlap_ratio(rect1, rect2):

    if rect1.ndim==1:
    rect1 = rect1[None,:]
    if rect2.ndim==1:
    rect2 = rect2[None,:]

    left = np.maximum(rect1[:,0], rect2[:,0])
    right = np.minimum(rect1[:,0]+rect1[:,2], rect2[:,0]+rect2[:,2])
    top = np.maximum(rect1[:,1], rect2[:,1])
    bottom = np.minimum(rect1[:,1]+rect1[:,3], rect2[:,1]+rect2[:,3])

    intersect = np.maximum(0,right - left) * np.maximum(0,bottom - top)
    union = rect1[:,2]*rect1[:,3] + rect2[:,2]*rect2[:,3] - intersect
    iou = np.clip(intersect / union, 0, 1)
    return iou

    def compute_success_overlap(gt_bb, result_bb):

    thresholds_overlap = np.arange(0, 1.05, 0.05)
    n_frame = len(gt_bb)
    success = np.zeros(len(thresholds_overlap))
    iou = np.zeros(n_frame)
    for i in range(n_frame):
    iou[i] = overlap_ratio(np.array(gt_bb[i]), np.array(result_bb[i]))
    for i in range(len(thresholds_overlap)):
    success[i] = sum(iou > thresholds_overlap[i]) / n_frame
    # return success
    return iou


    success_overlap = compute_success_overlap(gt_rects, res)

    import matplotlib.pyplot as plt
    import matplotlib.font_manager as fm

    x_data = list(range(gt_rects.shape[0]))
    y_data = success_overlap
    y_data2 = resScore

    # pdb.set_trace()

    ln1, = plt.plot(x_data,y_data,color='red',linewidth=2.0,linestyle='-')
    ln2, = plt.plot(x_data,y_data2,color='blue',linewidth=2.0,linestyle='-')

    plt.title("xxxx")
    plt.legend(handles=[ln1,ln2],labels=['IoU Value','Response Score'])

    ax = plt.gca()
    ax.spines['right'].set_color('none')
    ax.spines['top'].set_color('none')
    plt.show()

    Stay Hungry,Stay Foolish ...
  • 相关阅读:
    eclipse/myeclipse介绍
    HDU 5802 Windows 10
    LaTeX test
    数据结构2 静态区间第K大/第K小
    数据结构1 「在线段树中查询一个区间的复杂度为 $O(log N)$」的证明
    HDU 1007 Quoit Design
    HDU 5761 Rower Bo
    hihocoder #1341 Constraint Checker
    HDU #5733 tetrahedron
    hihocoder #1327
  • 原文地址:https://www.cnblogs.com/wangxiaocvpr/p/14333585.html
Copyright © 2011-2022 走看看