forked from marcosmoraes/deep-learning
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·67 lines (52 loc) · 2.74 KB
/
Copy pathmain.py
File metadata and controls
executable file
·67 lines (52 loc) · 2.74 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
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
import logging
import argparse
from satellite import start
from coloredlogs import ColoredFormatter
import sys
if sys.version_info[0] < 3:
raise RuntimeError('Python3 required')
def main(app, network_type, augment_data, is_training, is_predicting):
"""
"""
if app == 'satellite':
start.main(network_type, augment_data, is_training, is_predicting)
elif app == 'insects':
pass
else:
pass
if __name__ == '__main__':
"""
Example:
> python main.py -application APP -model MODEL -augment BOOLEAN -train BOOLEAN -predict BOOLEAN -verbose BOOLEAN
Usage:
> python main.py -application satellite -model unet -augment False -train True -predict False -verbose True
> python main.py -application satellite -model unet -augment False -train False -predict True -verbose True
> python main.py -application satellite -model unet -augment False -train True -predict True -verbose True
"""
parser = argparse.ArgumentParser(description='Integrate some of the main Deep Learning models for remote sensing '
'image analysis and mapping')
parser.add_argument('-application', action="store", dest='application', help='Defines which purpose the DL will '
'be trained: satellite or insects')
parser.add_argument('-model', action="store", dest='model', help='Deep Learning model name: unet, deeplabv3')
parser.add_argument('-augment', action="store", dest='augment', help='If True, augment training data')
parser.add_argument('-train', action="store", dest='train', help='Perform neural network training?')
parser.add_argument('-predict', action="store", dest='predict', help='Perform neural network prediction?')
parser.add_argument('-verbose', action="store", dest='verbose', help='Print log of processing')
args = parser.parse_args()
if eval(args.verbose):
log = logging.getLogger('')
ch = logging.StreamHandler(sys.stdout)
ch.setLevel(logging.INFO)
cf = ColoredFormatter("[%(asctime)s] {%(filename)-15s:%(lineno)-4s} %(levelname)-5s: %(message)s ")
ch.setFormatter(cf)
log.addHandler(ch)
fh = logging.FileHandler('logging.log')
fh.setLevel(logging.INFO)
ff = logging.Formatter("[%(asctime)s] {%(filename)-15s:%(lineno)-4s} %(levelname)-5s: %(message)s ",
datefmt='%Y.%m.%d %H:%M:%S')
fh.setFormatter(ff)
log.addHandler(fh)
log.setLevel(logging.DEBUG)
else:
logging.basicConfig(format="%(levelname)s: %(message)s")
main(args.application, args.model, args.augment, args.train, args.predict)