Skip to content

Commit

Permalink
πŸ› [Fix] validation_step
Browse files Browse the repository at this point in the history
Changed the self.metric() call to self.metric.update().
Removed the logging of per batch metric values.
Filtered out the dummy boxes from the per image "target" tensors before appending them to the metrics accumulator.

fixes #133
  • Loading branch information
Adamusen authored Dec 9, 2024
1 parent b96c8ea commit 2f28022
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions yolo/tools/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,8 @@ def validation_step(self, batch, batch_idx):
batch_size, images, targets, rev_tensor, img_paths = batch
H, W = images.shape[2:]
predicts = self.post_process(self.ema(images), image_size=[W, H])
batch_metrics = self.metric(
[to_metrics_format(predict) for predict in predicts], [to_metrics_format(target) for target in targets]
)

self.log_dict(
{
"map": batch_metrics["map"],
"map_50": batch_metrics["map_50"],
},
batch_size=batch_size,
)
self.metric.update([to_metrics_format(predict) for predict in predicts],
[to_metrics_format(target[target.sum(1) > 0]) for target in targets])
return predicts

def on_validation_epoch_end(self):
Expand Down

0 comments on commit 2f28022

Please sign in to comment.