Ask Your Question

anomaly_'s profile - activity

2017-05-31 13:21:05 -0600 received badge  Scholar (source)
2017-05-31 07:48:36 -0600 commented answer How to store negative float values in Mat object?

Ohh! Got it, Thanks a lot :)

2017-05-31 07:40:32 -0600 asked a question How to store negative float values in Mat object?

Why am I not able to do this?

Mat img = Mat(4,4, CV_32FC3);
img.at<Vec3b>(0,0)[0] = -1;
img.at<Vec3b>(0,1)[0] = -0.5;

When I display the Mat object, it shows 255 in place of -1. I want to have all of my pixel values in the range of -1 to 1. How can I achieve that?

2017-05-29 06:42:09 -0600 commented answer Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in parseTorchType

Thanks a lot @dkurtaev . It finally worked! :D

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

This is the link to my trained model http://s000.tinyupload.com/index.php?...

This is the link to my modified model, from which Softmax layer has been deleted: http://s000.tinyupload.com/index.php?...

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

256x256 pixels. You can un-comment https://gist.github.com/nitinkgp23/ff... , to make sure it is 256x256 pixels.

2017-05-28 08:04:27 -0600 commented answer Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in parseTorchType

This is the link to the cpp file https://gist.github.com/nitinkgp23/ff...

and this is the link to data.lua file, that reads data: https://gist.github.com/nitinkgp23/42...

and this is run.lua, the main file that is to be run https://gist.github.com/nitinkgp23/07...

After saving the model, there is another file modify.lua that reads the saved model, replaces the softmax layer with identity, and saves it back.

Thanks a lot.

2017-05-28 00:59:25 -0600 received badge  Enthusiast
2017-05-27 16:10:29 -0600 commented answer Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in parseTorchType

This is a link to my model.lua file https://gist.github.com/nitinkgp23/1a... It is a 2 class classification problem. I am inputting a 256x256 size image. How do I know whether I put the input blob with incorrect size? Please tell me if I need to provide any other info. I really have to get this done :(

2017-05-27 01:59:29 -0600 commented answer Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in parseTorchType

Hey, sorry if I am becoming a pain, but I really need to make through this. Any help will be highly appreciated. I did as described in the torch tutorial, but in net.forward() , I get this error : OpenCV Error: Assertion failed ((size_t)innerSize == innerSize0) in allocate, file /home/anomaly_/opencv-base/opencv_contrib/modules/dnn/src/layers/fully_connected_layer.cpp, line 89

2017-05-26 07:18:08 -0600 commented answer Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in parseTorchType

I am stuck with another issue. I was following the dnn tutorial for caffe, and I found a line net.setBlob(".data", inputBlob) to set the input blob. But in torch, since there is no prototxt file, how do I set the input blob? I did net.setBlob("l1_Convolution", inputBlob);where "l1_Convolution" is the name of my first layer. But this throws an error that I have described here http://answers.opencv.org/question/15...

2017-05-26 07:13:12 -0600 received badge  Editor (source)
2017-05-26 06:48:08 -0600 asked a question Error while making a forward pass using net.forward()

I have the following lines of code :

Mat inputBlob = blobFromImage(img);   // img is the image file read by opencv
net.setBlob("l1_Convolution", inputBlob);   // "l1_convolution" is the name of my first layer
net.forward();

After executing the third line, I get the following error:

OpenCV Error: Assertion failed (input.dims == 4 && (input.type() == CV_32F || input.type() == CV_64F)) in allocate, file /home/anomaly_/opencv-base/opencv_contrib/modules/dnn/src/layers/convolution_layer.cpp, line 81

I found out the line where the code was breaking and I did the assertion in my main function:

CV_Assert(inputBlob.dims == 4 && (inputBlob.type() == CV_32F || inputBlob.type() == CV_64F));

which passed successfully. What can be the reason for the code failing? Is the input in convolution_layer.cpp different from inputBlob in main function? Or is there something wrong with the line net.setBlob("l1_Convolution", inputBlob); ?

Please help.

2017-05-26 03:22:54 -0600 commented answer Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in parseTorchType

It worked! Thanks a lot! :)

2017-05-25 07:34:14 -0600 commented answer Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in parseTorchType

Yes, I know that openCV supports only evaluation. But, how do I save the model without the LogSoftMax function? After training the model from torch, I get a model.net file, which I want to import in openCV. So, how do I modify this binary file?

2017-05-25 01:16:40 -0600 commented answer Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in parseTorchType

Thanks @dkurtaev, but I will be glad if you could help me out a bit more. I understand that LogSoftMax can be replaced by Identity, but that can be done only in the eval mode right? We will need to have the LogSoftMax function during training. So, how do I modify the layers on the basis of which mode the model is working in? If I simply remove the softmax function or replace it with identity, the model won't converge.

2017-05-24 06:30:12 -0600 commented answer Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in parseTorchType

Hello, I did as told, and saved the model in CPU mode. But, that error went away, and a new one came Unknown nn class "nn.LogSoftMax" in function readTorchObject I assume this class is not yet supported yet. Can you provide me an alternative?

2017-05-17 11:20:17 -0600 asked a question Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in parseTorchType

I have a trained torch model that I am trying to import in OpenCV. Upon importing the model by

dnn::Net net = dnn::readNetFromTorch(modelFile);

I get the following error:

OpenCV Error: The function/feature is not implemented (Unknown type "CudaLong" of torch class "torch.CudaLongTensor") in parseTorchType, file /home/anomaly_/opencv-base/opencv_contrib/modules/dnn/src/torch/torch_importer.cpp, line 213 terminate called after throwing an instance of 'cv::Exception' what(): /home/anomaly_/opencv-base/opencv_contrib/modules/dnn/src/torch/torch_importer.cpp:213: error: (-213) Unknown type "CudaLong" of torch class "torch.CudaLongTensor" in function parseTorchType

Why do I get this error? Is it because of my trained model? What should I do so that my model is successfully imported?

I am using the latest opencv and opencv_contrib module.