Ask Your Question

dkurtaev's profile - activity

2020-09-28 10:24:43 -0600 received badge  Student (source)
2017-08-24 08:34:16 -0600 commented question Keras -> TensorFlow -> OpenCV/dnn

We support batch normalization which was serialized in fused mode. You may find test case here: https://github.com/opencv/opencv_extr.... Instead is_training=False you may replace False by variable and set to True during training and False before serialization.

2017-08-24 00:27:03 -0600 commented question Keras -> TensorFlow -> OpenCV/dnn
2017-08-22 06:57:28 -0600 commented question DNN performance on mobile platforms

Hi, @Jaykob! Unfortunately, I haven't experimented with DNN on mobile platforms but I can tell you that TensorFlow (+ Eigen computational backend by default) on CPU is definitely faster. In example, Inception-5h in TF takes 17.9ms versus 19.58ms in DNN. On the other hand, you'd like to run your model on GPU (using OpenCL, if it possible) to save power, in example. DNN is going to has some OpenCL backends (libdnn and Halide). I don't know if TensorFlow supports OpenCL. We're interested to know, what kind of layers are still required for you to extend TensorFlow importer as fast as it possible. Please, keep in touch with your decision. May be it will be the first time I run model on mobile device to help you =)

2017-08-17 06:01:54 -0600 commented question Are Microsoft CNTK models going to be supported in the DNN module anytime soon?

Am I right that you want to achieve faster training? Because this benchmarks seems to me about it. Let me help you with making a decision. If you train you model in TensorFlow you have to spend more time for training (according to benchmark) but (+1) you may convert it to CNTK format (using their tools), (+2) run it in OpenCV right now. But if you train model in CNTK you have only faster training time. I haven't found CNTK->TF converter and OpenCV is not supports it. So, model trained in CNTK seems to be used inside CNTK. If training time is critical, you'd better you CNTK.

2017-08-17 05:26:40 -0600 commented question Are Microsoft CNTK models going to be supported in the DNN module anytime soon?

Hm, may I ask a question? What do you mean by "pick the one that performs better for each specific case"?

2017-08-16 01:07:59 -0600 commented question Are Microsoft CNTK models going to be supported in the DNN module anytime soon?

Hi, @xgirones! First of all we need to know that mentioned framework will be interesting for computer vision community. Feel free to do a research: find interesting models trained in CNTK. We'll use it for tests and tutorials.

2017-08-02 04:58:12 -0600 commented question Tensorflow YOLO module in OpenCV 3.2

We've prepared some version of Pad operation at PR #9287. But there are some restrictions: only one dimension might be padded and only "from the right side". Could you try it?

2017-05-29 05:02:54 -0600 commented answer Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in parseTorchType

@anomaly_, I've prepared PR with bugfix. Problem was in layer size computation after reshape. If you don't want to wait it, you could fix it by replacing layer Reshape(7*7*32) to Reshape(7*7*32, true)like the LogSoftMax (no training require, just load model and replace layer). See https://github.com/torch/nn/blob/mast... again, Thank you for your contribution!

2017-05-28 11:17:33 -0600 commented answer Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in parseTorchType

Please give me a trained model if you have one.

2017-05-28 11:13:57 -0600 commented question How to remove video file in opencv

It doesn't matter what kind of files you're going to remove. Moreover it's not an OpenCV issue. If I understood you correctly, try to look at Java documentation. Fortunately, Java supports file system operations natively.

2017-05-28 10:45:19 -0600 commented answer Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in parseTorchType

I'm very sorry but I have no idea what size of A1.jpg is.

2017-05-28 02:10:44 -0600 commented answer Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in parseTorchType

It were be easier if you could provide link to code with DNN invocation too. Thanks!

2017-05-28 02:07:11 -0600 received badge  Enthusiast
2017-05-27 05:33:41 -0600 commented answer Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in parseTorchType

Probably you put input blob with incorrect size. What architecture do you use? What image size you have been trying to process?

2017-05-26 13:46:31 -0600 commented answer Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in parseTorchType

You'd better follow sample with importing model from torch. Use net.setBlob("", inputBlob);. According to https://github.com/opencv/opencv_cont....

2017-05-25 08:37:43 -0600 commented answer Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in parseTorchType

If you have Torch, you can load model. Try net = torch.load('model.net'). Then apply changes and save again.

2017-05-25 03:35:21 -0600 commented answer Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in parseTorchType

You are right, but you can do it just for run your model using OpenCV. Train model in Torch as usual but save without LogSoftMax for evaluating needs. By the way, do you remember that OpenCV doesn't provide networks training, only evaluation?

2017-05-24 13:12:12 -0600 commented question Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in parseTorchType

