From f574c1bf8e813bbe3da2eb8162c072fa69b51c57 Mon Sep 17 00:00:00 2001
From: "Daniel.Frisinghelli" <daniel.frisinghelli@eurac.edu>
Date: Thu, 18 Feb 2021 16:38:06 +0100
Subject: [PATCH] Adjust counters starting from 0.

---
 pysegcnn/core/trainer.py | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/pysegcnn/core/trainer.py b/pysegcnn/core/trainer.py
index 4e82d54..bc0f11c 100644
--- a/pysegcnn/core/trainer.py
+++ b/pysegcnn/core/trainer.py
@@ -2545,24 +2545,28 @@ class NetworkInference(BaseConfig):
             # check whether to reconstruct the scenes of a dataset
             if self.predict_scene:
 
+                # append model predictions of current batch to scene dictionary
+                for k, v in zip(INFERENCE_NAMES, [inputs, labels, prdctn]):
+                    scenes[k].append(v)
+
                 # check if an entire scene is processed
-                if batch % self.trg_ds.dataset.tiles == 0 and batch != 0:
+                if (batch + 1) % self.trg_ds.dataset.tiles == 0 and batch != 0:
 
                     # convert scene dictionary to numpy arrays
-                    inputs, labels, prdctn = [np.asarray(v) for _, v in
-                                              scenes.items()]
+                    inputs, labels, prdctn = [
+                        np.asarray(v) for _, v in scenes.items()]
 
                     # tiles of the current scene
                     current_tiles = self.trg_ds.indices[
-                        np.arange(batch - self.trg_ds.dataset.tiles, batch)]
+                        np.arange((batch + 1) - self.trg_ds.dataset.tiles,
+                                  batch)]
 
                     # name of the current scene
                     batch = np.unique([self.trg_ds.dataset.scenes[sid]['id']
                                        for sid in current_tiles]).item()
 
                     # modify the progress string
-                    progress = progress.replace('Sample', 'Scene')
-                    progress += ' Id: {}'.format(batch)
+                    progress = 'Scene Id: {}'.format(batch)
 
                     # reconstruct the entire scene
                     inputs = reconstruct_scene(inputs)
@@ -2603,10 +2607,6 @@ class NetworkInference(BaseConfig):
                             self.scenes_path.joinpath(batch_name)),
                             bbox_inches='tight')
 
-                # append model predictions of current batch to scene dictionary
-                for k, v in zip(INFERENCE_NAMES, [inputs, labels, prdctn]):
-                    scenes[k].append(v)
-
             else:
                 # save current batch to output dictionary
                 output[batch] = {k: v for k, v in zip(INFERENCE_NAMES,
-- 
GitLab