Merge pull request #25660 from Abdurrahheem:ash/fix-slice-empty-input

Slice layer parser fix to support empty input case #25660

This PR fixes Slice Layer's parser to handle empty input cases (cases with initializer)
It fixed the issue rased in #24838

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Abduragim Shtanchaev 2024-05-31 14:13:36 +04:00 committed by GitHub
parent f4ebf7c0a6
commit d7f04a9d33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1202,7 +1202,12 @@ void ONNXImporter::parseReduce(LayerParams& layerParams, const opencv_onnx::Node
void ONNXImporter::parseSlice(LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto)
{
MatShape inpShape = outShapes[node_proto.input(0)];
MatShape inpShape;
if (constBlobs.find(node_proto.input(0)) != constBlobs.end())
inpShape = shape(getBlob(node_proto, 0));
else {
inpShape = outShapes[node_proto.input(0)];
}
int dims = inpShape.size();
std::vector<int> begin(dims, 0);
std::vector<int> end(dims, INT_MAX);