From 30f99e1fbc1eb670316705a285aa9aa452e98973 Mon Sep 17 00:00:00 2001
From: "Daniel.Frisinghelli" <daniel.frisinghelli@eurac.edu>
Date: Thu, 4 Feb 2021 17:28:16 +0100
Subject: [PATCH] Fixed a bug: Name of the model is now correctly parsed from
 state file name.

---
 pysegcnn/core/models.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/pysegcnn/core/models.py b/pysegcnn/core/models.py
index f35fd29..d37daca 100644
--- a/pysegcnn/core/models.py
+++ b/pysegcnn/core/models.py
@@ -276,11 +276,12 @@ class Network(nn.Module):
 
         """
         # get the model class of the pretrained model
-        model_class = item_in_enum(str(state_file).split('_')[0],
+        state_file = pathlib.Path(state_file)
+        model_class = item_in_enum(str(state_file.stem).split('_')[0],
                                    SupportedModels)
 
         # get the optimizer class of the pretrained model
-        optim_class = item_in_enum(str(state_file).split('_')[1],
+        optim_class = item_in_enum(str(state_file.stem).split('_')[1],
                                    SupportedOptimizers)
 
         # load the pretrained model configuration
-- 
GitLab