/
non_adv_evaluate.py
46 lines (36 loc) · 1.16 KB
/
non_adv_evaluate.py
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
38
39
40
41
42
43
44
45
46
import argparse
import json
from src.evaluation import NonAdvEvaluator
from src.utils import ConfigManager, load_yaml
def main(config, args):
config_manager = ConfigManager(config)
model = config_manager.init_object("model", weight_file=args.weights_path)
dataset = config_manager.init_object("dataset")
# Run evaluation
evaluator = NonAdvEvaluator(model, dataset)
results = evaluator.evaluate(tuple(config["resize"]))
# Save results
print(results)
with open(args.results_path, "w") as f:
json.dump(results, f)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--config",
help="path to the config file",
default="configs/evaluate/config.yaml",
)
parser.add_argument(
"--weights_path",
help="path to the weights / checkpoint to load",
default="artifacts/exif_sc.npy",
)
parser.add_argument(
"--results_path",
help="path to store evaluation results as JSON file",
default="results.json",
)
args = parser.parse_args()
# Load config file
config = load_yaml(args.config)
main(config, args)