def on_epoch_end(self, epoch, logs=None): logs = logs or {} coco_tag = ['AP @[ IoU=0.50:0.95 | area= all | maxDets=100 ]', 'AP @[ IoU=0.50 | area= all | maxDets=100 ]', 'AP @[ IoU=0.75 | area= all | maxDets=100 ]', 'AP @[ IoU=0.50:0.95 | area= small | maxDets=100 ]', 'AP @[ IoU=0.50:0.95 | area=medium | maxDets=100 ]', 'AP @[ IoU=0.50:0.95 | area= large | maxDets=100 ]', 'AR @[ IoU=0.50:0.95 | area= all | maxDets= 1 ]', 'AR @[ IoU=0.50:0.95 | area= all | maxDets= 10 ]', 'AR @[ IoU=0.50:0.95 | area= all | maxDets=100 ]', 'AR @[ IoU=0.50:0.95 | area= small | maxDets=100 ]', 'AR @[ IoU=0.50:0.95 | area=medium | maxDets=100 ]', 'AR @[ IoU=0.50:0.95 | area= large | maxDets=100 ]'] coco_eval_stats = evaluate_coco(self.generator, self.model, self.threshold) if coco_eval_stats is not None and self.tensorboard is not None and self.tensorboard.writer is not None: import tensorflow as tf summary = tf.Summary() for index, result in enumerate(coco_eval_stats): summary_value = summary.value.add() summary_value.simple_value = result summary_value.tag = '{}. {}'.format(index + 1, coco_tag[index]) self.tensorboard.writer.add_summary(summary, epoch) logs[coco_tag[index]] = result
def main(args=None): # parse arguments if args is None: args = sys.argv[1:] args = parse_args(args) # make sure keras is the minimum required version check_keras_version() # optionally choose specific GPU if args.gpu: os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu keras.backend.tensorflow_backend.set_session(get_session()) # create the model print('Loading model, this may take a second...') model = keras.models.load_model(args.model, custom_objects=custom_objects) # create a generator for testing data test_generator = CocoGenerator(args.coco_path, args.set) evaluate_coco(test_generator, model, args.score_threshold)