main.py 2.6 KB
Newer Older
1
from config import config
okiss's avatar
okiss committed
2
from ensemble import run
3
import numpy as np
okiss's avatar
okiss committed
4
import scipy
okiss's avatar
okiss committed
5
from scipy import io
okiss's avatar
okiss committed
6
import h5py
okiss's avatar
okiss committed
7
8
import logging
import time
9

10
def main():
Ard Kastrati's avatar
Ard Kastrati committed
11
12
    logging.basicConfig(filename=config['info_log'], level=logging.INFO)
    logging.info('Started the Logging')
13
    start_time = time.time()
14
    # try:
okiss's avatar
okiss committed
15
16
17
18
19
20
21
22
23
24
    # trainX, trainY = IOHelper.get_mat_data(config['data_dir'], verbose=True)
    f =  io.loadmat('trainX.mat')
    trainX = f['trainX'].reshape(-1,500,129)[:20,...]
    trainY=io.loadmat('trainY.mat')['trainY'][:20]

    if config['model'] == 'eegnet' or config['model'] == 'eegnet_cluster':
        trainX = np.transpose(trainX, (0, 2, 1))
        logging.info(trainX.shape)
    run(trainX,trainY)
    '''
zpgeng's avatar
zpgeng committed
25
    if config['model'] == 'cnn' or config['model'] == 'cnn_cluster':
26
        logging.info("Started running CNN. If you want to run other methods please choose another model in the config.py file.")
27
        CNN.run(trainX, trainY)
28

zpgeng's avatar
zpgeng committed
29
    elif config['model'] == 'eegnet' or config['model'] == 'eegnet_cluster':
30
31
        logging.info(
            "Started running EEGNet. If you want to run other methods please choose another model in the config.py file.")
32
        eegnet_x = np.transpose(trainX, (0, 2, 1))
Ard Kastrati's avatar
Ard Kastrati committed
33
        logging.info(eegnet_x.shape)
34
        eegNet.run(trainX=eegnet_x, trainY=trainY)
35

36
37
38
    elif config['model'] == 'inception' or config['model'] == 'inception_cluster':
        logging.info("Started running InceptionTime. If you want to run other methods please choose another model in the config.py file.")
        inception.run(trainX=trainX, trainY=trainY)
39

zpgeng's avatar
zpgeng committed
40
    elif config['model'] == 'xception' or config['model'] == 'xception_cluster':
41
        logging.info("Started running XceptionTime. If you want to run other methods please choose another model in the config.py file.")
42
43
44
45
46
        xception.run(trainX=trainX, trainY=trainY)

    elif config['model'] == 'deepeye' or config['model'] == 'deepeye_cluster':
        logging.info("Started running DeepEye. If you want to run other methods please choose another model in the config.py file.")
        deepeye.run(trainX=trainX, trainY=trainY)
okiss's avatar
okiss committed
47

48
49
50
    elif config['model'] == 'deepeye-rnn' or config['model'] == 'deepeye-rnn_cluster':
        logging.info("Started running deepeye-rnn. If you want to run other methods please choose another model in the config.py file.")
        deepeyeRNN.run(trainX=trainX, trainY=trainY)
51

52
    else:
Ard Kastrati's avatar
Ard Kastrati committed
53
        logging.info('Cannot start the program. Please choose one model in the config.py file')
okiss's avatar
okiss committed
54
    '''
Ard Kastrati's avatar
Ard Kastrati committed
55
56
    logging.info("--- Runtime: %s seconds ---" % (time.time() - start_time))
    logging.info('Finished Logging')
57

58
if __name__=='__main__':
zigeng's avatar
zigeng committed
59
    main()