-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.m
64 lines (55 loc) · 2.35 KB
/
main.m
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
disp('Nepali Handwritten Character Recognition')
disp('-----------------------------------------')
mode = 'Numerals'; % Numerals, Vowels, Consonants
reExtractFeatures = false;
disp('Setting up the configurations ...')
config = setup();
switch(mode)
case 'Numerals'
disp('Operation mode: Numerals')
datasetDir = config.NUMERALS_DATASET_DIR;
datasetName = config.NUMERALS;
datasetMatFile = config.NUMERALS_DATASET;
preprocessedMatFile = config.NUMERALS_DATASET_PP;
featuresMatFile = config.NUMERALS_DATASET_FE;
mlpModelMatFile = config.NUMERALS_DATASET_MODEL_MLP;
rbfModelMatFile = config.NUMERALS_DATASET_MODEL_RBF;
case 'Vowels'
disp('Operation mode: Vowels')
datasetDir = config.VOWELS_DATASET_DIR;
datasetName = config.VOWELS;
datasetMatFile = config.VOWELS_DATASET;
preprocessedMatFile = config.VOWELS_DATASET_PP;
featuresMatFile = config.VOWELS_DATASET_FE;
mlpModelMatFile = config.VOWELS_DATASET_MODEL_MLP;
rbfModelMatFile = config.VOWELS_DATASET_MODEL_RBF;
case 'Consonants'
disp('Operation mode: Consonants')
datasetDir = config.CONSONANTS_DATASET_DIR;
datasetName = config.CONSONANTS;
datasetMatFile = config.CONSONANTS_DATASET;
preprocessedMatFile = config.CONSONANTS_DATASET_PP;
featuresMatFile = config.CONSONANTS_DATASET_FE;
mlpModelMatFile = config.CONSONANTS_DATASET_MODEL_MLP;
rbfModelMatFile = config.CONSONANTS_DATASET_MODEL_RBF;
end
disp('Creating calss samples ...')
samples = readClassSamples(config);
if (reExtractFeatures || ~ exist(featuresMatFile, 'file'))
disp('Creating the dataset ...')
dataset = createDataset(datasetDir, datasetName, datasetMatFile);
disp('Preprocessing the images ...')
datasetPP = preprocessing(dataset, preprocessedMatFile);
disp('Extracting features ...')
datasetFE = extractFeatures(datasetPP, featuresMatFile);
else
disp('Loading features ...')
datasetFE = load(featuresMatFile);
datasetFE = datasetFE.dataset;
end
disp('Preparing for training ...')
features = prepareForTrain(datasetFE, 0.8, 0.2);
disp('Trainig MLP ...')
modelMLP = mlp(features, mlpModelMatFile, config.RESULTS_EXCEL_FILE);
disp('Trainig RBF ...')
modelRBF = rbf(features, rbfModelMatFile, config.RESULTS_EXCEL_FILE);