-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
74 lines (59 loc) · 2.64 KB
/
main.cpp
File metadata and controls
74 lines (59 loc) · 2.64 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
65
66
67
68
69
70
71
72
73
74
#include <QDebug>
#include <QString>
#include <QImageReader>
#include "grids/fasthexgrid.hpp"
#include "normalizers/sigmoidnormalizer.h"
#include "suspects/colorsuspect.h"
#include "soms/som.h"
#include "classifiers/annclassifier.h"
#include "libraries/sobel_hu_library.h"
#include "hsom.h"
using namespace somtk;
int main()
{
qDebug() << "Starting HSOM test executable" << endl;
QVector<int> gridSize;
gridSize << 25;
qDebug() << "Creating gridTemplate for histograms" << endl;
HistogramGrid gridTemplate( new FastHexGrid<double>( gridSize ) );
qDebug() << "Creating Training Library" << endl;
QMap< QString, QVariant > trainingLibraryParameters;
SuspectLibraryPtr trainingLibrary( new SobelHuLibrary( gridTemplate, trainingLibraryParameters ) );
trainingLibrary->load( "/home/dusktreader/image_library/training_library.xml" );
qDebug() << "Creating Testing Library" << endl;
QMap< QString, QVariant > testingLibraryParameters;
SuspectLibraryPtr testingLibrary( new SobelHuLibrary( gridTemplate, testingLibraryParameters ) );
testingLibrary->load( "/home/dusktreader/image_library/testing_library.xml" );
qDebug() << "Creating and initializing Normalizer" << endl;
NormalizerPtr normalizer( new SigmoidNormalizer() );
QMap<QString, QVariant> normalizerParameters;
normalizerParameters["epsilon"] = 1.0e-6;
normalizerParameters["sigmaStep"] = 5;
normalizer->initialize( normalizerParameters );
qDebug() << "Creating and initializing SOM" << endl;
FeatureGrid somGrid( new FastHexGrid<FeaturePtr>( gridSize ) );
SOMPtr som( new SOM( somGrid, normalizer ) );
qDebug() << "Creating and initializing Classifier" << endl;
ClassifierPtr classifier( new ANNClassifier() );
QMap<QString, QVariant> somParameters;
somParameters["maxEpochs"] = 20;
somParameters["initialAlpha"] = 0.8;
somParameters["initialRadiusRatio"] = 0.40;
QMap<QString, QVariant> classifierParameters;
classifierParameters["inputWidth"] = somGrid->capacity();
classifierParameters["outputWidth"] = trainingLibrary->categoryCount();
qDebug() << "Creating and initializing HSOM" << endl;
HSOM hsom( som, classifier );
qDebug() << "Training HSOM" << endl;
hsom.train( trainingLibrary, somParameters, classifierParameters );
qDebug() << "Testing HSOM" << endl;
foreach( SuspectPtr suspect, testingLibrary->suspects() )
{
hsom.classify( suspect );
qDebug() << suspect->name() << ":";
foreach( double d, suspect->classification() )
qDebug() << d << " ";
qDebug() << ":" << suspect->predCategory() << endl;
}
return 0;
}