From b955e9504e5fa2dd0f23bbb9d85d56f5e1fee6b5 Mon Sep 17 00:00:00 2001 From: Meghpal <40922889+Meghpal@users.noreply.github.com> Date: Fri, 24 Dec 2021 13:13:55 +0530 Subject: [PATCH] dtype handling for labels in the map file --- python-package/SLIM/core.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python-package/SLIM/core.py b/python-package/SLIM/core.py index a452c79..b9622ce 100755 --- a/python-package/SLIM/core.py +++ b/python-package/SLIM/core.py @@ -625,10 +625,11 @@ def save_model(self, modelfname, mapfname): else: raise RuntimeError("Not exist a model to save.") - def load_model(self, modelfname, mapfname): + def load_model(self, modelfname, mapfname, map_dtype=np.int32): ''' @brief load a model @params modelfname: filename of the model mapfname: filename of the item map + map_dtype: data type of the map labels @return None ''' # if there is a model, destruct the model @@ -641,7 +642,7 @@ def load_model(self, modelfname, mapfname): byref(self.handle), c_char_p(modelfname.encode('utf-8'))) try: - self.id2item = np.genfromtxt(mapfname, dtype=np.int32) + self.id2item = np.genfromtxt(mapfname, dtype=map_dtype) except: self.id2item = np.genfromtxt(mapfname) self.item2id = {}