Comments (4)
There is Python code that can be run for "u2net_human_seg. Onnx"
# Inference
net.setInput(blob)
d0 = net.forward()
# Norm
pred = normPred(d0[:, 0, :, :])
There are problems in rewriting to C + +. My code is like this
Mat inputBlob = blobFromImages(src, 1.0/255.0, Size(320, 320),Scalar(), true, false);
net.setInput(inputBlob);
Mat prob = net.forward();
The error echo is:
“[ INFO:0] global E:\Gitee\opencv_2021\opencv\modules\dnn\src\onnx\onnx_importer.cpp (395) cv::dnn::dnn4_v20201117::ONNXImporter::populateNet DNN/ONNX: loading ONNX v6 model produced by 'pytorch':1.8. Number of nodes = 1055, inputs = 1, outputs = 7
OpenCV(4.5.1-dev) Error: Assertion failed (total(os[i]) > 0) in cv::dnn::dnn4_v20201117::Net::Impl::getLayerShapesRecursively, file E:\Gitee\opencv_2021\opencv\modules\dnn\src\dnn.cpp, line 3520”
I tried to do some research, but I can't find the reason. I hope I can help with C + + calling. Thanks!
from opencv_zoo.
Can you provide the related cpp files so that I can help debugging?
from opencv_zoo.
OK,cpp code is simple
#include <iostream>
#include "opencv2/dnn.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/objdetect.hpp"
using namespace cv;
using namespace std;
using namespace cv::dnn;
int main(int argc, char ** argv)
{
Net net = readNetFromONNX("e:/template/u2net_human_seg.onnx");
Mat src = imread("e:/template/lena.jpg");
if (net.empty()) {
printf("read model data failure...\n");
return -1;
}
Mat inputBlob = blobFromImages(src, 1.0/255.0, Size(320, 320),Scalar(), true, false);
net.setInput(inputBlob);
Mat prob = net.forward();
//ERROR
/*
[ INFO:0] global E:\Gitee\opencv_2021\opencv\modules\dnn\src\onnx\onnx_importer.cpp (395) cv::dnn::dnn4_v20201117::ONNXImporter::populateNet DNN/ONNX: loading ONNX v6 model produced by 'pytorch':1.8. Number of nodes = 1055, inputs = 1, outputs = 7
OpenCV(4.5.1-dev) Error: Assertion failed (total(os[i]) > 0) in cv::dnn::dnn4_v20201117::Net::Impl::getLayerShapesRecursively, file E:\Gitee\opencv_2021\opencv\modules\dnn\src\dnn.cpp, line 3520”
*/
return 0;
}
I think this is the same as this Python code
net = cv.dnn.readNet(args.model)
input_size = 320 # fixed
# build blob using OpenCV
img = cv.imread(args.input)
blob = cv.dnn.blobFromImage(img, scalefactor=(1.0/255.0), size=(input_size, input_size), swapRB=True)
# Inference
net.setInput(blob)
d0 = net.forward()
from opencv_zoo.
hello, Is your problem solved?
from opencv_zoo.
Related Issues (20)
- VitTracker weights (question) HOT 10
- Mediapipe pose estimation performance HOT 5
- Refreshing template in Vit (Question) HOT 4
- Dynamic Input Shape? HOT 2
- Lack of charsets in models\text_recognition_crnn HOT 8
- `quantize-ort.py` doesn't reproduce the quantized models in the repos HOT 3
- Is it possible to parallelize face detection process using the face_detection_yunet model in C++? HOT 6
- How to process output of face detection network when batch of images is used as network input? HOT 7
- SFace: Quantized model is slower HOT 2
- 为什么输入的两张相同的图片经过处理以后维度会不一样 HOT 10
- 求助求助,随便选两个图片对比的相似度都很高。 HOT 3
- Add Java demos (Last update on 2024-04-07) HOT 4
- I can't run the yunet_2023mar in OpenCV4.9.0 HOT 2
- Face Anti-Spoofing opencv HOT 1
- 总是报错 HOT 1
- 奇怪的问题 HOT 1
- SFaceRecognizer model face recognition C++ test failed HOT 2
- VitTracker crush HOT 12
- the issue of quantification HOT 1
- Efficient SAM is not compliant with onnx standard
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opencv_zoo.