-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
81 lines (59 loc) · 2.56 KB
/
main.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#-------------------------------------------------------------------------------------------------------------------------------
# PNEUMONIA DETECTION
# DETECTS IF A PERSON HAS PNEUMONIA OR NOT USING THE X-RAY IMAGES OF THEIR CHEST. USES CONVOLUTIONAL NEURAL NETWORK
# FILE NAME: MAIN.PY
# DONE BY: VIGNESHWAR RAVICHANDAR
# TOPICS: Deep Learning, TensorFlow, Convolutional Neural Networks, Binary Classification
#-------------------------------------------------------------------------------------------------------------------------------
# IMPORTING REQUIRED LIBRARIES
import os
import argparse
# FUNCTION TO CONVERT STR INPUT TO BOOL
def strBool(v):
if isinstance(v, bool):
return v
if v.lower() in ('yes', 'true', 't', 'y', '1'):
return True
elif v.lower() in ('no', 'false', 'f', 'n', '0'):
return False
else:
raise argparse.ArgumentTypeError('Expected a Boolean Value.')
# PARSING FUNCTION
def parse():
parser = argparse.ArgumentParser(description = 'Command Line Interface for Pneumonia Detection.')
parser.add_argument('-ds','--dataset',
type = str,
help = 'Argument taken for mentioning dataset source.',
default = "local")
parser.add_argument('-tr','--train',
type = strBool,
help = 'Argument taken for training model.',
default = "False")
parser.add_argument('-req','--install_requirements',
type = strBool,
help = 'Argument taken for installing requirements',
default = False)
parser.add_argument('-t','--test',
type = strBool,
help = 'Argument for testing with custom input',
required = True)
args = parser.parse_args()
return args
# MAIN FUNCTION
if __name__ == "__main__":
# DISABLING TENSORFLOW DEBUGGING INFORMATION
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
print("TensorFlow Debugging Information is hidden.")
args = parse()
if (args.install_requirements):
os.system('sudo apt install python3-pip')
os.system('pip3 install -r requirements.txt')
if (args.dataset.lower() == 'cloud'):
os.system('. src/get_ds.sh')
os.system('. src/check_ds.sh')
if (args.dataset.lower() == 'local'):
os.system('. src/check_ds.sh')
if (args.train):
os.system('python3 src/train.py')
if (args.test):
os.system('python3 src/test.py')