Closed turowicz closed 5 years ago
my code:
private (int Id, double Probability) Predict(Mat blob, string[] labels, Net net)
{
net.SetInput(blob, "data");
using (var predictions = net.Forward("prob"))
{
GetMaxClass(predictions, out int classId, out double classProb);
return (classId, classProb);
}
}
private void GetMaxClass(Mat probBlob, out int classId, out double classProb)
{
using (var probMat = probBlob.Reshape(1, 1))
{
Cv2.MinMaxLoc(probMat, out _, out classProb, out _, out var classNumber);
classId = classNumber.X;
}
}
cc @shimat
Did you try setPreferableTarget
and/or setPreferableBackend
?
I'm sorry but I'm not familiar with dnn. Their implementation in OpenCvSharp is halfway. The enum flags are not defined.
net.SetPreferableTarget(1); // DNN_TARGET_OPENCL
@shimat thank you I will try that
Using setPreferableTarget(1)
sorted out the problem.
Using setPreferableBackend
together with setPreferableTarget
resulted in an error.
Problem solved @shimat, thanks!
@turowicz have you since tried this with latest opencvsharp4? @shimat or would it no longer work in opencvsharp4 because you dropped gpu support there?
i try to understand if the OpenCL support for DNN is probably independent of the general opencv CUDA support and therefore should work also with opencvsharp4?
@joreg I'm still on 3.4.x because I'm using a lot of frameworks that depend on it. Dlib, Tensorflow and others.
I'm on OpenCvSharp 3.x and OpenCV 3.x compiled with GPU.
I've rewritten the following article in C# and am using the models the original paper author has published:
https://itywik.org/2018/03/26/age-and-gender-detection-with-opencv-on-the-raspberry-pi/
My question is about performance. Running these predictions takes around 100ms each, which is way slower in comparison to running FaceRecognition by @takuya-takeuchi.
Question Should I be investigating the performance issues or is it a normal processing time of raster data?