MCPcopy Create free account
hub / github.com/OpenGVLab/UniFormerV2 / TensorboardWriter

Class TensorboardWriter

slowfast/visualization/tensorboard_vis.py:20–235  ·  view source on GitHub ↗

Helper class to log information to Tensorboard.

Source from the content-addressed store, hash-verified

18
19
20class TensorboardWriter(object):
21 """
22 Helper class to log information to Tensorboard.
23 """
24
25 def __init__(self, cfg):
26 """
27 Args:
28 cfg (CfgNode): configs. Details can be found in
29 slowfast/config/defaults.py
30 """
31 # class_names: list of class names.
32 # cm_subset_classes: a list of class ids -- a user-specified subset.
33 # parent_map: dictionary where key is the parent class name and
34 # value is a list of ids of its children classes.
35 # hist_subset_classes: a list of class ids -- user-specified to plot histograms.
36 (
37 self.class_names,
38 self.cm_subset_classes,
39 self.parent_map,
40 self.hist_subset_classes,
41 ) = (None, None, None, None)
42 self.cfg = cfg
43 self.cm_figsize = cfg.TENSORBOARD.CONFUSION_MATRIX.FIGSIZE
44 self.hist_figsize = cfg.TENSORBOARD.HISTOGRAM.FIGSIZE
45
46 if cfg.TENSORBOARD.LOG_DIR == "":
47 log_dir = os.path.join(
48 cfg.OUTPUT_DIR, "runs-{}".format(cfg.TRAIN.DATASET)
49 )
50 else:
51 log_dir = os.path.join(cfg.OUTPUT_DIR, cfg.TENSORBOARD.LOG_DIR)
52
53 self.writer = SummaryWriter(log_dir=log_dir)
54 logger.info(
55 "To see logged results in Tensorboard, please launch using the command \
56 `tensorboard --port=<port-number> --logdir {}`".format(
57 log_dir
58 )
59 )
60
61 if cfg.TENSORBOARD.CLASS_NAMES_PATH != "":
62 if cfg.DETECTION.ENABLE:
63 logger.info(
64 "Plotting confusion matrix is currently \
65 not supported for detection."
66 )
67 (
68 self.class_names,
69 self.parent_map,
70 self.cm_subset_classes,
71 ) = get_class_names(
72 cfg.TENSORBOARD.CLASS_NAMES_PATH,
73 cfg.TENSORBOARD.CATEGORIES_PATH,
74 cfg.TENSORBOARD.CONFUSION_MATRIX.SUBSET_PATH,
75 )
76
77 if cfg.TENSORBOARD.HISTOGRAM.ENABLE:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected