gil.simas@sea.ai commited on
Commit
48a1df0
1 Parent(s): 137b0e5

add examples

Browse files
box_metrics.py CHANGED
@@ -169,8 +169,6 @@ class box_metrics(evaluate.Metric):
169
  if bep < 0:
170
  raise ValueError("BEP should be greater than 0, pls contact code maintainer")
171
 
172
- ious = np.append(ious, iou)
173
- beps = np.append(beps, bep)
174
 
175
  t_xc = (p_box[0].item()+p_box[2].item())/2
176
  p_xc = (t_box[0].item()+t_box[2].item())/2
@@ -181,6 +179,12 @@ class box_metrics(evaluate.Metric):
181
  t_h = t_box[3].item()-t_box[1].item()
182
  p_h = p_box[3].item()-p_box[1].item()
183
 
 
 
 
 
 
 
184
  e_widths = np.append(e_widths, p_w-t_w)
185
  e_heights = np.append(e_heights, p_h-t_h)
186
  e_bottom_x = np.append(e_bottom_x, p_xc-t_xc)
@@ -192,8 +196,8 @@ class box_metrics(evaluate.Metric):
192
  e_n_bottom_y = np.append(e_n_bottom_y, (p_yc-t_yc)/t_h)
193
 
194
  output[sequence][model] = {
195
- "iou_mean": np.mean(ious),
196
- "bep_mean": np.mean(beps),
197
  "e_bottom_x_mean": np.mean(e_bottom_x),
198
  "e_bottom_y_mean": np.mean(e_bottom_y),
199
  "e_width_mean": np.mean(e_widths),
@@ -214,7 +218,7 @@ class box_metrics(evaluate.Metric):
214
  }
215
 
216
  return output
217
-
218
  @staticmethod
219
  def summarize(result):
220
  """Summarize the results by model insteaf by sequence: model"""
 
169
  if bep < 0:
170
  raise ValueError("BEP should be greater than 0, pls contact code maintainer")
171
 
 
 
172
 
173
  t_xc = (p_box[0].item()+p_box[2].item())/2
174
  p_xc = (t_box[0].item()+t_box[2].item())/2
 
179
  t_h = t_box[3].item()-t_box[1].item()
180
  p_h = p_box[3].item()-p_box[1].item()
181
 
182
+ if t_h < 10:
183
+ continue
184
+
185
+ ious = np.append(ious, iou)
186
+ beps = np.append(beps, bep)
187
+
188
  e_widths = np.append(e_widths, p_w-t_w)
189
  e_heights = np.append(e_heights, p_h-t_h)
190
  e_bottom_x = np.append(e_bottom_x, p_xc-t_xc)
 
196
  e_n_bottom_y = np.append(e_n_bottom_y, (p_yc-t_yc)/t_h)
197
 
198
  output[sequence][model] = {
199
+ "iou": np.mean(ious),
200
+ "bep": np.mean(beps),
201
  "e_bottom_x_mean": np.mean(e_bottom_x),
202
  "e_bottom_y_mean": np.mean(e_bottom_y),
203
  "e_width_mean": np.mean(e_widths),
 
218
  }
219
 
220
  return output
221
+
222
  @staticmethod
223
  def summarize(result):
224
  """Summarize the results by model insteaf by sequence: model"""
unit_test.py → examples/batch.py RENAMED
File without changes
test.py → examples/payload.py RENAMED
@@ -16,9 +16,9 @@ dataset_view = fo.load_dataset(dataset_name).match_tags(tags) if tags else fo.lo
16
  sequences = dataset_view.distinct("sequence")
17
 
18
  # bbox_metric = BoxMetrics(max_iou=0.01)
19
- bbox_metric = evaluate.load("box_metrics.py")
20
 
21
- for sequence in tqdm(sequences[:2]):
22
  try:
23
  payload = fo_to_payload(dataset = dataset_name,
24
  gt_field = det_gt_field,
 
16
  sequences = dataset_view.distinct("sequence")
17
 
18
  # bbox_metric = BoxMetrics(max_iou=0.01)
19
+ bbox_metric = evaluate.load("SEA-AI/box_metrics")
20
 
21
+ for sequence in tqdm(sequences):
22
  try:
23
  payload = fo_to_payload(dataset = dataset_name,
24
  gt_field = det_gt_field,
utils.py CHANGED
@@ -41,7 +41,7 @@ def bbox_bep(box1, box2, xywh=False, eps=1e-7, bep1 = True):
41
 
42
  return bep
43
 
44
- def bbox_iou(box1, box2, xywh=True, GIoU=False, DIoU=False, CIoU=False, eps=1e-7):
45
  """
46
  Calculates IoU, GIoU, DIoU, or CIoU between two boxes, supporting xywh/xyxy formats.
47
 
 
41
 
42
  return bep
43
 
44
+ def bbox_iou(box1, box2, xywh=False, GIoU=False, DIoU=False, CIoU=False, eps=1e-7):
45
  """
46
  Calculates IoU, GIoU, DIoU, or CIoU between two boxes, supporting xywh/xyxy formats.
47