From b792e276d0f547f69e5c1fd8edf7c4e0f5989a0e Mon Sep 17 00:00:00 2001 From: wxywb Date: Wed, 14 Sep 2022 10:39:58 +0800 Subject: [PATCH] revise the scoring method. Signed-off-by: wxywb --- tn.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/tn.py b/tn.py index a5e428f..b0aacf0 100644 --- a/tn.py +++ b/tn.py @@ -64,6 +64,7 @@ def tn(sims: np.ndarray, list of temporal aligned copied segments, [query_min, ref_min, query_max, ref_max] for each segment """ infringe_box_list = [] + infringe_score_list = [] path = 0 node_pair2id = {} node_pair2id[(-1, -1)] = 0 @@ -177,8 +178,9 @@ def tn(sims: np.ndarray, if ave_length > 0 and score / ave_length > min_sim and min(refer_max - refer_min, query_max - query_min) > min_length and ious.max() < max_iou: infringe_box_list.append([int(query_min), int(refer_min), int(query_max), int(refer_max)]) + infringe_score_list.append(score / ave_length) path += 1 - return infringe_box_list + return infringe_box_list, infringe_score_list @register(output_schema=['vec']) @@ -199,16 +201,7 @@ class TemporalNetwork(NNOperator): def __call__(self, src_video_vec: 'ndarray', dst_video_vec: 'ndarray') -> float: sim_map = np.dot(src_video_vec, dst_video_vec.T) - res = tn(sim_map, self._tn_max_step, self._tn_top_k, self._max_path, self._min_sim, self._min_length, self._max_iou) - det_scores = [] - - for duplicate_det in res: - x1, y1, x2, y2 = duplicate_det - e1, e2 = x2 - x1, y2 - y1 - e = max(e1,e2) - crop = sim_map[x1:x2, y1:y2] - standard_crop = cv2.resize(crop, dsize=(e, e), interpolation=cv2.INTER_CUBIC) - diagonal_edge = standard_crop.diagonal() - det_scores.append(diagonal_edge.mean()) - return res, det_scores + ranges, scores = tn(sim_map, self._tn_max_step, self._tn_top_k, self._max_path, self._min_sim, self._min_length, self._max_iou) + + return ranges, scores