-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
39 lines (37 loc) · 1.4 KB
/
Copy pathmain.py
File metadata and controls
39 lines (37 loc) · 1.4 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
38
39
import argparse
from feature_extraction import segment, merge, extract_features
from prediction import predict
def main(steps):
image_dir = 'data/images'
patient_info = 'data/patient_info.csv'
seg_dir = 'data/segmentations'
feature_dir = 'data'
features = 'data/features.csv'
model_path = 'data/model.json'
pred_dir = 'data'
if 'segment' in steps:
segment(image_dir, seg_dir)
if 'merge' in steps:
merge(seg_dir)
if 'extract' in steps:
extract_features(image_dir, seg_dir, feature_dir)
if 'predict' in steps:
predict(features, patient_info, model_path, pred_dir)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--feature-extraction', action='store_true',
help='All feature extraction steps (segment, merge, extract)')
parser.add_argument('--segment', action='store_true')
parser.add_argument('--merge', action='store_true')
parser.add_argument('--extract', action='store_true')
parser.add_argument('--predict', action='store_true')
args = vars(parser.parse_args())
steps = []
feature_extraction_steps = ['segment', 'merge', 'extract']
for step in feature_extraction_steps:
if args['feature_extraction'] or args[step]:
steps.append(step)
for step in ['predict']:
if args[step]:
steps.append(step)
main(steps)