@anomaly_, I'm sorry. Some problems with website and my answers gone. Firstly, I have recommended you to convert your model to CPU mode by net = net:float(). For solve issue with LogSoftMax you could try to remove this layer or replace it to Identity. It's correct because LogSoftMax is a monotonic function. It means that for all A > B: LogSoftMax(A) > LogSoftMax(B). So for model deployment you can just use data from layer before LogSoftMax. Moreover it's better for efficiency.

2016-12-27 00:20:42 -0600 received badge  Editor (source)
2016-12-26 07:49:06 -0600 commented question Canny using separate functions

I have found this article with "Linking of the Anchors by Smart Routing" procedure. I will try it.

2016-12-26 03:49:33 -0600 asked a question Canny using separate functions

Hi! I've tried to write Canny edge detector using OpenCV's functions for better understanding. As I can see, my own pipeline has wrong results after non-maximum suppression.

  cv::GaussianBlur(input, blur, cv::Size(5, 5), 1.4, 1.4);
  cv::Sobel(blur, dx, CV_32F, 1, 0, 3);
  cv::Sobel(blur, dy, CV_32F, 0, 1, 3);
  cv::cartToPolar(dx, dy, magnitudes, angles);

  cv::Mat edges = cv::Mat::zeros(img.size(), CV_8UC1);
  for (int y = 1; y < angles.rows - 1; ++y) {
    for (int x = 1; x < angles.cols - 1; ++x) {
      float a = angles.at<float>(y, x);
      float m = magnitudes.at<float>(y, x);
      if (a > CV_PI) {
        a -= CV_PI;
      }

      if (a < CV_PI / 8 || a > CV_PI - CV_PI / 8) {
        if (m > magnitudes.at<float>(y, x + 1) &&
            m > magnitudes.at<float>(y, x - 1)) {
          edges.at<uint8_t>(y, x) = 255;
        }
      } else if (a < 0.5f * CV_PI - CV_PI / 8) {
        if (m > magnitudes.at<float>(y - 1, x + 1) &&
            m > magnitudes.at<float>(y + 1, x - 1)) {
          edges.at<uint8_t>(y, x) = 255;
        }
      } else if (a < 0.5f * CV_PI + CV_PI / 8) {
        if (m > magnitudes.at<float>(y - 1, x) &&
            m > magnitudes.at<float>(y + 1, x)) {
          edges.at<uint8_t>(y, x) = 255;
        }
      } else {
        if (m > magnitudes.at<float>(y - 1, x - 1) &&
            m > magnitudes.at<float>(y + 1, x + 1)) {
          edges.at<uint8_t>(y, x) = 255;
        }
      }
    }
  }

Float32 input.
image description

OpenCV's Canny output

cv::Canny(input, output, 100, 200, 3, true);

image description

My
image description

Next steps of method only reduces number of edge pixels. Thus my mistake already here.
Based on OpenCV 3.2.x doc and OpenCV 2.4.x doc.
Version of Opencv: 3.1.0-dev

Please tell me if I have obvious misunderstanding. Thanks!


Update: Problem solved, removed gaussian blur (not used in OpenCV's implementation) and edited conditions (two '>' replaced to '>=' and swapped diagonals).

  cv::Sobel(blur, dx, CV_32F, 1, 0, 3);
  cv::Sobel(blur, dy, CV_32F, 0, 1, 3);
  cv::cartToPolar(dx, dy, magnitudes, angles);

  cv::Mat edges = cv::Mat::zeros(img.size(), CV_8UC1);
  for (int y = 1; y < angles.rows - 1; ++y) {
    for (int x = 1; x < angles.cols - 1; ++x) {
      float a = angles.at<float>(y, x);
      float m = magnitudes.at<float>(y, x);
      if (a > CV_PI) {
        a -= CV_PI;
      }

      if (a < CV_PI / 8 || a > CV_PI - CV_PI / 8) {
        if (m >= magnitudes.at<float>(y, x + 1) &&
            m > magnitudes.at<float>(y, x - 1)) {
          edges.at<uint8_t>(y, x) = 255;
        }
      } else if (a < 0.5f * CV_PI - CV_PI / 8) {
        if (m > magnitudes.at<float>(y - 1, x - 1) &&
            m > magnitudes.at<float>(y + 1, x + 1)) {
          edges.at<uint8_t>(y, x) = 255;
        }
      } else if (a < 0.5f * CV_PI + CV_PI / 8) {
        if (m > magnitudes.at<float>(y - 1, x) &&
            m >= magnitudes.at<float>(y + 1, x)) {
          edges.at<uint8_t>(y, x) = 255;
        }
      } else {
        if (m > magnitudes.at<float>(y - 1, x + 1) &&
            m > magnitudes.at<float>(y + 1, x - 1)) {
          edges.at<uint8_t>(y, x) = 255;
        }
      }
    }
  }