From 5d4e1fbadd369c2bb4e3303583d7ba53fdbe4e5c Mon Sep 17 00:00:00 2001 From: sovit-123 Date: Thu, 19 Oct 2023 22:40:26 +0530 Subject: [PATCH] Minor changes to evaluation script --- eval.py | 3 +-- utils/validate.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/eval.py b/eval.py index 8045e790..1e3c43a6 100644 --- a/eval.py +++ b/eval.py @@ -139,6 +139,7 @@ def evaluate( classes=None, colors=None ): + metric = MeanAveragePrecision(class_metrics=args['verbose']) n_threads = torch.get_num_threads() # FIXME remove this and make paste_masks_in_image run on the GPU torch.set_num_threads(1) @@ -172,13 +173,11 @@ def evaluate( preds.append(preds_dict) target.append(true_dict) ##################################### - outputs = [{k: v.to(cpu_device) for k, v in t.items()} for t in outputs] # gather the stats from all processes metric_logger.synchronize_between_processes() torch.set_num_threads(n_threads) - metric = MeanAveragePrecision(class_metrics=args['verbose']) metric.update(preds, target) metric_summary = metric.compute() return metric_summary diff --git a/utils/validate.py b/utils/validate.py index 6497265d..832a04b5 100644 --- a/utils/validate.py +++ b/utils/validate.py @@ -78,16 +78,18 @@ # Model configurations IMAGE_WIDTH = args['img_size'] IMAGE_HEIGHT = args['img_size'] - valid_dataset = create_valid_dataset( - VALID_DIR_IMAGES, VALID_DIR_LABELS, - IMAGE_WIDTH, IMAGE_HEIGHT, CLASSES - ) + VALID_DIR_IMAGES, + VALID_DIR_LABELS, + args['img_size'], + CLASSES, + square_training=True + ) valid_loader = create_valid_loader(valid_dataset, BATCH_SIZE, NUM_WORKERS) coco_evaluator, stats = evaluate( model, valid_loader, device=DEVICE, - classes=CLASSES, - ) \ No newline at end of file + # classes=CLASSES, + )