From 073408c73e987197571d7111186fcd0980dc7540 Mon Sep 17 00:00:00 2001
From: "Daniel.Frisinghelli" <daniel.frisinghelli@eurac.edu>
Date: Fri, 5 Feb 2021 14:32:47 +0100
Subject: [PATCH] Scene identifiers are now correctly retrieved.

---
 pysegcnn/core/trainer.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/pysegcnn/core/trainer.py b/pysegcnn/core/trainer.py
index cc805cc..45d6ee2 100644
--- a/pysegcnn/core/trainer.py
+++ b/pysegcnn/core/trainer.py
@@ -54,7 +54,6 @@ from pysegcnn.core.graphics import (plot_loss, plot_confusion_matrix,
 from pysegcnn.core.constants import map_labels
 from pysegcnn.main.train_config import HERE, DRIVE_PATH
 
-
 # module level logger
 LOGGER = logging.getLogger(__name__)
 
@@ -2505,9 +2504,14 @@ class NetworkInference(BaseConfig):
             # check whether to reconstruct the scene
             if self.dataloader.batch_size > 1:
 
-                # id of the current scene
-                current_scene = np.int(batch * self.dataloader.batch_size)
-                batch = self.trg_ds.dataset.scenes[current_scene]['id']
+                # tiles of the current scene
+                current_tiles = self.trg_ds.indices[
+                    np.arange(batch * self.dataloader.batch_size,
+                              (batch + 1) * self.dataloader.batch_size)]
+
+                # name of the current scene
+                batch = np.unique([sid for sid in self.trg_ds.dataset.scenes[
+                    current_tiles]['id']]).item()
 
                 # modify the progress string
                 progress = progress.replace('Sample', 'Scene')
-- 
GitLab