-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_label_maker.py
66 lines (53 loc) · 2.13 KB
/
run_label_maker.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import boto3
import yaml
import click
import urllib.parse as urlparse
from label_maker import *
def run_site_selection(dir_config, run_local, do_corr, do_match, do_validate_metrics, do_selction):
assert isinstance(run_local, bool)
# params
if dir_config.startswith("s3"):
parsed = urlparse.urlparse(dir_config)
config = yaml.load(boto3.resource('s3').Bucket(parsed.netloc).Object(parsed.path).get()['Body'].read())
else:
with open(dir_config, "r") as config:
config = yaml.safe_load(config)
params = {**config['Sites_Selection'], **config['AWS']}
# calculate correlation
if do_corr == True:
get_corr(params, run_local=run_local)
else:
pass
# match validation labels and predictions
if do_match == True:
match_validate_pred(params, run_local=run_local)
else:
pass
# calculate validate metrics
if do_validate_metrics:
get_metrics(params, run_local=run_local)
else:
pass
# select new sites
if do_selction:
get_new_sites(params, run_local=run_local)
else:
pass
@click.command()
@click.option('--dir-config', default='./config.yaml',
help='Directory of config file')
@click.option('--run-local', is_flag=True,
help='Whether the scripts are run in local conputer')
@click.option('--do-corr', is_flag=True,
help='Whether to calculate the correlation')
@click.option('--do-match', is_flag=True,
help='Whether to match directories of validate labels and score maps')
@click.option('--do-validate-metrics', is_flag=True,
help='Whether to calculate metrics on prediction of each validation site')
@click.option('--do-selection', is_flag=True,
help='Whether to select new sites based on calculated image correlation, prediciton metrics on validation sites,'
'and specified site numbers')
def main(dir_config, run_local, do_corr, do_match, do_validate_metrics, do_selection):
run_site_selection(dir_config, run_local, do_corr, do_match, do_validate_metrics, do_selection)
if __name__=='__main__':
main()