From e9a443fd3b2bf15d856b49fcc68e06252fed1eff Mon Sep 17 00:00:00 2001
From: Remi Cresson <remi.cresson@inrae.fr>
Date: Thu, 6 Apr 2023 00:06:59 +0200
Subject: [PATCH] ADD: no-data support

---
 include/otbTensorflowMultisourceModelBase.hxx | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/otbTensorflowMultisourceModelBase.hxx b/include/otbTensorflowMultisourceModelBase.hxx
index 15e8dbe..f0d414b 100644
--- a/include/otbTensorflowMultisourceModelBase.hxx
+++ b/include/otbTensorflowMultisourceModelBase.hxx
@@ -132,11 +132,12 @@ TensorflowMultisourceModelBase<TInputImage, TOutputImage>::RunSession(DictType &
     inputs_new.emplace_back(m_InputLayers[k], inputTensor);
     if (m_InputUseNodata[k] == true)
     {
-      tensorflow::int64 ndCount = 0;
+      const auto nodataValue = m_InputNodataValues[k];
       const tensorflow::int64 nElmT = inputTensor.NumElements();
+      tensorflow::int64 ndCount = 0;
       auto array = inputTensor.flat<InternalPixelType>();
       for (tensorflow::int64 i = 0 ; i < nElmT ; i++)
-        if (array(i) == m_InputNodataValues[k])
+        if (array(i) == nodataValue)
           ndCount++;
       if (ndCount == nElmT)
       {
-- 
GitLab