-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevaluate.py
More file actions
37 lines (30 loc) · 1.36 KB
/
evaluate.py
File metadata and controls
37 lines (30 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
# coding: utf-8
# ---- My utils ----
from models import model_selector
from utils.arguments import *
from utils.data_augmentation import data_augmentation_selector
from utils.datasets import dataset_selector
from utils.neural import *
_, _, val_aug = data_augmentation_selector(
args.data_augmentation, args.img_size, args.crop_size, args.mask_reshape_method
)
test_loader = dataset_selector(_, _, val_aug, args, is_test=True)
model = model_selector(
args.problem_type, args.model_name, test_loader.dataset.num_classes, from_swa=args.swa_checkpoint,
in_channels=test_loader.dataset.img_channels, devices=args.gpu, checkpoint=args.model_checkpoint
)
test_metrics = MetricsAccumulator(
args.problem_type, args.metrics, test_loader.dataset.num_classes, average="mean",
include_background=test_loader.dataset.include_background, mask_reshape_method=args.mask_reshape_method
)
test_metrics, cases_ids = test_step(
test_loader, model, test_metrics, generated_overlays=args.generated_overlays,
overlays_path=f"{args.output_dir}/overlays/test_evaluation"
)
test_metrics.save_progress_cases(cases_ids, args.output_dir, identifier="test_metrics")
print("\nResults:")
test_metrics.update()
test_metrics.report_best()
if args.notify:
slack_message(message=f"{args.dataset.upper()} evaluation experiments finished!", channel="experiments")