Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main Repositories
otb
Commits
9e6b26ab
Commit
9e6b26ab
authored
7 years ago
by
Cédric Traizet
Browse files
Options
Downloads
Patches
Plain Diff
app cxx added
parent
8426dd2a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!4
Dimensionality reduction algorithms
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/cbDimensionalityReduction.cxx
+27
-20
27 additions, 20 deletions
app/cbDimensionalityReduction.cxx
app/cbDimensionalityReductionTrainer.cxx
+28
-2
28 additions, 2 deletions
app/cbDimensionalityReductionTrainer.cxx
with
55 additions
and
22 deletions
app/cbDimensionalityReduction.cxx
+
27
−
20
View file @
9e6b26ab
...
...
@@ -5,9 +5,7 @@
#include
<iostream>
#include
"otbImage.h"
//#include "otbVectorImage.h"
#include
"otbImageFileReader.h"
#include
"otbImageFileWriter.h"
#include
"otbVectorImage.h"
#include
<shark/Models/Autoencoder.h>
//normal autoencoder model
...
...
@@ -16,6 +14,7 @@
#include
<shark/Models/Normalizer.h>
#include
"encode_filter.h"
//#include "dummy_filter.h"
namespace
otb
{
...
...
@@ -25,11 +24,18 @@ namespace Wrapper
class
CbDimensionalityReduction
:
public
otb
::
Wrapper
::
Application
{
public:
typedef
CbDimensionalityReduction
Self
;
/** Standard class typedefs. */
typedef
CbDimensionalityReduction
Self
;
typedef
Application
Superclass
;
typedef
itk
::
SmartPointer
<
Self
>
Pointer
;
typedef
itk
::
SmartPointer
<
const
Self
>
ConstPointer
;
/** Standard macro */
itkNewMacro
(
Self
);
itkTypeMacro
(
CbDimensionalityReduction
,
otb
::
Wrapper
::
Application
);
itkTypeMacro
(
CbDimensionalityReduction
,
otb
::
Application
);
private:
void
DoInit
()
{
SetName
(
"CbDimensionalityReduction"
);
...
...
@@ -56,33 +62,34 @@ private:
void
DoExecute
()
{
typedef
shark
::
TiedAutoencoder
<
shark
::
TanhNeuron
,
shark
::
LinearNeuron
>
AutoencoderType
;
using
image_type
=
otb
::
VectorImage
<
double
,
2
>
;
typedef
shark
::
Autoencoder
<
shark
::
TanhNeuron
,
shark
::
LinearNeuron
>
AutoencoderType
;
using
image_type
=
FloatVectorImageType
;
using
FilterType
=
EncodeFilter
<
image_type
,
AutoencoderType
,
shark
::
Normalizer
<
shark
::
RealVector
>>
;
using
DummyFilterType
=
DummyFilter
<
image_type
>
;
std
::
cout
<<
"Appli !"
<<
std
::
endl
;
FloatVectorImageType
::
Pointer
inImage
=
GetParameterImage
(
"in"
);
std
::
string
encoderPath
=
GetParameterString
(
"model"
);
std
::
string
normalizerPath
=
GetParameterString
(
"normalizer"
);
//inImage->UpdateOutputInformation();
using
ReaderType
=
otb
::
ImageFileReader
<
image_type
>
;
ReaderType
::
Pointer
reader
=
ReaderType
::
New
();
reader
->
SetFileName
(
"/mnt/data/home/vincenta/features_2014/SL_MultiTempGapF_Brightness_NDVI_NDWI__.tif"
);
FilterType
::
Pointer
filter
=
FilterType
::
New
();
filter
->
SetAutoencoderModel
(
encoderPath
);
filter
->
SetNormalizerModel
(
normalizerPath
);
filter
->
SetInput
(
reader
->
GetOutput
());
//filter->SetInput(inImage);
filter
->
UpdateOutputInformation
();
filter
->
SetInput
(
inImage
);
filter
->
Update
();
SetParameterOutputImage
(
"out"
,
filter
->
GetOutput
());
/*
DummyFilterType::Pointer dummy_filter = DummyFilterType::New(); // this filter simply copies the input image (do not need shark library)
dummy_filter->SetInput(GetParameterFloatVectorImage("in"));
dummy_filter->Update();
dummy_filter->UpdateOutputInformation();
SetParameterOutputImage("out", dummy_filter->GetOutput());
*/
//SetParameterOutputImage("out", inImage); // copy input image
}
};
...
...
This diff is collapsed.
Click to expand it.
app/cbDimensionalityReductionTrainer.cxx
+
28
−
2
View file @
9e6b26ab
#include
"otbWrapperApplication.h"
#include
"otbWrapperApplicationFactory.h"
#include
"otbWrapperChoiceParameter.h"
#include
"otbOGRDataSourceWrapper.h"
#include
"otbOGRFeatureWrapper.h"
namespace
otb
{
namespace
Wrapper
{
class
CbDimensionalityReductionTrainer
:
public
otb
::
Wrapper
::
Application
{
public:
...
...
@@ -13,6 +21,14 @@ private:
{
SetName
(
"CbDimensionalityReductionTrainer"
);
SetDescription
(
"Trainer for the dimensionality reduction algorithms used in the cbDimensionalityReduction application."
);
AddParameter
(
ParameterType_InputVectorData
,
"train"
,
"Name of the input training vector data"
);
SetParameterDescription
(
"train"
,
"The vector data used for training."
);
/*
AddParameter(ParameterType_InputVectorData, "val", "Name of the input validation vector data");
SetParameterDescription("val","The vector data used for validation.");
*/
AddRAMParameter
();
}
...
...
@@ -23,9 +39,19 @@ private:
void
DoExecute
()
{
std
::
cout
<<
"Appli !"
<<
std
::
endl
;
int
ThisDoesNothing
=
0
;
std
::
string
shapefile
=
GetParameterString
(
"train"
);
otb
::
ogr
::
DataSource
::
Pointer
source
=
otb
::
ogr
::
DataSource
::
New
(
shapefile
,
otb
::
ogr
::
DataSource
::
Modes
::
Read
);
otb
::
ogr
::
Layer
layer
=
source
->
GetLayer
(
0
);
//ListSampleType::Pointer input = ListSampleType::New();
//const int nbFeatures = GetSelectedItems("feat").size();
//input->SetMeasurementVectorSize(nbFeatures);
}
};
OTB_APPLICATION_EXPORT
(
CbDimensionalityReductionTrainer
)
}
}
OTB_APPLICATION_EXPORT
(
otb
::
Wrapper
::
CbDimensionalityReductionTrainer
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment