Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.

Commit 981a549

Browse files
Jimmy Kimfacebook-github-bot
authored andcommitted
meter usage logging implementation
Summary: Ensures that all meter classes (e.g. precision, accuracy, recall) inheriting from the base class classy_vision/meters/classy_meter.py have their usage logged. This is done through the log_class_usage function defined in classy_vision/generic/util.py. Reviewed By: kazhang Differential Revision: D25680979 fbshipit-source-id: 3b19dda5ff5f5e0c6122b495bf8c600fff681db3
1 parent ac1f352 commit 981a549

File tree

5 files changed

+11
-0
lines changed

5 files changed

+11
-0
lines changed

classy_vision/meters/accuracy_meter.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def __init__(self, topk):
2525
args:
2626
topk: list of int `k` values.
2727
"""
28+
super().__init__()
29+
2830
assert isinstance(topk, list), "topk must be a list"
2931
assert len(topk) > 0, "topk list should have at least one element"
3032
assert [is_pos_int(x) for x in topk], "each value in topk must be >= 1"

classy_vision/meters/classy_meter.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from typing import Any, Dict, Tuple
88

99
import torch
10+
from classy_vision.generic.util import log_class_usage
1011

1112

1213
class ClassyMeter:
@@ -16,6 +17,9 @@ class ClassyMeter:
1617
This can include meters like Accuracy, Precision and Recall, etc.
1718
"""
1819

20+
def __init__(self):
21+
log_class_usage("Meter", self.__class__)
22+
1923
@classmethod
2024
def from_config(cls, config: Dict[str, Any]) -> "ClassyMeter":
2125
"""Instantiates a ClassyMeter using a configuration.

classy_vision/meters/precision_meter.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def __init__(self, topk):
2626
args:
2727
topk: list of int `k` values.
2828
"""
29+
super().__init__()
30+
2931
assert isinstance(topk, list), "topk must be a list"
3032
assert len(topk) > 0, "topk list should have at least one element"
3133
assert [is_pos_int(x) for x in topk], "each value in topk must be >= 1"

classy_vision/meters/recall_meter.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def __init__(self, topk, target_is_one_hot=True, num_classes=None):
2525
args:
2626
topk: list of int `k` values.
2727
"""
28+
super().__init__()
29+
2830
assert isinstance(topk, list), "topk must be a list"
2931
assert len(topk) > 0, "topk list should have at least one element"
3032
assert [is_pos_int(x) for x in topk], "each value in topk must be >= 1"

classy_vision/meters/video_meter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def __init__(self, clips_per_video_train, clips_per_video_test):
2727
clips_per_video_train: No. of clips sampled per video at train time
2828
clips_per_video_test: No. of clips sampled per video at test time
2929
"""
30+
super().__init__()
3031

3132
self._clips_per_video_train = clips_per_video_train
3233
self._clips_per_video_test = clips_per_video_test

0 commit comments

Comments
 (0)