delete opencv2

debug mindata

use new download
pull/6216/head
gongdaguo 4 years ago
parent 411f13bde9
commit fe59c9cf9b

@ -1,6 +1,8 @@
# MindSpore # MindSpore
build/ build/
mindspore/lib mindspore/lib
app/src/main/assets/model/
app/src/main/cpp/mindspore-lite-0.7.0-minddata-arm64-cpu
output output
*.ir *.ir
mindspore/ccsrc/schema/inner/* mindspore/ccsrc/schema/inner/*

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -6,39 +6,28 @@
cmake_minimum_required(VERSION 3.4.1) cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_VERBOSE_MAKEFILE on) set(CMAKE_VERBOSE_MAKEFILE on)
set(libs ${CMAKE_SOURCE_DIR}/libs)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI})
set(MINDSPORELITE_VERSION mindspore-lite-0.7.0-minddata-arm64-cpu)
# ============== Set MindSpore Dependencies. ============= # ============== Set MindSpore Dependencies. =============
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include) include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/MindSpore) include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}/third_party/flatbuffers/include)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/MindSpore/flatbuffers) include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION})
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/MindSpore/ir/dtype) include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}/include)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/MindSpore/schema) include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}/include/ir/dtype)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}/include/schema)
add_library(mindspore-lite SHARED IMPORTED ) add_library(mindspore-lite SHARED IMPORTED )
add_library(minddata-lite SHARED IMPORTED )
set_target_properties(mindspore-lite PROPERTIES IMPORTED_LOCATION set_target_properties(mindspore-lite PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libmindspore-lite.so) ${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}/lib/libmindspore-lite.so)
set_target_properties(minddata-lite PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}/lib/libminddata-lite.so)
# --------------- MindSpore Lite set End. -------------------- # --------------- MindSpore Lite set End. --------------------
# =============== Set OpenCV Dependencies ===================
include_directories(${CMAKE_SOURCE_DIR}/opencv/sdk/native/jni/include/)
add_library(lib-opencv SHARED IMPORTED )
set_target_properties(lib-opencv PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libopencv_java4.so)
# --------------- OpenCV set End. ---------------------------
# Creates and names a library, sets it as either STATIC # Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code. # or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you. # You can define multiple libraries, and CMake builds them for you.
@ -79,10 +68,8 @@ add_definitions(-DMNN_USE_LOGCAT)
target_link_libraries( # Specifies the target library. target_link_libraries( # Specifies the target library.
mlkit-label-MS mlkit-label-MS
# --- opencv ---
lib-opencv
# --- mindspore --- # --- mindspore ---
minddata-lite
mindspore-lite mindspore-lite
# --- other dependencies.--- # --- other dependencies.---

@ -49,7 +49,7 @@ android {
} }
} }
packagingOptions{ packagingOptions{
pickFirst 'lib/arm64-v8a/libopencv_java4.so' pickFirst 'lib/arm64-v8a/libminddata-lite.so'
pickFirst 'lib/arm64-v8a/libmindspore-lite.so' pickFirst 'lib/arm64-v8a/libmindspore-lite.so'
pickFirst 'lib/arm64-v8a/libmlkit-label-MS.so' pickFirst 'lib/arm64-v8a/libmlkit-label-MS.so'
} }

@ -1,27 +1,18 @@
/** /**
* To download necessary library from HuaWei server. * To download necessary library from HuaWei server.
* Including mindspore-lite .so file, opencv .so file and model file. * Including mindspore-lite .so file, minddata-lite .so file and model file.
* The libraries can be downloaded manually. * The libraries can be downloaded manually.
*/ */
def targetMindSporeInclude = "src/main/cpp/"
def targetopenCVInclude = "src/main/cpp/include" def mindsporeLite_Version = "mindspore-lite-0.7.0-minddata-arm64-cpu"
def targetMindSporeInclude = "src/main/cpp/include"
def targetModelFile = "src/main/assets/model/mobilenetv2.ms" def targetModelFile = "src/main/assets/model/mobilenetv2.ms"
def openCVLibrary_arm64 = "libs/arm64-v8a/libopencv_java4.so" def mindSporeLibrary_arm64 = "src/main/cpp/${mindsporeLite_Version}.tar.gz"
def mindSporeLibrary_arm64 = "libs/arm64-v8a/libmindspore-lite.so"
def openCVlibIncluding_arm64 = "src/main/cpp/include/opencv2/include.zip"
def mindSporeLibIncluding_arm64 = "src/main/cpp/include/MindSpore/include.zip"
def modelDownloadUrl = "https://download.mindspore.cn/model_zoo/official/lite/mobilenetv2_openimage_lite/mobilenetv2.ms" def modelDownloadUrl = "https://download.mindspore.cn/model_zoo/official/lite/mobilenetv2_openimage_lite/mobilenetv2.ms"
def opencvDownloadUrl = "https://download.mindspore.cn/model_zoo/official/lite/lib/opencv%204.4.0/libopencv_java4.so" def mindsporeLiteDownloadUrl = "https://download.mindspore.cn/model_zoo/official/lite/lib/mindspore%20version%201.0/${mindsporeLite_Version}.tar.gz"
def mindsporeLiteDownloadUrl = "https://download.mindspore.cn/model_zoo/official/lite/lib/mindspore%20version%200.7/libmindspore-lite.so"
def opencvincludeDownloadUrl = "https://download.mindspore.cn/model_zoo/official/lite/lib/opencv%204.4.0/include.zip"
def mindsporeIncludeDownloadUrl = "https://download.mindspore.cn/model_zoo/official/lite/lib/mindspore%20version%200.7/include.zip"
def cleantargetopenCVInclude = "src/main/cpp/include/opencv2" def cleantargetMindSporeInclude = "src/main/cpp"
def cleantargetMindSporeInclude = "src/main/cpp/include/MindSpore"
task downloadModelFile(type: DownloadUrlTask) { task downloadModelFile(type: DownloadUrlTask) {
@ -32,15 +23,6 @@ task downloadModelFile(type: DownloadUrlTask) {
target = file("${targetModelFile}") target = file("${targetModelFile}")
} }
task downloadOpenCVLibrary(type: DownloadUrlTask) {
doFirst {
println "Downloading ${opencvDownloadUrl}"
}
sourceUrl = "${opencvDownloadUrl}"
target = file("${openCVLibrary_arm64}")
}
task downloadMindSporeLibrary(type: DownloadUrlTask) { task downloadMindSporeLibrary(type: DownloadUrlTask) {
doFirst { doFirst {
println "Downloading ${mindsporeLiteDownloadUrl}" println "Downloading ${mindsporeLiteDownloadUrl}"
@ -49,80 +31,36 @@ task downloadMindSporeLibrary(type: DownloadUrlTask) {
target = file("${mindSporeLibrary_arm64}") target = file("${mindSporeLibrary_arm64}")
} }
task downloadopecvIncludeLibrary(type: DownloadUrlTask) { task unzipMindSporeInclude(type: Copy, dependsOn: 'downloadMindSporeLibrary') {
doFirst {
println "Downloading ${opencvincludeDownloadUrl}"
}
sourceUrl = "${opencvincludeDownloadUrl}"
target = file("${openCVlibIncluding_arm64}")
}
task downloadMindSporeIncludeLibrary(type: DownloadUrlTask) {
doFirst {
println "Downloading ${mindsporeIncludeDownloadUrl}"
}
sourceUrl = "${mindsporeIncludeDownloadUrl}"
target = file("${mindSporeLibIncluding_arm64}")
}
task unzipopencvInclude(type: Copy, dependsOn: 'downloadopecvIncludeLibrary') {
doFirst { doFirst {
println "Unzipping ${openCVlibIncluding_arm64}" println "Unzipping ${mindSporeLibrary_arm64}"
} }
from zipTree("${openCVlibIncluding_arm64}") from tarTree(resources.gzip("${mindSporeLibrary_arm64}"))
into "${targetopenCVInclude}"
}
task unzipMindSporeInclude(type: Copy, dependsOn: 'downloadMindSporeIncludeLibrary') {
doFirst {
println "Unzipping ${mindSporeLibIncluding_arm64}"
}
from zipTree("${mindSporeLibIncluding_arm64}")
into "${targetMindSporeInclude}" into "${targetMindSporeInclude}"
} }
task cleanUnusedopencvFiles(type: Delete, dependsOn: ['unzipopencvInclude']) {
delete fileTree("${cleantargetopenCVInclude}").matching {
include "*.zip"
}
}
task cleanUnusedmindsporeFiles(type: Delete, dependsOn: ['unzipMindSporeInclude']) { task cleanUnusedmindsporeFiles(type: Delete, dependsOn: ['unzipMindSporeInclude']) {
delete fileTree("${cleantargetMindSporeInclude}").matching { delete fileTree("${cleantargetMindSporeInclude}").matching {
include "*.zip" include "*.tar.gz"
} }
} }
/* /*
* Using preBuild to download mindspore library, opencv library and model file. * Using preBuild to download mindspore library, opencv library and model file.
* Run before gradle build. * Run before gradle build.
*/ */
if (file("libs/arm64-v8a/libmindspore-lite.so").exists()){ if (file("src/main/cpp/${mindsporeLite_Version}/lib/libmindspore-lite.so").exists()){
downloadMindSporeLibrary.enabled = false downloadMindSporeLibrary.enabled = false
unzipMindSporeInclude.enabled = false
cleanUnusedmindsporeFiles.enabled = false
} }
if (file("libs/arm64-v8a/libopencv_java4.so").exists()){
downloadOpenCVLibrary.enabled = false
}
if (file("src/main/assets/model/mobilenetv2.ms").exists()){ if (file("src/main/assets/model/mobilenetv2.ms").exists()){
downloadModelFile.enabled = false downloadModelFile.enabled = false
} }
if (file("src/main/cpp/include/MindSpore/lite_session.h").exists()){
downloadMindSporeIncludeLibrary.enabled = false
unzipopencvInclude.enabled = false
cleanUnusedopencvFiles.enabled =false
}
if (file("src/main/cpp/include/opencv2/core.hpp").exists()){
downloadopecvIncludeLibrary.enabled = false
unzipMindSporeInclude.enabled = false
cleanUnusedmindsporeFiles.enabled =false
}
preBuild.dependsOn downloadMindSporeLibrary
preBuild.dependsOn downloadOpenCVLibrary
preBuild.dependsOn downloadModelFile preBuild.dependsOn downloadModelFile
preBuild.dependsOn unzipopencvInclude preBuild.dependsOn downloadMindSporeLibrary
preBuild.dependsOn unzipMindSporeInclude preBuild.dependsOn unzipMindSporeInclude
preBuild.dependsOn cleanUnusedopencvFiles
preBuild.dependsOn cleanUnusedmindsporeFiles preBuild.dependsOn cleanUnusedmindsporeFiles
class DownloadUrlTask extends DefaultTask { class DownloadUrlTask extends DefaultTask {

@ -18,7 +18,7 @@
#include <android/log.h> #include <android/log.h>
#include <iostream> #include <iostream>
#include <string> #include <string>
#include "include/MindSpore/errorcode.h" #include "include/errorcode.h"
#define MS_PRINT(format, ...) __android_log_print(ANDROID_LOG_INFO, "MSJNI", format, ##__VA_ARGS__) #define MS_PRINT(format, ...) __android_log_print(ANDROID_LOG_INFO, "MSJNI", format, ##__VA_ARGS__)
@ -54,8 +54,6 @@ int MSNetWork::ReleaseNets(void) {
return 0; return 0;
} }
const int MSNetWork::RET_CATEGORY_SUM = 601;
const char *MSNetWork::labels_name_map[MSNetWork::RET_CATEGORY_SUM] = { const char *MSNetWork::labels_name_map[MSNetWork::RET_CATEGORY_SUM] = {
{"Tortoise"}, {"Container"}, {"Magpie"}, {"Seaturtle"}, {"Football"}, {"Ambulance"}, {"Ladder"}, {"Tortoise"}, {"Container"}, {"Magpie"}, {"Seaturtle"}, {"Football"}, {"Ambulance"}, {"Ladder"},
{"Toothbrush"}, {"Syringe"}, {"Sink"}, {"Toy"}, {"Organ(MusicalInstrument) "}, {"Cassettedeck"}, {"Toothbrush"}, {"Syringe"}, {"Sink"}, {"Toy"}, {"Organ(MusicalInstrument) "}, {"Cassettedeck"},

@ -52,10 +52,9 @@ class MSNetWork {
int ReleaseNets(void); int ReleaseNets(void);
private:
mindspore::session::LiteSession *session; mindspore::session::LiteSession *session;
mindspore::lite::Model *model; mindspore::lite::Model *model;
static const int RET_CATEGORY_SUM; static const int RET_CATEGORY_SUM = 601;
static const char *labels_name_map[RET_CATEGORY_SUM]; static const char *labels_name_map[RET_CATEGORY_SUM];
}; };
#endif #endif

Loading…
Cancel
Save