From 35a892a4f31c8c4e55ab0a8b80b5d0598a8c5d82 Mon Sep 17 00:00:00 2001 From: remi cresson <remi.cresson@teledetection.fr> Date: Fri, 31 Aug 2018 15:14:57 +0000 Subject: [PATCH] REFAC: wip#3 --- app/otbImageClassifierFromDeepFeatures.cxx | 8 ++-- app/otbTensorflowModelServe.cxx | 44 +++++++++---------- app/otbTensorflowModelTrain.cxx | 4 +- app/otbTrainClassifierFromDeepFeatures.cxx | 3 +- .../otbTensorflowMultisourceModelValidate.hxx | 27 ++++++------ 5 files changed, 43 insertions(+), 43 deletions(-) diff --git a/app/otbImageClassifierFromDeepFeatures.cxx b/app/otbImageClassifierFromDeepFeatures.cxx index b699a02..5f76322 100644 --- a/app/otbImageClassifierFromDeepFeatures.cxx +++ b/app/otbImageClassifierFromDeepFeatures.cxx @@ -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" ); diff --git a/app/otbTensorflowModelServe.cxx b/app/otbTensorflowModelServe.cxx index 14d0d7c..84cc692 100644 --- a/app/otbTensorflowModelServe.cxx +++ b/app/otbTensorflowModelServe.cxx @@ -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 diff --git a/app/otbTensorflowModelTrain.cxx b/app/otbTensorflowModelTrain.cxx index e6c979e..9adf498 100644 --- a/app/otbTensorflowModelTrain.cxx +++ b/app/otbTensorflowModelTrain.cxx @@ -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)"; diff --git a/app/otbTrainClassifierFromDeepFeatures.cxx b/app/otbTrainClassifierFromDeepFeatures.cxx index e54d572..d1377e8 100644 --- a/app/otbTrainClassifierFromDeepFeatures.cxx +++ b/app/otbTrainClassifierFromDeepFeatures.cxx @@ -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" ); diff --git a/include/otbTensorflowMultisourceModelValidate.hxx b/include/otbTensorflowMultisourceModelValidate.hxx index 31047f3..a8b5a32 100644 --- a/include/otbTensorflowMultisourceModelValidate.hxx +++ b/include/otbTensorflowMultisourceModelValidate.hxx @@ -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() << ")"); } } -- GitLab