jacklangerman commited on
Commit
0614af0
1 Parent(s): de91949

validate edges

Browse files
Files changed (1) hide show
  1. hoho/wed.py +3 -3
hoho/wed.py CHANGED
@@ -79,7 +79,7 @@ def compute_WED(pd_vertices, pd_edges, gt_vertices, gt_edges, cv_ins=-1/2, cv_de
79
  insertion_costs = cv_ins * len(unmatched_gt_indices)
80
 
81
  # Step 5: Edge Deletion and Insertion
82
- updated_pd_edges = [(col_ind[np.where(row_ind == edge[0])[0][0]], col_ind[np.where(row_ind == edge[1])[0][0]]) for edge in pd_edges if edge[0] in row_ind and edge[1] in row_ind]
83
  pd_edges_set = set(map(tuple, [set(edge) for edge in updated_pd_edges]))
84
  gt_edges_set = set(map(tuple, [set(edge) for edge in gt_edges]))
85
 
@@ -88,12 +88,12 @@ def compute_WED(pd_vertices, pd_edges, gt_vertices, gt_edges, cv_ins=-1/2, cv_de
88
  edges_to_delete = pd_edges_set - gt_edges_set
89
 
90
  vert_tf = [np.where(col_ind == v)[0][0] if v in col_ind else 0 for v in range(len(gt_vertices))]
91
- deletion_edge_costs = ce * sum(np.linalg.norm(pd_vertices[vert_tf[edge[0]]] - pd_vertices[vert_tf[edge[1]]]) for edge in edges_to_delete)
92
 
93
 
94
  # Insert missing edges from ground truth
95
  edges_to_insert = gt_edges_set - pd_edges_set
96
- insertion_edge_costs = ce * sum(np.linalg.norm(gt_vertices[edge[0]] - gt_vertices[edge[1]]) for edge in edges_to_insert)
97
 
98
  # Step 5: Calculation of WED
99
  WED = translation_costs + deletion_costs + insertion_costs + deletion_edge_costs + insertion_edge_costs
 
79
  insertion_costs = cv_ins * len(unmatched_gt_indices)
80
 
81
  # Step 5: Edge Deletion and Insertion
82
+ updated_pd_edges = [(col_ind[np.where(row_ind == edge[0])[0][0]], col_ind[np.where(row_ind == edge[1])[0][0]]) for edge in pd_edges if len(edge)==2 and edge[0] in row_ind and edge[1] in row_ind]
83
  pd_edges_set = set(map(tuple, [set(edge) for edge in updated_pd_edges]))
84
  gt_edges_set = set(map(tuple, [set(edge) for edge in gt_edges]))
85
 
 
88
  edges_to_delete = pd_edges_set - gt_edges_set
89
 
90
  vert_tf = [np.where(col_ind == v)[0][0] if v in col_ind else 0 for v in range(len(gt_vertices))]
91
+ deletion_edge_costs = ce * sum(np.linalg.norm(pd_vertices[vert_tf[edge[0]]] - pd_vertices[vert_tf[edge[1]]]) for edge in edges_to_delete if len(edge) == 2)
92
 
93
 
94
  # Insert missing edges from ground truth
95
  edges_to_insert = gt_edges_set - pd_edges_set
96
+ insertion_edge_costs = ce * sum(np.linalg.norm(gt_vertices[edge[0]] - gt_vertices[edge[1]]) for edge in edges_to_insert if len(edge) == 2)
97
 
98
  # Step 5: Calculation of WED
99
  WED = translation_costs + deletion_costs + insertion_costs + deletion_edge_costs + insertion_edge_costs