diff --git a/app/otbTensorflowModelServe.cxx b/app/otbTensorflowModelServe.cxx index 47a8c95730443c0c3345933d71f63a1bcbcb556d..1a91cd86b2eaa492cd7aaa8cff9bd84fba20e77d 100644 --- a/app/otbTensorflowModelServe.cxx +++ b/app/otbTensorflowModelServe.cxx @@ -70,11 +70,14 @@ public: InputImageSource m_ImageSource; SizeType m_PatchSize; std::string m_Placeholder; + float m_NodataValue; + bool m_HasNodata; // Parameters keys std::string m_KeyIn; // Key of input image list - std::string m_KeyPszX; // Key for samples sizes X - std::string m_KeyPszY; // Key for samples sizes Y + std::string m_KeyPszX; // Key for receptive field size in X + std::string m_KeyPszY; // Key for receptive field size in Y + std::string m_KeyND; // Key for no-data value std::string m_KeyPHName; // Key for placeholder name in the tensorflow model }; @@ -93,7 +96,8 @@ public: ss_key_in, ss_desc_in, ss_key_dims_x, ss_desc_dims_x, ss_key_dims_y, ss_desc_dims_y, - ss_key_ph, ss_desc_ph; + ss_key_ph, ss_desc_ph, + ss_key_nd, ss_desc_nd; // Parameter group key/description ss_key_group << "source" << inputNumber; @@ -104,12 +108,14 @@ public: 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"; + ss_key_nd << ss_key_group.str() << ".nodata"; // Parameter group descriptions ss_desc_in << "Input image (or list to stack) 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; + ss_desc_nd << "No-data value for pixels of source #" << inputNumber; // Populate group AddParameter(ParameterType_Group, ss_key_group.str(), ss_desc_group.str()); @@ -122,6 +128,8 @@ public: SetDefaultParameterInt (ss_key_dims_y.str(), 1); AddParameter(ParameterType_String, ss_key_ph.str(), ss_desc_ph.str()); MandatoryOff (ss_key_ph.str()); + AddParameter(ParameterType_Float, ss_key_nd.str(), ss_desc_nd.str()); + MandatoryOff (ss_key_nd.str()); // Add a new bundle ProcessObjectsBundle bundle; @@ -129,6 +137,7 @@ public: bundle.m_KeyPszX = ss_key_dims_x.str(); bundle.m_KeyPszY = ss_key_dims_y.str(); bundle.m_KeyPHName = ss_key_ph.str(); + bundle.m_KeyND = ss_key_nd.str(); m_Bundles.push_back(bundle); @@ -236,10 +245,14 @@ public: bundle.m_Placeholder = GetParameterAsString(bundle.m_KeyPHName); bundle.m_PatchSize[0] = GetParameterInt(bundle.m_KeyPszX); bundle.m_PatchSize[1] = GetParameterInt(bundle.m_KeyPszY); + bundle.m_HasNodata = HasValue(bundle.m_KeyND); + bundle.m_NodataValue = GetParameterFloat(bundle.m_KeyND); otbAppLogINFO("Source info :"); otbAppLogINFO("Receptive field : " << bundle.m_PatchSize ); otbAppLogINFO("Placeholder name : " << bundle.m_Placeholder); + if (bundle.m_HasNodata == true) + otbAppLogINFO("No-data value : " << bundle.m_NodataValue); } } @@ -274,7 +287,8 @@ public: // Input sources for (auto& bundle: m_Bundles) { - m_TFFilter->PushBackInputTensorBundle(bundle.m_Placeholder, bundle.m_PatchSize, bundle.m_ImageSource.Get()); + float nodata = (bundle.m_HasNodata == true) ? bundle.m_NodataValue : 0; + m_TFFilter->PushBackInputTensorBundle(bundle.m_Placeholder, bundle.m_PatchSize, bundle.m_ImageSource.Get(), bundle.m_HasNodata, nodata); } // Fully convolutional mode on/off