-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstart.py
More file actions
54 lines (49 loc) · 2.09 KB
/
start.py
File metadata and controls
54 lines (49 loc) · 2.09 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
import sys
from torch._C import device
import config
config.init()
from global_values import *
import librosa
from core.feature_exraction.data_to_db import data_set
import common.log_handler as log_handler
logger = log_handler.get_logger()
from core.feature_exraction import extract
from core.predictor.training import Train
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--mode', help='feature extraction or training')
parser.add_argument('--feature', help='choose which feature to extract or train')
parser.add_argument('--feature_tables', help='choose the feature to train using tables name',
type=list)
parser.add_argument('--model', help='choose which predictor to train')
parser.add_argument('--gender', help='wether consider gender or not')
parser.add_argument('--db', help='choose which database version you use, sqlite or mysql')
parser.add_argument('--device', '-d', default='cpu', help="which device")
args = parser.parse_args()
if args.db is not None:
config.db_type = args.db
if args.mode == 'extract':
# fea_ext = extract.FeatureExtration(model=args.feature)
fea_ext = extract.FeatureExtration(feature_name=args.feature)
fea_ext.gen_fea()
elif args.mode == 'train':
if args.feature is not None:
fea = args.feature
model = args.model
logger.info(f'You are training using model {model} via feature {fea}')
training = Train(model_name=model, feature_name=fea, device=args.device)
training.start()
if args.gender == 'y':
logger.info(f'You are training using model {model} via feature {fea} and consider gender!')
Train(model_name=model, feature_name=fea, gender=True, devcie=args.device).start()
else:
fea_tables = args.feature_tables
model = args.model
logger.info(f'[Training] You are using model {model} via feature table {fea_tables}')
training = Train()
elif args.mode == 'database':
from common.sql_handler import SqlHandler
sql_handler = SqlHandler()
sql_handler.print_tables()
else:
logger.info('training model not finished yet!')