PSPNet icon indicating copy to clipboard operation
PSPNet copied to clipboard

Python or C++ predict scripts?

Open lucasjinreal opened this issue 7 years ago • 16 comments
trafficstars

Hi, is there python or C++ scripts available?

lucasjinreal avatar Jan 13 '18 05:01 lucasjinreal

With python, you can using this script demo.zip

ThienAnh avatar Jan 18 '18 08:01 ThienAnh

Thanks @ThienAnh. That was helpful.

mkarki2 avatar Jan 23 '18 14:01 mkarki2

@ThienAnh Thanks for your code. But there is a problem.

python demo.py Traceback (most recent call last): File "demo.py", line 17, in import caffe File "../python/caffe/init.py", line 1, in from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver File "../python/caffe/pycaffe.py", line 13, in from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver,
ImportError: libmatio.so.2: cannot open shared object file: No such file or directory gzyaoxin@edt-machine02-machine:~/ImageProject/PSPNET-cudnn5/evaluation$ python Python 2.7.9 (default, Jun 29 2016, 13:08:31) [GCC 4.9.2] on linux2 Type "help", "copyright", "credits" or "license" for more information.

import caffe


there are a ImportError about libmatio.so.2 in your code. I have already installed matio and import caffe succesfully when i do not modify sys.path.

But it seems to be a little different between the caffe in this project and official version. So using official version directly cause a other error.

How to solve this problem?

yaoxinthu avatar Jan 30 '18 07:01 yaoxinthu

See your issue in https://github.com/hszhao/PSPNet/issues/14

ThienAnh avatar Jan 30 '18 07:01 ThienAnh

@ThienAnh Thank you very much!

yaoxinthu avatar Jan 30 '18 07:01 yaoxinthu

@YaoXinatTHU you are wellcome

ThienAnh avatar Jan 30 '18 09:01 ThienAnh

@ThienAnh Hi ThienAnh, do you happen to have the prediction code for c++?? :-) Will appreciate your response. Thank you so much!!

Anyone who has a copy of a c++ prediction code can also response by helping me.

pewpewpeww avatar Aug 27 '18 08:08 pewpewpeww

@pewpewpeww I will share c++ code tonight. (Now i had out of office)

ThienAnh avatar Aug 27 '18 08:08 ThienAnh

@pewpewpeww This is code predict sample in c++

PredictSample.zip

ThienAnh avatar Aug 27 '18 16:08 ThienAnh

@ThienAnh Thank you very much for your help!! :-) I referred to the code and realised that it requires a Utility.h file to run. Do you have it too?

pewpewpeww avatar Aug 28 '18 00:08 pewpewpeww

@ThienAnh How the C++ inference speed on CPU?

lucasjinreal avatar Aug 28 '18 07:08 lucasjinreal

@pewpewpeww Utility.h only common funtions for read image, convert string2char. You can ignore it.

@jinfagang I don't test on CPU. (So i think it is very low)

ThienAnh avatar Aug 28 '18 09:08 ThienAnh

@ThienAnh Thank you so much. The code predict sample in c++ works. When i use the function called "predict" , I got a error "Check failed: error == cudaSuccess (2 vs. 0) out of memory" .I know it means my gpu memory may be small (about 11GB) . So i was thinking is there some key words like "batch_size" which i could modified. By the way , I use test prototxt file "pspnet101_cityscapes_713.prototxt" ,but there isn't "batch_size" or something like that .Do you have any idea? Any way , thank you ,thank you,thank you . Hi, I solve this problem by modified input size from 713 to 463 and some kernel and strides. And i got another problem,. when i predict an image ,i got a result without anything just white. Do you have any idea?

cobbwho avatar Mar 21 '19 12:03 cobbwho

@cobbwho default of batch_size is 1. Because if batch_size>1 --> Will be out of memory. An idea for memory, you can split network to 2 or 3 or more parts, but performace will be slow

ThienAnh avatar Mar 21 '19 14:03 ThienAnh

@jinfagang I test a image about 473*473. GPU version use about 0.4s . CPU version use about 6.5s. It's too slow.

cobbwho avatar Mar 22 '19 08:03 cobbwho

@ThienAnh thank you .emmmm,I'm so sorry that the problem about "out of memory" I mentioned is a mistake . "batch_size" only happened in trainning progress., but the probleam hanppened in my prediction progress. I modified the input size from 713 to 473 ,and it's work. Any way ,thank you . I noticed another issue#75 about the predict result is wrong result . I have the same problem as you. I read the prediction code you uploaded called "PredictSample.zip" and I think It's right ,but the result is wrong too. At least the result is correct before forward delivery. But after a forward pass, the output data is 0 in output_layer. Seriously, I don't know why. Did you get the right result now?

cobbwho avatar Mar 23 '19 13:03 cobbwho