-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
自己编译mdl库运行速度超慢且自己使用tools转换的model不能工作!!! #75
Comments
能把你so库编译的脚本贴出来看看吗? |
关于第二个问题,你用test/googlenet目录下的模型试试呢 |
说明一下我是使用tools下的googlenet/deploy.prototxt和googlenet/full.caffemodel转换的,生成后的model.min.json是格式化的json,看了一下,demo中的是经过压缩的,从调试信息可以看出,在计算json的hash值时不匹配造成,症结在此,解决方法就是:计算格式化json后的hash值替换tools后生成的,OK! 关于第一个问题,我开始时使用的是debug,换成release后速度提到4s,不过还是很慢啊,估计是优化的问题,还有demo的模型应该是经过优化的!!! |
编译so的cmake脚本: For more information about using CMake with Android Studio, read thedocumentation: https://d.android.com/studio/projects/add-native-code.htmlSets the minimum version of CMake required to build the native library.cmake_minimum_required(VERSION 3.4.1) Creates and names a library, sets it as either STATICor SHARED, and provides the relative paths to its source code.You can define multiple libraries, and CMake builds them for you.Gradle automatically packages shared libraries with your APK.add_definitions ( #set(CMAKE_VERBOSE_MAKEFILE on) 引用第三方库头文件include_directories( F:/opencv/build/includeF:/opencv/build/include/opencvF:/opencv/build/include/opencv2
引用第三方库#add_library( ml # so库的名称SHAREDIMPORTED # 表示只需要导入,不需要构建so库。)第三方库的路径#set_target_properties( ml # so库的名称PROPERTIES IMPORTED_LOCATION # import so库libs/libml.so # so库路径)本so库的名称、源码等include_directories( Searches for a specified prebuilt library and stores the path as avariable. Because CMake includes system libraries in the search path bydefault, you only need to specify the name of the public NDK libraryyou want to add. CMake verifies that the library exists beforecompleting its build.find_library( # Sets the name of the path variable. Specifies libraries CMake should link to your target library. Youcan link multiple libraries, such as libraries you define in thisbuild script, prebuilt third-party libraries, or system libraries.target_link_libraries( # Specifies the target library. |
@2php 你的Cmake中好像没有打开neon支持 |
@2php 关于第二个问题,你是手动改了tools生成的sign值才能校验通过是吗? |
@cocodark 是的,我估计是由于linux和windows上关于换行符的原因导致hash计算错误,因为开发环境都是windows |
@cocodark NEON不知道是不是这样开启?externalNativeBuild { |
开启neon的方式应该是ok的,你通过jni接口设置线程数了吗?参照Android demo |
你是在windows上生成的json,然后在android上加载? |
@cocodark 是的windows上生成;线程都是demo默认的 |
linux和windows上换行符表示差异导致hash计算不一致,MDL在异常信息会抛出linux平台计算的hash值,手动替换下,这个问题之前有人提过。 |
@cocodark 嗯,惭愧没浏览大神们的Issues |
|
"-DCMAKE_BUILD_TYPE=Release"我看你没有加这个控制选项 |
@cocodark 好的,release编译我是切换AS的变量来实现的 |
@cocodark 用你的编译参数运行了一下,使用转换后的model,运行时间8s,生成出来的so有5M左右,应该是没有经过优化 |
你的so体积超出太多,你检查下你的编译参数 和cmakeList.txt,正常so体积在500K左右 |
@cocodark 嗯,需要加上build.sh上面的一些参数,慢慢测试,非常感谢回复~~~ |
后面我会提供一个源码编译的Android demo |
在android demo的基础上增加了so库的编译,生成apk后运行(googlenet)速度达到25s,与预览版相差十万八千里,不知道这是怎么回事?
其次,使用model转换工具生成googlenet的data.min.bin和model.min.json,替换预览版的运行,等了5分钟都没有结果,这又是为何?
The text was updated successfully, but these errors were encountered: