Commit 35a892a4 authored by remi cresson's avatar remi cresson
Browse files

REFAC: wip#3

parent 7ce1daf5
......@@ -92,9 +92,11 @@ private:
ShareParameter("deepmodel", "tfmodel.model",
"Deep net model parameters", "Deep net model parameters");
ShareParameter("output", "tfmodel.output",
"Deep net outputs parameters", "Deep net outputs parameters");
ShareParameter("finetuning", "tfmodel.finetuning",
"Deep net fine tuning parameters","Deep net fine tuning parameters");
"Deep net outputs parameters",
"Deep net outputs parameters");
ShareParameter("optim", "tfmodel.optim",
"This group of parameters allows optimization of processing time",
"This group of parameters allows optimization of processing time");
// Classify shared parameters
ShareParameter("model" , "classif.model" , "Model file" , "Model file" );
......
......@@ -106,14 +106,14 @@ public:
// Parameter group keys
ss_key_in << ss_key_group.str() << ".il";
ss_key_dims_x << ss_key_group.str() << ".fovx";
ss_key_dims_y << ss_key_group.str() << ".fovy";
ss_key_dims_x << ss_key_group.str() << ".rfieldx";
ss_key_dims_y << ss_key_group.str() << ".rfieldy";
ss_key_ph << ss_key_group.str() << ".placeholder";
// Parameter group descriptions
ss_desc_in << "Input image (or list to stack) for source #" << inputNumber;
ss_desc_dims_x << "Field of view width for source #" << inputNumber;
ss_desc_dims_y << "Field of view height for source #" << inputNumber;
ss_desc_dims_x << "Input receptive field (width) for source #" << inputNumber;
ss_desc_dims_y << "Input receptive field (height) for source #" << inputNumber;
ss_desc_ph << "Name of the input placeholder for source #" << inputNumber;
// Populate group
......@@ -182,22 +182,22 @@ public:
MandatoryOn ("output.names");
// Output Field of Expression
AddParameter(ParameterType_Int, "output.foex", "The output field of expression (x)");
SetMinimumParameterIntValue ("output.foex", 1);
SetDefaultParameterInt ("output.foex", 1);
MandatoryOn ("output.foex");
AddParameter(ParameterType_Int, "output.foey", "The output field of expression (y)");
SetMinimumParameterIntValue ("output.foey", 1);
SetDefaultParameterInt ("output.foey", 1);
MandatoryOn ("output.foey");
AddParameter(ParameterType_Int, "output.efieldx", "The output expression field (width)");
SetMinimumParameterIntValue ("output.efieldx", 1);
SetDefaultParameterInt ("output.efieldx", 1);
MandatoryOn ("output.efieldx");
AddParameter(ParameterType_Int, "output.efieldy", "The output expression field (height)");
SetMinimumParameterIntValue ("output.efieldy", 1);
SetDefaultParameterInt ("output.efieldy", 1);
MandatoryOn ("output.efieldy");
// Fine tuning
AddParameter(ParameterType_Group, "finetuning" , "Fine tuning performance or consistency parameters");
AddParameter(ParameterType_Bool, "finetuning.disabletiling", "Disable tiling");
MandatoryOff ("finetuning.disabletiling");
AddParameter(ParameterType_Int, "finetuning.tilesize", "Tile width used to stream the filter output");
SetMinimumParameterIntValue ("finetuning.tilesize", 1);
SetDefaultParameterInt ("finetuning.tilesize", 16);
AddParameter(ParameterType_Group, "optim" , "This group of parameters allows optimization of processing time");
AddParameter(ParameterType_Bool, "optim.disabletiling", "Disable tiling");
MandatoryOff ("optim.disabletiling");
AddParameter(ParameterType_Int, "optim.tilesize", "Tile width used to stream the filter output");
SetMinimumParameterIntValue ("optim.tilesize", 1);
SetDefaultParameterInt ("optim.tilesize", 16);
// Output image
AddParameter(ParameterType_OutputImage, "out", "output image");
......@@ -205,8 +205,8 @@ public:
// Example
SetDocExampleParameterValue("source1.il", "spot6pms.tif");
SetDocExampleParameterValue("source1.placeholder", "x1");
SetDocExampleParameterValue("source1.fovx", "16");
SetDocExampleParameterValue("source1.fovy", "16");
SetDocExampleParameterValue("source1.rfieldx", "16");
SetDocExampleParameterValue("source1.rfieldy", "16");
SetDocExampleParameterValue("model.dir", "/tmp/my_saved_model/");
SetDocExampleParameterValue("model.userplaceholders", "is_training=false dropout=0.0");
SetDocExampleParameterValue("output.names", "out_predict1 out_proba1");
......@@ -286,10 +286,10 @@ public:
otbAppLogINFO("Output field of expression: " << m_TFFilter->GetOutputExpressionFields()[0]);
// Streaming
if (GetParameterInt("finetuning.disabletiling")!=1)
if (GetParameterInt("optim.disabletiling")!=1)
{
// Get the tile size
const unsigned int tileSize = GetParameterInt("finetuning.tilesize");
const unsigned int tileSize = GetParameterInt("optim.tilesize");
otbAppLogINFO("Force tiling with squared tiles of " << tileSize)
// Update the TF filter to get the output image size
......
......@@ -130,8 +130,8 @@ public:
// Parameter group descriptions
ss_desc_tr_in << "Input image (or list to stack) for source #" << inputNumber << " (training)";
ss_desc_val_in << "Input image (or list to stack) for source #" << inputNumber << " (validation)";
ss_desc_dims_x << "Field of view width for source #" << inputNumber;
ss_desc_dims_y << "Field of view height for source #" << inputNumber;
ss_desc_dims_x << "Patch size (x) for source #" << inputNumber;
ss_desc_dims_y << "Patch size (y) for source #" << inputNumber;
ss_desc_tr_ph << "Name of the input placeholder for source #" << inputNumber << " (training)";
ss_desc_val_ph << "Name of the input placeholder "
"or output tensor for source #" << inputNumber << " (validation)";
......
......@@ -63,7 +63,6 @@ private:
}
void DoInit()
{
......@@ -91,7 +90,7 @@ private:
}
ShareParameter("model", "tfmodel.model", "Deep net model parameters", "Deep net model parameters");
ShareParameter("output", "tfmodel.output", "Deep net outputs parameters", "Deep net outputs parameters");
ShareParameter("finetuning", "tfmodel.finetuning", "Deep net fine tuning parameters", "Deep net fine tuning parameters");
ShareParameter("optim", "tfmodel.optim", "This group of parameters allows optimization of processing time", "This group of parameters allows optimization of processing time");
// Train shared parameters
ShareParameter("vd" , "train.io.vd" , "Input vector data list" , "Input vector data list" );
......
......@@ -30,36 +30,35 @@ TensorflowMultisourceModelValidate<TInputImage>
{
Superclass::GenerateOutputInformation();
//////////////////////////////////////////////////////////////////////////////////////////
// Check the references
//////////////////////////////////////////////////////////////////////////////////////////
// Check that there is some reference
const unsigned int nbOfRefs = m_References.size();
if (nbOfRefs == 0)
{
itkExceptionMacro("No reference is set");
}
SizeListType outputEFSizes = this->GetOutputExpressionFields();
if (nbOfRefs != outputEFSizes.size())
// Check the number of references
SizeListType outputPatchSizes = this->GetOutputExpressionFields();
if (nbOfRefs != outputPatchSizes.size())
{
itkExceptionMacro("There is " << nbOfRefs << " but only " <<
outputEFSizes.size() << " field of expression sizes");
itkExceptionMacro("There is " << nbOfRefs << " references but only " <<
outputPatchSizes.size() << " output patch sizes");
}
// Check reference image infos
for (unsigned int i = 0 ;i < nbOfRefs ; i++)
for (unsigned int i = 0 ; i < nbOfRefs ; i++)
{
const SizeType outputFOESize = outputEFSizes[i];
const SizeType outputPatchSize = outputPatchSizes[i];
const RegionType refRegion = m_References[i]->GetLargestPossibleRegion();
if (refRegion.GetSize(0) != outputFOESize[0])
if (refRegion.GetSize(0) != outputPatchSize[0])
{
itkExceptionMacro("Reference image " << i << " width is " << refRegion.GetSize(0) <<
" but field of expression width is " << outputFOESize[0]);
" but patch size (x) is " << outputPatchSize[0]);
}
if (refRegion.GetSize(1) / outputFOESize[1] != this->GetNumberOfSamples())
if (refRegion.GetSize(1) != this->GetNumberOfSamples() * outputPatchSize[1])
{
itkExceptionMacro("Reference image " << i << " height is " << refRegion.GetSize(1) <<
" but field of expression width is " << outputFOESize[1] <<
" but patch size (y) is " << outputPatchSize[1] <<
" which is not consistent with the number of samples (" << this->GetNumberOfSamples() << ")");
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment