Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The difference between running the code in c ++ and python #2

Closed
sawakk opened this issue Jun 5, 2017 · 10 comments
Closed

The difference between running the code in c ++ and python #2

sawakk opened this issue Jun 5, 2017 · 10 comments

Comments

@sawakk
Copy link

sawakk commented Jun 5, 2017

Hi, I tried to run an example on the python and everything turned out fine. But when I run an example on c ++, the result does not match the declared one.
original
res

The console displays:
Processing time = 361 ms
Output_blob (n, c, h, w) = 1, 19, 512, 1024
Processing time on the python is 1800 ms.

If I use weights with Segnet, then I get a fine result, but the speed has not changed.
ressegnet

@TimoSaemann
Copy link
Owner

Hi, I have updated the C++ code. Please try it again.

@sawakk
Copy link
Author

sawakk commented Jun 6, 2017

Does not work(
In the c ++ example
test_segmentation ENet/final_model_weights/bn_conv_merged_model.prototxt
ENet/final_model_weights/bn_conv_merged_weights.caffemodel
But I do not have bn_conv_merged_model.prototkst and bn_conv_merged_weights.caffemodel.
Instead of them I use the ENet/prototxts/enet_deploy_final.prototxt and
ENet/enet_weights_zoo/cityscapes_weights.caffemodel.

@TimoSaemann
Copy link
Owner

Yes, thats right.
I've checked it, it works.

Are you sure you are using the latest version?

@sawakk
Copy link
Author

sawakk commented Jun 6, 2017

I really want to run a neural network, but I do not know what's wrong anymore
`QT += core
QT -= gui

CONFIG += c++11

TARGET = untitled
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app

CONFIG += link_pkgconfig
PKGCONFIG += opencv

INCLUDEPATH += /usr/local/cuda/targets/x86_64-linux/include
INCLUDEPATH += /usr/local/cuda/lib64

INCLUDEPATH += /home/user/lib/caffe/ENet-master/caffe-enet/include
/home/user/lib/caffe/ENet-master/caffe-enet/build/include
/usr/include/boost

LIBS += -L/home/user/lib/caffe/ENet-master/caffe-enet/build/lib
-lcaffe

LIBS += /usr/lib/x86_64-linux-gnu/libglog.so
LIBS += -L/usr/lib/x86_64-linux-gnu
-lboost_system

SOURCES += main.cpp

DEFINES += QT_DEPRECATED_WARNINGS
`
Here is my .pro file. The project is compiled on qt. If I run / home / user / lib / caffe / ENet-master / caffe-enet / build / examples / ENet_with_C ++ / test_segmentation, it works fine too

@TimoSaemann
Copy link
Owner

Do you get an error message or what do you mean by "does not work"?
If you still get the same prediction image, which you posted in the first post, then you do not use the latest version of caffe-enet.
The best way is to clone and build the ENet repository again.

@sawakk
Copy link
Author

sawakk commented Jun 6, 2017

Yes, I still have an image as in the first post.
I deleted and re-downloaded everything. (2 hours ago)

@TimoSaemann
Copy link
Owner

The problem was the missing argmax layer. I have implemented this function in the script "test_segmentation.cpp". If you are using the old version, you can also add the following to the enet_deploy_final.prototxt.

layer {
  name: "argmax"
  type: "ArgMax"
  bottom: "deconv6_0_0"
  top: "argmax"
  argmax_param {
    axis: 1
  }
}

@sawakk
Copy link
Author

sawakk commented Jun 6, 2017

Working! Thank you very much!
The error was in using the ENet/scripts/test_segmentation.cpp but need ENet/caffe-enet/examples/ENet_with_C++/test_segmentation.cpp.

Thank =)

@sawakk sawakk closed this as completed Jun 6, 2017
@TimoSaemann
Copy link
Owner

Ah, I have missed to adapt this script in this directory. Thanks for pointing this out. I am glad to hear that it works now.

@ThomasLengeling
Copy link

ThomasLengeling commented Jun 13, 2017

@sawakk @TimoSaemann

I tried using the ENet/caffe-enet/examples/ENet_with_C++/test_segmentation.cpp.

I am using the following models

ENet/prototxts/enet_deploy_final.prototxt
ENet/enet_weights_zoo/cityscapes_weights.caffemodel

screenshot from 2017-06-13 17-03-24

I added the "argmx" layer to enet_deploy_final.prototxt.
But still the result is not the same as the python code,

display window_screenshot_13 06 2017

any suggestion?

Thank you for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants