Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New dnn engine #3794

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions modules/dnn_superres/src/dnn_superres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class DepthToSpace CV_FINAL : public cv::dnn::Layer

static cv::Ptr<cv::dnn::Layer> create(cv::dnn::LayerParams& params);

virtual bool getMemoryShapes(const std::vector<std::vector<int> > &inputs,
virtual bool getMemoryShapes(const std::vector<MatShape> &inputs_,
const int,
std::vector<std::vector<int> > &outputs,
std::vector<std::vector<int> > &) const CV_OVERRIDE;
std::vector<MatShape> &outputs_,
std::vector<MatShape> &) const CV_OVERRIDE;

virtual void forward(cv::InputArrayOfArrays inputs_arr,
cv::OutputArrayOfArrays outputs_arr,
Expand Down Expand Up @@ -308,39 +308,39 @@ cv::Ptr<cv::dnn::Layer> DepthToSpace::create(cv::dnn::LayerParams &params)
return cv::Ptr<cv::dnn::Layer>(new DepthToSpace(params));
}

bool DepthToSpace::getMemoryShapes(const std::vector <std::vector<int>> &inputs,
const int, std::vector <std::vector<int>> &outputs, std::vector <std::vector<int>> &) const
bool DepthToSpace::getMemoryShapes(const std::vector <MatShape> &inpShapes,
const int, std::vector <MatShape> &outShapes, std::vector <MatShape> &) const
{
std::vector<int> outShape(4);
MatShape outShape(4);

int scale;
if( inputs[0][1] == 4 || inputs[0][1] == 9 || inputs[0][1] == 16 ) //Only one image channel
if( inpShapes[0][1] == 4 || inpShapes[0][1] == 9 || inpShapes[0][1] == 16 ) //Only one image channel
{
scale = static_cast<int>(sqrt(inputs[0][1]));
scale = static_cast<int>(sqrt(inpShapes[0][1]));
}
else // Three image channels
{
scale = static_cast<int>(sqrt(inputs[0][1]/3));
scale = static_cast<int>(sqrt(inpShapes[0][1]/3));
}

outShape[0] = inputs[0][0];
outShape[1] = static_cast<int>(inputs[0][1] / pow(scale,2));
outShape[2] = static_cast<int>(scale * inputs[0][2]);
outShape[3] = static_cast<int>(scale * inputs[0][3]);
outShape[0] = inpShapes[0][0];
outShape[1] = static_cast<int>(inpShapes[0][1] / pow(scale,2));
outShape[2] = static_cast<int>(scale * inpShapes[0][2]);
outShape[3] = static_cast<int>(scale * inpShapes[0][3]);

outputs.assign(4, outShape);
outShapes.assign(1, outShape);

return false;
}

void DepthToSpace::forward(cv::InputArrayOfArrays inputs_arr, cv::OutputArrayOfArrays outputs_arr,
cv::OutputArrayOfArrays)
{
std::vector <cv::Mat> inputs, outputs;
inputs_arr.getMatVector(inputs);
outputs_arr.getMatVector(outputs);
cv::Mat &inp = inputs[0];
cv::Mat &out = outputs[0];
std::vector <cv::Mat> inputs_, outputs_;
inputs_arr.getMatVector(inputs_);
outputs_arr.getMatVector(outputs_);
cv::Mat &inp = inputs_[0];
cv::Mat &out = outputs_[0];
const float *inpData = (float *) inp.data;
float *outData = (float *) out.data;

Expand Down
4 changes: 2 additions & 2 deletions modules/text/src/ocr_holistic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ class OCRHolisticWordRecognizerImpl CV_FINAL : public OCRHolisticWordRecognizer
size_t getClassCount()
{
int id = net.getLayerId("prob");
dnn::MatShape inputShape;
MatShape inputShape;
inputShape.push_back(1);
inputShape.push_back(1);
inputShape.push_back(getPerceptiveField().height);
inputShape.push_back(getPerceptiveField().width);
vector<dnn::MatShape> inShapes, outShapes;
vector<MatShape> inShapes, outShapes;
net.getLayerShapes(inputShape, CV_32F, id, inShapes, outShapes);
CV_Assert(outShapes.size() == 1 && outShapes[0].size() == 4);
CV_Assert(outShapes[0][0] == 1 && outShapes[0][2] == 1 && outShapes[0][3] == 1);
Expand Down
Loading