Skip to content

Commit

Permalink
Minor changes to evaluation script
Browse files Browse the repository at this point in the history
  • Loading branch information
sovit-123 committed Oct 19, 2023
1 parent b4c0566 commit 5d4e1fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 1 addition & 2 deletions eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions utils/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
# classes=CLASSES,
)

0 comments on commit 5d4e1fb

Please sign in to comment.