Can dnn model made under Python be used under JAVA

asked 2019-01-22 09:35:59 -0500

rreck gravatar image

I am a new to OpenCV and would like to develop using Python, but the people I support use Java. We are wondering if models created under one programming language be used under another.

edit retag flag offensive close merge delete

Comments

1

Yes this should be possible. Open cv can read and evaluate several models. The way the models were created (python, c++, assembler, texteditor) plays no role here - it just has to be a valid model from opencv point of view.

As always - there are exception. For example in tensorflow your python code IS the model (hello missing abstraction), so if you have any custom cost functions for example - it can be that you cannot read it in open cv.

For reasons given above and also for performance reasons i tend to use the native solution(tensorflow, torch, yolo).

holger gravatar imageholger ( 2019-01-22 10:10:09 -0500 )edit
1

the short answer would be: if you can use it with cv2.dnn from python, it will be no problem in java.

you would have to write some things diffferently in java though, so it would help to know your specific use-case.

berak gravatar imageberak ( 2019-01-22 14:41:48 -0500 )edit