CARVIEW |
Navigation Menu
-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
[GSoC] Develop OpenCV.js DNN modules for promising web use cases together with their tutorials #18064
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
Conversation
β¦encv.js tutorial
β¦ns into code snippet.
β¦ow in the web page.
[Opencv.js doc] Init commit to add image classification example in opβ¦
β¦camera in opencv.js tutorial
[Opencv.js doc] Add image classification example with camera
β¦pencv.js tutorial
[Opencv.js doc] Init commit to add semantic segmentation example
Fix the utils.loadOpenCv for promise module
[Opencv.js doc] Add object detection example.
[Opencv.js doc] Add fast neural style transfer example with opencv.js
[Opencv.js doc] Add pose estimation example
Please try to enable DetectionModel - t must be more efficient than js postprocessing |
doc/js_tutorials/js_assets/js_image_classification_with_camera.html
Outdated
Show resolved
Hide resolved
I found this function before in the wiki. But this project is based on Opencv 3.4, |
@dkurt , I agree |
@akineeic , please help fix the buildbot failures. |
The onnx repo doesn't host the models in the github any more. Now they use LFS(large file system) to store instead, for example squeezeNet. So loading model from the url doesn't work in that case. So I'm wondering if we can add a button for users to upload models. |
It sounds like a good solution to me. It can solve two restrictions here: 1) docs.opencv.org would not host any external models; 2) cross-origin issue of the external models. The usage would be like: user follows the links in your table to download models, then upload models to the tutorial for inference. @akineeic , please go ahead to try this solution and let us know the results. |
779aa1d
to
f3df32e
Compare
f3df32e
to
74daac9
Compare
I have done the work. Users can use their own models download the models according to the table in the bottom of the webpage, and then click the input buttons to upload the models. Finally click the Try it will do inference once. @huningxin @dkurt @alalek You can try the online demo without build(but it will take several minutes to load opencv.js). Any suggestion is welcomed sincerely. |
"needSoftmax": "false", | ||
"labelsUrl": "https://raw.githubusercontent.com/petewarden/tf_ios_makefile_example/master/data/imagenet_comp_graph_label_strings.txt", | ||
"modelUrl": "https://raw.githubusercontent.com/petewarden/tf_ios_makefile_example/master/data/tensorflow_inception_graph.pb" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you remove the ONNX models? You list models in #18064 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems these models can't run in this example with opencv.js. I test successfully with opencv python before. This may caused by the difference version between python and opencv.js. I'll investigate these models later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please investigate whether the root cause is the version of latest ONNX models. Did you try some old models?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That may be the root cause. I'll try to find the old model and have a try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a number of tested models here: https://github.com/opencv/opencv_extra/blob/master/testdata/dnn/download_models.py
But they are not very interesting - almost all the models just ports to Caffe2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akineeic, could you try the ONNX models listed in download_models.py?
Thanks @akineeic , the model upload function works great. I found some issues and left some comments in the code. Please take a look. |
Thanks for your reviewer! I have modify the code according to your comments. And I update the code in my repo at hte same code. You can clone the code to launch a local web server or just try the online demo. |
BTW, what is wrong with preview pages: https://pullrequest.opencv.org/buildbot/export/pr/18064/docs/d5/d10/tutorial_js_root.html ? |
I just create a subpage to hold the examples. |
@alalek , thanks for this link. It is very convenient for review. We'll use that. We didn't know the buildbot can host the preview pages, so I suggest @akineeic to host on his own github repo. |
87e28a1
to
eecd46c
Compare
@huningxin @alalek @dkurt Thanks for your review! I have finished the coding according to your conments. And my GSoC report can be found here. I'm wondering do you have any suggestion to the code or the webpage? |
doc/js_tutorials/js_assets/js_image_classification_with_camera.html
Outdated
Show resolved
Hide resolved
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need to implement NMS? There is already NMSBoxes in dnn module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the reason is current dnn module of OpenCV.js doesn't expose NMSBoxes. @akineeic could you clarify that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the later reply. I missed the mail since I forgot to change the primary email of my github account. The reason is mentioned by @huningxin that the JS binding of NMSBoxes is not implemented yet.
bdd1de4
to
491b5d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! Thank you for contribution π
Overview
Introduction
OpenCV.js comes out as a JavaScript binding for a selected subset of OpenCV functions for the open web platform. It allows emerging web applications involving multimedia processing to benefit from the wide variety of vision functions available in OpenCV. OpenCV.js leverages Emscripten to compile OpenCV functions into ASM.js or WebAssembly targets, and provides JavaScript APIs for web developers.
The dnn module of OpenCV supports several frameworks including caffe, tensorflow, torch, darknet, onnx. It also supports so many types of layers as shown in the wiki, which reveal its potential to develop deep learning applications. OpenCV.js also binds some dnn API which is enough to do deep learning inference on the Web. At the same time, with the optimization through multi-threads and SIMD, the performance of the dnn module in OpenCV.js is impressive. All of these means that OpenCV.js also has the ability and potential to develop attractive deep learning applications on the Web.
But there are lack of tutorials to show the ability or potential of the dnn module of OpenCV.js. Very little information a developer can get from the tutorial even if he is interested in the dnn module of OpenCV.js. Lack of documentation and tutorials becomes a major issue that prevents widespread use of the dnn module in OpenCV.js.
Therefore, the main goal of this project is to develop several deep learning example with OpenCV.js and add them into the tutorial.
Work structure
Develop DNN(Deep Neural Networks) examples
This project added several DNN examples into OpenCV.js tutorial, including image classification, object detection, style transfer, semantic segmentation and pose estimation. The process flow of each example is similar. So condensed a function
main
to do inference once, which could be divided into several parts as follows:mean
,std
according to model.setInput
andforward
to get the output data.The first three part have been written into a JS file as help functions since these parts can be re-use between examples. You should only re-write the post-processing function to develop different example and change the parameters to run differents models.
Usage of DNN example
Follow the tutorial to build OpenCV.js and append option
--build_doc
to build documents. To try the DNN examples, launch a local web server in <build_dir>/doc/doxygen/html folder. Then clickOpenCV.js Tutorials
andDeep Neural Networks (dnn module) example
in turn will navigate into the example webpage. You can download models according to the table in the bottom of the webpage or use their own models. Click themodelFile
button (andconfigFile
button if neeed) to upload model and modify the parameters in the first codeSnippet according to the uploaded model. Finally clickTry it
button will run functionmain
to do inference once and show the result in the webpage.Result
Test Environment
OS: Ubuntu 18.04
Emscripten: 1.39.15, LLVM upstream backend
Browser: Google Chrome 85.0.4183.83 (Official Build) (64-bit)
Hardware: Core(TM) i7-5960X CPU @ 3.00GHz with 16 logical cores
Test Result
Examples show(test in scalar)
Future Work
DetectionModel
for object detection example with the new version of OpenCV.