Commit 95deb466 authored by Julien Malik's avatar Julien Malik

BUG: emit FATAL error when input model file cannot be loaded

parent 613ef142
......@@ -119,6 +119,12 @@ private:
otbAppLogINFO("Loading model");
m_Model = MachineLearningModelFactoryType::CreateMachineLearningModel(GetParameterString("model"),
MachineLearningModelFactoryType::ReadMode);
if (m_Model.IsNull())
{
otbAppLogFATAL(<< "Error when loading model " << GetParameterString("model") << " : unsupported model type");
}
m_Model->Load(GetParameterString("model"));
otbAppLogINFO("Model loaded");
......
......@@ -214,6 +214,12 @@ void TrainImagesClassifier::Classify(ListSampleType::Pointer validationListSampl
//Classification
ModelPointerType model = MachineLearningModelFactoryType::CreateMachineLearningModel(GetParameterString("io.out"),
MachineLearningModelFactoryType::ReadMode);
if (model.IsNull())
{
otbAppLogFATAL(<< "Error when loading model " << GetParameterString("io.out"));
}
model->Load(GetParameterString("io.out"));
model->SetInputListSample(validationListSample);
model->SetTargetListSample(predictedList);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment