Can dnn model made under Python be used under JAVA [closed]

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 reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-10 03:06:40.545233



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

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