Skip to content
This repository was archived by the owner on Jun 3, 2020. It is now read-only.

Commit 0e5a51a

Browse files
committed
load_model: simplify the model loading with respect to deeposlandia 0.6.2
1 parent 107f22d commit 0e5a51a

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

qdeeplandia.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
QHBoxLayout, QVBoxLayout, QMessageBox, \
2929
QToolBar, QLabel, QCheckBox
3030

31-
os.environ['DEEPOSL_CONFIG']=os.path.join(os.path.dirname(__file__),'config.ini')
32-
from .deeposlandia import postprocess
33-
from .processing_provider.provider import QDeepLandiaProvider
31+
os.environ['DEEPOSL_CONFIG'] = os.path.join(os.path.dirname(__file__), 'config.ini')
32+
from deeposlandia.postprocess import get_trained_model
3433

34+
from .processing_provider.provider import QDeepLandiaProvider
3535
from .gui.NbLabelDialog import NbLabelDialog
3636
from .inferenceTask import InferenceTask
3737

@@ -61,8 +61,6 @@ def __init__(self, iface):
6161
self.layer = self.updateLayer()
6262
self.nb_labels = None
6363
self.model_path = None
64-
self.datapath = None
65-
self.dataset = None
6664

6765
locale = QSettings().value('locale/userLocale') or 'en_USA'
6866
locale = locale[0:2]
@@ -147,12 +145,10 @@ def load_trained_model(self):
147145
self.nb_labels = nbLabelDlg.param()
148146
else :
149147
return
150-
151-
self.datapath = os.path.abspath(os.path.join(os.path.dirname(self.model_path), '..', '..', '..', '..'))
152-
self.dataset = os.path.basename(os.path.abspath(os.path.join(os.path.dirname(self.model_path), '..', '..', '..')))
148+
153149
self.image_size = os.path.splitext(os.path.basename(self.model_path))[0].split('-')[-1]
154150
try :
155-
self.model = postprocess.get_trained_model(self.datapath, self.dataset, int(self.image_size), int(self.nb_labels))
151+
self.model = get_trained_model(self.model_path, int(self.image_size), int(self.nb_labels))
156152
except ValueError as e:
157153
self.iface.messageBar().pushMessage(tr("Critical"),
158154
str(e), level=Qgis.Critical)

0 commit comments

Comments
 (0)