Commit 8380cfa7 authored by Yuxin Wu's avatar Yuxin Wu

[FasterRCNN] write evaluation to monitors

parent 230efcc1
......@@ -129,6 +129,7 @@ def eval_on_dataflow(df, detect_func):
# https://github.com/pdollar/coco/blob/master/PythonAPI/pycocoEvalDemo.ipynb
def print_evaluation_scores(json_file):
ret = {}
assert config.BASEDIR and os.path.isdir(config.BASEDIR)
annofile = os.path.join(
config.BASEDIR, 'annotations',
......@@ -139,9 +140,12 @@ def print_evaluation_scores(json_file):
cocoEval.evaluate()
cocoEval.accumulate()
cocoEval.summarize()
ret['mAP(bbox)'] = cocoEval.stats[0]
if config.MODE_MASK:
cocoEval = COCOeval(coco, cocoDt, 'segm')
cocoEval.evaluate()
cocoEval.accumulate()
cocoEval.summarize()
ret['mAP(segm)'] = cocoEval.stats[0]
return ret
......@@ -8,7 +8,6 @@ import cv2
import shutil
import itertools
import tqdm
import math
import numpy as np
import json
import tensorflow as tf
......@@ -313,7 +312,9 @@ class EvalCallback(Callback):
logger.get_logger_dir(), 'outputs{}.json'.format(self.global_step))
with open(output_file, 'w') as f:
json.dump(all_results, f)
print_evaluation_scores(output_file)
scores = print_evaluation_scores(output_file)
for k, v in scores.items():
self.trainer.monitors.put_scalar(k, v)
def _trigger_epoch(self):
if self.epoch_num in self.epochs_to_eval:
......@@ -359,8 +360,8 @@ if __name__ == '__main__':
else:
logger.set_logger_dir(args.logdir)
print_config()
stepnum = 300
warmup_epoch = max(math.ceil(500.0 / stepnum), 5)
stepnum = 500
warmup_epoch = 3
factor = get_batch_factor()
cfg = TrainConfig(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment