Skip to content

Commit

Permalink
bug fix: exclude scores if rot and eval straight (#1639)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixdittrich92 authored Jun 12, 2024
1 parent 3f8bd01 commit 0f1f7f6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions references/detection/train_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ def evaluate(model, val_loader, batch_transforms, val_metric, amp=False):
for target, loc_pred in zip(targets, loc_preds):
for boxes_gt, boxes_pred in zip(target.values(), loc_pred.values()):
if args.rotation and args.eval_straight:
# Convert pred to boxes [xmin, ymin, xmax, ymax] N, 4, 2 --> N, 4
boxes_pred = np.concatenate((boxes_pred.min(axis=1), boxes_pred.max(axis=1)), axis=-1)
# Convert pred to boxes [xmin, ymin, xmax, ymax] N, 5, 2 (with scores) --> N, 4
boxes_pred = np.concatenate((boxes_pred[:, :4].min(axis=1), boxes_pred[:, :4].max(axis=1)), axis=-1)
val_metric.update(gts=boxes_gt, preds=boxes_pred[:, :4])

val_loss += out["loss"].item()
Expand Down
4 changes: 2 additions & 2 deletions references/detection/train_tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def evaluate(model, val_loader, batch_transforms, val_metric):
for target, loc_pred in zip(targets, loc_preds):
for boxes_gt, boxes_pred in zip(target.values(), loc_pred.values()):
if args.rotation and args.eval_straight:
# Convert pred to boxes [xmin, ymin, xmax, ymax] N, 4, 2 --> N, 4
boxes_pred = np.concatenate((boxes_pred.min(axis=1), boxes_pred.max(axis=1)), axis=-1)
# Convert pred to boxes [xmin, ymin, xmax, ymax] N, 5, 2 (with scores) --> N, 4
boxes_pred = np.concatenate((boxes_pred[:, :4].min(axis=1), boxes_pred[:, :4].max(axis=1)), axis=-1)
val_metric.update(gts=boxes_gt, preds=boxes_pred[:, :4])

val_loss += out["loss"].numpy()
Expand Down

0 comments on commit 0f1f7f6

Please sign in to comment.