PKaushik commited on
Commit
470bd55
1 Parent(s): 94aadfb
Files changed (1) hide show
  1. yolov6/utils/events.py +41 -0
yolov6/utils/events.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ import os
4
+ import yaml
5
+ import logging
6
+ import shutil
7
+
8
+
9
+ def set_logging(name=None):
10
+ rank = int(os.getenv('RANK', -1))
11
+ logging.basicConfig(format="%(message)s", level=logging.INFO if (rank in (-1, 0)) else logging.WARNING)
12
+ return logging.getLogger(name)
13
+
14
+
15
+ LOGGER = set_logging(__name__)
16
+ NCOLS = shutil.get_terminal_size().columns
17
+
18
+
19
+ def load_yaml(file_path):
20
+ """Load data from yaml file."""
21
+ if isinstance(file_path, str):
22
+ with open(file_path, errors='ignore') as f:
23
+ data_dict = yaml.safe_load(f)
24
+ return data_dict
25
+
26
+
27
+ def save_yaml(data_dict, save_path):
28
+ """Save data to yaml file"""
29
+ with open(save_path, 'w') as f:
30
+ yaml.safe_dump(data_dict, f, sort_keys=False)
31
+
32
+
33
+ def write_tblog(tblogger, epoch, results, losses):
34
+ """Display mAP and loss information to log."""
35
+ tblogger.add_scalar("val/mAP@0.5", results[0], epoch + 1)
36
+ tblogger.add_scalar("val/mAP@0.50:0.95", results[1], epoch + 1)
37
+
38
+ tblogger.add_scalar("train/iou_loss", losses[0], epoch + 1)
39
+ tblogger.add_scalar("train/l1_loss", losses[1], epoch + 1)
40
+ tblogger.add_scalar("train/obj_loss", losses[2], epoch + 1)
41
+ tblogger.add_scalar("train/cls_loss", losses[3], epoch + 1)