Wrong input layer size in TrainImagesRegression using the ANN classifier
Description
This bug was reported by a user on the forum
The input layer of the output model produced TrainImagesRegression
when using the artificial neural network classifier (ann
) always has a size of 1, when it should match the number of bands of the input image. The training does not fail, and a mse is computed. However awhen trying to use the model with ImageRegression
an error is thrown by OpenCV:
(FATAL) ImageRegression: itk::ERROR: MultiThreader(000001D5109CC040): Exception occurred during SingleMethodExecute OpenCV(4.1.1) C:\build\otb\build\OPENCV\src\OPENCV\modules\ml\src\ann_mlp.cpp:350: error: (-215:Assertion failed) (type == CV_32F || type == CV_64F) && inputs.cols == layer_sizes[0] in function ‘cv::ml::ANN_MLPImpl::predict’
Note that training an artificial neural network model with TrainVectorRegression
works correctly, so the problem is likely located in TrainImagesRegression
. Also note that TrainImagesClassifier
works correctly whn trying to train an artificial neural network for classification.
Steps to reproduce
otbcli_TrainImagesRegression -io.il input.tif -io.ip "predicted_values.tif" -io.out model.txt -classifier ann -classifier.ann.sizes 10
otbcli_ImageRegression -in input.tif -model model.txt -out out.tif
leads to the following model :
%YAML:1.0
---
opencv_ml_ann_mlp:
format: 3
layer_sizes: [ 1, 10, 1 ]
[...]
but the input image has 4 bands.
Configuration information
OTB 7.2, reproduced on Windows 10 and Ubuntu 16.04