|
|
@ -95,21 +95,19 @@ class LearningBasedWBImpl : public LearningBasedWB |
|
|
|
palette_size = 300; |
|
|
|
palette_size = 300; |
|
|
|
palette_bandwidth = 0.1f; |
|
|
|
palette_bandwidth = 0.1f; |
|
|
|
prediction_thresh = 0.025f; |
|
|
|
prediction_thresh = 0.025f; |
|
|
|
if (path_to_model.empty()) |
|
|
|
/* try to load model from file */ |
|
|
|
|
|
|
|
FileStorage fs; |
|
|
|
|
|
|
|
if (!path_to_model.empty() && fs.open(path_to_model, FileStorage::READ)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
/* use the default model */ |
|
|
|
if (fs["num_trees"].isReal()) { //workaround for #10506
|
|
|
|
num_trees = _num_trees; |
|
|
|
double nt = fs["num_trees"]; |
|
|
|
num_tree_nodes = _num_tree_nodes; |
|
|
|
num_trees = int(nt); |
|
|
|
feature_idx = _feature_idx; |
|
|
|
double ntn = fs["num_tree_nodes"]; |
|
|
|
thresh_vals = _thresh_vals; |
|
|
|
num_tree_nodes = int(ntn); |
|
|
|
leaf_vals = _leaf_vals; |
|
|
|
} else { |
|
|
|
} |
|
|
|
num_trees = fs["num_trees"]; |
|
|
|
else |
|
|
|
num_tree_nodes = fs["num_tree_nodes"]; |
|
|
|
{ |
|
|
|
} |
|
|
|
/* load model from file */ |
|
|
|
|
|
|
|
FileStorage fs(path_to_model, 0); |
|
|
|
|
|
|
|
num_trees = fs["num_trees"]; |
|
|
|
|
|
|
|
num_tree_nodes = fs["num_tree_nodes"]; |
|
|
|
|
|
|
|
fs["feature_idx"] >> feature_idx_Mat; |
|
|
|
fs["feature_idx"] >> feature_idx_Mat; |
|
|
|
fs["thresh_vals"] >> thresh_vals_Mat; |
|
|
|
fs["thresh_vals"] >> thresh_vals_Mat; |
|
|
|
fs["leaf_vals"] >> leaf_vals_Mat; |
|
|
|
fs["leaf_vals"] >> leaf_vals_Mat; |
|
|
@ -117,6 +115,15 @@ class LearningBasedWBImpl : public LearningBasedWB |
|
|
|
thresh_vals = thresh_vals_Mat.ptr<float>(); |
|
|
|
thresh_vals = thresh_vals_Mat.ptr<float>(); |
|
|
|
leaf_vals = leaf_vals_Mat.ptr<float>(); |
|
|
|
leaf_vals = leaf_vals_Mat.ptr<float>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
/* use the default model */ |
|
|
|
|
|
|
|
num_trees = _num_trees; |
|
|
|
|
|
|
|
num_tree_nodes = _num_tree_nodes; |
|
|
|
|
|
|
|
feature_idx = _feature_idx; |
|
|
|
|
|
|
|
thresh_vals = _thresh_vals; |
|
|
|
|
|
|
|
leaf_vals = _leaf_vals; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int getRangeMaxVal() const { return range_max_val; } |
|
|
|
int getRangeMaxVal() const { return range_max_val; } |
|
|
|