Compare commits
No commits in common. 'master' and 'main' have entirely different histories.
File diff suppressed because it is too large
Load Diff
@ -1,13 +0,0 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
@ -1,3 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
@ -1,116 +0,0 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<codeStyleSettings language="XML">
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
<arrangement>
|
||||
<rules>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:android</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:id</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>style</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
</rules>
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="11" />
|
||||
</component>
|
||||
</project>
|
||||
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="Embedded JDK" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@ -1,110 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="BintrayJCenter" />
|
||||
<option name="name" value="BintrayJCenter" />
|
||||
<option name="url" value="https://jcenter.bintray.com/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="Google" />
|
||||
<option name="name" value="Google" />
|
||||
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="D:\AndroidSDK\extras\m2repository" />
|
||||
<option name="name" value="D:\AndroidSDK\extras\m2repository" />
|
||||
<option name="url" value="file:/$PROJECT_DIR$/../AndroidSDK/extras/m2repository" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="D:\AndroidSDK\extras\google\m2repository" />
|
||||
<option name="name" value="D:\AndroidSDK\extras\google\m2repository" />
|
||||
<option name="url" value="file:/$PROJECT_DIR$/../AndroidSDK/extras/google/m2repository" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="D:\AndroidSDK\extras\android\m2repository" />
|
||||
<option name="name" value="D:\AndroidSDK\extras\android\m2repository" />
|
||||
<option name="url" value="file:/$PROJECT_DIR$/../AndroidSDK/extras/android/m2repository" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="C:\Users\99693\AppData\Local\Android\Sdk\extras\google\m2repository" />
|
||||
<option name="name" value="C:\Users\99693\AppData\Local\Android\Sdk\extras\google\m2repository" />
|
||||
<option name="url" value="file:/$USER_HOME$/AppData/Local/Android/Sdk/extras/google/m2repository" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="C:\Users\99693\AppData\Local\Android\Sdk\extras\m2repository" />
|
||||
<option name="name" value="C:\Users\99693\AppData\Local\Android\Sdk\extras\m2repository" />
|
||||
<option name="url" value="file:/$USER_HOME$/AppData/Local/Android/Sdk/extras/m2repository" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="C:\Users\99693\AppData\Local\Android\Sdk\extras\android\m2repository" />
|
||||
<option name="name" value="C:\Users\99693\AppData\Local\Android\Sdk\extras\android\m2repository" />
|
||||
<option name="url" value="file:/$USER_HOME$/AppData/Local/Android/Sdk/extras/android/m2repository" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="MavenRepo" />
|
||||
<option name="name" value="MavenRepo" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven4" />
|
||||
<option name="name" value="maven4" />
|
||||
<option name="url" value="https://maven.aliyun.com/repository/gradle-plugin/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven" />
|
||||
<option name="name" value="maven" />
|
||||
<option name="url" value="https://maven.aliyun.com/repository/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven5" />
|
||||
<option name="name" value="maven5" />
|
||||
<option name="url" value="https://maven.aliyun.com/repository/spring-plugin/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven3" />
|
||||
<option name="name" value="maven3" />
|
||||
<option name="url" value="https://maven.aliyun.com/repository/google/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven7" />
|
||||
<option name="name" value="maven7" />
|
||||
<option name="url" value="https://maven.aliyun.com/repository/apache-snapshots/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven6" />
|
||||
<option name="name" value="maven6" />
|
||||
<option name="url" value="https://maven.aliyun.com/repository/grails-core/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven2" />
|
||||
<option name="name" value="maven2" />
|
||||
<option name="url" value="https://maven.aliyun.com/repository/spring/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="D:\coder888\sdk\extras\android\m2repository" />
|
||||
<option name="name" value="D:\coder888\sdk\extras\android\m2repository" />
|
||||
<option name="url" value="file:/D:/coder888/sdk/extras/android/m2repository" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="D:\coder888\sdk\extras\google\m2repository" />
|
||||
<option name="name" value="D:\coder888\sdk\extras\google\m2repository" />
|
||||
<option name="url" value="file:/D:/coder888/sdk/extras/google/m2repository" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="D:\coder888\sdk\extras\m2repository" />
|
||||
<option name="name" value="D:\coder888\sdk\extras\m2repository" />
|
||||
<option name="url" value="file:/D:/coder888/sdk/extras/m2repository" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
||||
@ -1,46 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DesignSurface">
|
||||
<option name="filePathToZoomLevelMap">
|
||||
<map>
|
||||
<entry key="..\:/Users/CYJ/Downloads/SmartTrashCan/app/src/main/res/layout/activity_main.xml" value="0.19739583333333333" />
|
||||
<entry key="..\:/Users/CYJ/Downloads/SmartTrashCan/app/src/main/res/layout/activity_main1.xml" value="0.21614583333333334" />
|
||||
<entry key="..\:/Users/www27/Downloads/SmartTrashCanV2/app/src/main/res/layout/activity_home.xml" value="0.19895833333333332" />
|
||||
<entry key="..\:/Users/www27/Downloads/SmartTrashCanV2/app/src/main/res/layout/activity_index.xml" value="0.19895833333333332" />
|
||||
<entry key="..\:/Users/www27/Downloads/SmartTrashCanV2/app/src/main/res/layout/activity_main.xml" value="0.19895833333333332" />
|
||||
<entry key="..\:/Users/www27/Downloads/SmartTrashCanV2/app/src/main/res/layout/activity_main1.xml" value="0.19895833333333332" />
|
||||
<entry key="..\:/Users/www27/Downloads/SmartTrashCanV2/app/src/main/res/layout/activity_notes.xml" value="0.19895833333333332" />
|
||||
<entry key="..\:/Users/www27/Downloads/SmartTrashCanV2/app/src/main/res/layout/activity_rigister.xml" value="0.19895833333333332" />
|
||||
<entry key="..\:/Users/www27/Downloads/SmartTrashCanV2/app/src/main/res/layout/classification.xml" value="0.19895833333333332" />
|
||||
<entry key="..\:/Users/www27/Downloads/SmartTrashCanV2/app/src/main/res/layout/frag_category.xml" value="0.19895833333333332" />
|
||||
<entry key="..\:/Users/www27/Downloads/SmartTrashCanV2/app/src/main/res/layout/frag_home.xml" value="0.19895833333333332" />
|
||||
<entry key="..\:/Users/www27/Downloads/SmartTrashCanV2/app/src/main/res/layout/frag_setting.xml" value="0.19895833333333332" />
|
||||
<entry key="..\:/Users/www27/Downloads/SmartTrashCanV2/app/src/main/res/layout/layout_dry.xml" value="0.19895833333333332" />
|
||||
<entry key="..\:/Users/www27/Downloads/SmartTrashCanV2/app/src/main/res/layout/layout_less.xml" value="0.19895833333333332" />
|
||||
<entry key="..\:/Users/www27/Downloads/SmartTrashCanV2/app/src/main/res/layout/layout_recycler.xml" value="0.19895833333333332" />
|
||||
<entry key="..\:/Users/www27/Downloads/SmartTrashCanV2/app/src/main/res/layout/layout_wish.xml" value="0.19895833333333332" />
|
||||
<entry key="..\:/Users/www27/Downloads/SmartTrashCanV2/app/src/main/res/menu/main.xml" value="0.16296296296296298" />
|
||||
<entry key="..\:/Users/www27/Downloads/SmartTrashCanV2/app/src/main/res/menu/menu_action_options.xml" value="0.16296296296296298" />
|
||||
<entry key="..\:/Users/www27/Downloads/SmartTrashCanV2/app/src/main/res/menu/notes.xml" value="0.16296296296296298" />
|
||||
<entry key="..\:/Users/zhang'yun'han/Desktop/gxz224/app/src/main/res/layout/activity_home.xml" value="0.2046875" />
|
||||
<entry key="..\:/Users/zhang'yun'han/Desktop/gxz224/app/src/main/res/layout/activity_index.xml" value="0.2046875" />
|
||||
<entry key="..\:/Users/zhang'yun'han/Desktop/gxz224/app/src/main/res/layout/activity_main.xml" value="0.2046875" />
|
||||
<entry key="..\:/Users/zhang'yun'han/Desktop/gxz224/app/src/main/res/layout/activity_main1.xml" value="0.2046875" />
|
||||
<entry key="..\:/Users/zhang'yun'han/Desktop/gxz224/app/src/main/res/layout/activity_notes.xml" value="0.2046875" />
|
||||
<entry key="..\:/Users/zhang'yun'han/Desktop/gxz224/app/src/main/res/layout/frag_category.xml" value="0.2046875" />
|
||||
<entry key="..\:/Users/zhang'yun'han/Desktop/gxz224/app/src/main/res/layout/frag_home.xml" value="0.2046875" />
|
||||
<entry key="..\:/Users/zhang'yun'han/Desktop/gxz224/app/src/main/res/layout/frag_setting.xml" value="0.2046875" />
|
||||
<entry key="..\:/Users/zhang'yun'han/Desktop/gxz224/app/src/main/res/layout/layout_dry.xml" value="0.2046875" />
|
||||
<entry key="..\:/Users/zhang'yun'han/Desktop/gxz224/app/src/main/res/layout/layout_less.xml" value="0.2046875" />
|
||||
<entry key="..\:/Users/zhang'yun'han/Desktop/gxz224/app/src/main/res/layout/layout_recycler.xml" value="0.2046875" />
|
||||
<entry key="..\:/Users/zhang'yun'han/Desktop/gxz224/app/src/main/res/layout/layout_wish.xml" value="0.2046875" />
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
||||
@ -1 +0,0 @@
|
||||
/build
|
||||
@ -1,150 +0,0 @@
|
||||
import java.security.MessageDigest
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
defaultConfig {
|
||||
applicationId "com.example.administrator.baiduvoicetest"
|
||||
minSdkVersion 28
|
||||
targetSdkVersion 28
|
||||
versionCode 100000
|
||||
versionName "1.0"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
||||
ndk {
|
||||
//选择要添加的对应cpu类型的.so库。
|
||||
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
|
||||
// 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64', 'mips', 'mips64'
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
// Or, if you prefer, you can continue to check for errors in release builds,
|
||||
// but continue the build even when errors are found:
|
||||
abortOnError false
|
||||
}
|
||||
useLibrary 'org.apache.http.legacy'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation files('libs/fastjson-1.0.4.jar')
|
||||
implementation files('libs/xUtils-2.6.14.jar')
|
||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||
implementation 'com.android.support:design:28.0.0'
|
||||
implementation files('libs\\mysql-connector-java-5.1.47-bin.jar')
|
||||
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||
implementation files('libs/PaddlePredictor.jar')
|
||||
|
||||
|
||||
implementation files('libs/com.baidu.tts_2.2.9.20161020_154fa02_release.jar')
|
||||
implementation files('libs/VoiceRecognition-2.1.20.jar')
|
||||
implementation files('libs/galaxy-v2.0.jar')
|
||||
}
|
||||
|
||||
def paddleLiteLibs = 'https://paddlelite-demo.bj.bcebos.com/libs/android/paddle_lite_libs_v2_6_1.tar.gz'
|
||||
task downloadAndExtractPaddleLiteLibs(type: DefaultTask) {
|
||||
doFirst {
|
||||
println "Downloading and extracting Paddle Lite libs"
|
||||
}
|
||||
doLast {
|
||||
// Prepare cache folder for libs
|
||||
if (!file("cache").exists()) {
|
||||
mkdir "cache"
|
||||
}
|
||||
// Generate cache name for libs
|
||||
MessageDigest messageDigest = MessageDigest.getInstance('MD5')
|
||||
messageDigest.update(paddleLiteLibs.bytes)
|
||||
String cacheName = new BigInteger(1, messageDigest.digest()).toString(32)
|
||||
// Download libs
|
||||
if (!file("cache/${cacheName}.tar.gz").exists()) {
|
||||
ant.get(src: paddleLiteLibs, dest: file("cache/${cacheName}.tar.gz"))
|
||||
}
|
||||
// Unpack libs
|
||||
copy {
|
||||
from tarTree("cache/${cacheName}.tar.gz")
|
||||
into "cache/${cacheName}"
|
||||
}
|
||||
// Copy PaddlePredictor.jar
|
||||
if (!file("libs/PaddlePredictor.jar").exists()) {
|
||||
copy {
|
||||
from "cache/${cacheName}/java/PaddlePredictor.jar"
|
||||
into "libs"
|
||||
}
|
||||
}
|
||||
// Copy libpaddle_lite_jni.so for armeabi-v7a and arm64-v8a
|
||||
if (!file("src/main/jniLibs/armeabi-v7a/libpaddle_lite_jni.so").exists()) {
|
||||
copy {
|
||||
from "cache/${cacheName}/java/libs/armeabi-v7a/"
|
||||
into "src/main/jniLibs/armeabi-v7a"
|
||||
}
|
||||
}
|
||||
if (!file("src/main/jniLibs/arm64-v8a/libpaddle_lite_jni.so").exists()) {
|
||||
copy {
|
||||
from "cache/${cacheName}/java/libs/arm64-v8a/"
|
||||
into "src/main/jniLibs/arm64-v8a"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
preBuild.dependsOn downloadAndExtractPaddleLiteLibs
|
||||
|
||||
def paddleLiteModels = [
|
||||
[
|
||||
'src' : 'https://paddlelite-demo.bj.bcebos.com/models/mobilenet_v1_fp32_224_for_cpu_v2_6_0.tar.gz',
|
||||
'dest' : 'src/main/assets/models/mobilenet_v1_for_cpu'
|
||||
],
|
||||
[
|
||||
'src' : 'https://paddlelite-demo.bj.bcebos.com/models/mobilenet_v1_fp32_224_for_npu_v2_6_0.tar.gz',
|
||||
'dest' : 'src/main/assets/models/mobilenet_v1_for_npu'
|
||||
]
|
||||
]
|
||||
task downloadAndExtractPaddleLiteModels(type: DefaultTask) {
|
||||
doFirst {
|
||||
println "Downloading and extracting Paddle Lite models"
|
||||
}
|
||||
doLast {
|
||||
// Prepare cache folder for models
|
||||
if (!file("cache").exists()) {
|
||||
mkdir "cache"
|
||||
}
|
||||
paddleLiteModels.eachWithIndex { model, index ->
|
||||
MessageDigest messageDigest = MessageDigest.getInstance('MD5')
|
||||
messageDigest.update(model.src.bytes)
|
||||
String cacheName = new BigInteger(1, messageDigest.digest()).toString(32)
|
||||
// Download model file
|
||||
if (!file("cache/${cacheName}.tar.gz").exists()) {
|
||||
ant.get(src: model.src, dest: file("cache/${cacheName}.tar.gz"))
|
||||
}
|
||||
// Unpack model file
|
||||
copy {
|
||||
from tarTree("cache/${cacheName}.tar.gz")
|
||||
into "cache/${cacheName}"
|
||||
}
|
||||
// Copy model file
|
||||
if (!file("${model.dest}/model.nb").exists()) {
|
||||
copy {
|
||||
from "cache/${cacheName}"
|
||||
into "${model.dest}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
preBuild.dependsOn downloadAndExtractPaddleLiteModels
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,277 +0,0 @@
|
||||
// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*
|
||||
* This file defines PaddlePredictor, the api for lite. It supports multiple
|
||||
* hardware including ARM, X86, OpenCL, CUDA and so on.
|
||||
*/
|
||||
|
||||
#ifndef PADDLE_LITE_API_H_ // NOLINT
|
||||
#define PADDLE_LITE_API_H_
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "paddle_place.h" // NOLINT
|
||||
|
||||
namespace paddle {
|
||||
namespace lite_api {
|
||||
|
||||
using shape_t = std::vector<int64_t>;
|
||||
using lod_t = std::vector<std::vector<uint64_t>>;
|
||||
|
||||
enum class LiteModelType { kProtobuf = 0, kNaiveBuffer, UNK };
|
||||
|
||||
struct LITE_API Tensor {
|
||||
explicit Tensor(void* raw);
|
||||
explicit Tensor(const void* raw);
|
||||
|
||||
void Resize(const shape_t& shape);
|
||||
|
||||
/// Readonly data.
|
||||
template <typename T>
|
||||
const T* data() const;
|
||||
|
||||
template <typename T>
|
||||
T* mutable_data(TargetType type = TargetType::kHost) const;
|
||||
|
||||
template <typename T, TargetType type = TargetType::kHost>
|
||||
void CopyFromCpu(const T* data);
|
||||
|
||||
template <typename T>
|
||||
void CopyToCpu(T* data) const;
|
||||
/// Shape of the tensor.
|
||||
shape_t shape() const;
|
||||
TargetType target() const;
|
||||
PrecisionType precision() const;
|
||||
|
||||
// LoD of the tensor
|
||||
lod_t lod() const;
|
||||
|
||||
// Set LoD of the tensor
|
||||
void SetLoD(const lod_t& lod);
|
||||
|
||||
private:
|
||||
void* raw_tensor_;
|
||||
};
|
||||
|
||||
/// The PaddlePredictor defines the basic interfaces for different kinds of
|
||||
/// predictors.
|
||||
class LITE_API PaddlePredictor {
|
||||
public:
|
||||
PaddlePredictor() = default;
|
||||
|
||||
/// Get i-th input.
|
||||
virtual std::unique_ptr<Tensor> GetInput(int i) = 0;
|
||||
|
||||
/// Get i-th output.
|
||||
virtual std::unique_ptr<const Tensor> GetOutput(int i) const = 0;
|
||||
|
||||
virtual void Run() = 0;
|
||||
virtual std::shared_ptr<PaddlePredictor> Clone() = 0;
|
||||
|
||||
virtual std::string GetVersion() const = 0;
|
||||
|
||||
// Get input names
|
||||
virtual std::vector<std::string> GetInputNames() = 0;
|
||||
// Get output names
|
||||
virtual std::vector<std::string> GetOutputNames() = 0;
|
||||
// Get output names
|
||||
virtual std::vector<std::string> GetParamNames();
|
||||
|
||||
// Get Input by name
|
||||
virtual std::unique_ptr<Tensor> GetInputByName(const std::string& name) = 0;
|
||||
|
||||
/// Get a readonly tensor, return null if no one called `name` exists.
|
||||
virtual std::unique_ptr<const Tensor> GetTensor(
|
||||
const std::string& name) const = 0;
|
||||
/// Get a mutable tensor, return null if on one called `name` exists
|
||||
/// internal infereces API, not recommanded.
|
||||
virtual std::unique_ptr<Tensor> GetMutableTensor(const std::string& name);
|
||||
|
||||
/// Persist the optimized model to disk. This API is only supported by
|
||||
/// CxxConfig, and the persisted model can be reused for MobileConfig.
|
||||
virtual void SaveOptimizedModel(
|
||||
const std::string& model_dir,
|
||||
LiteModelType model_type = LiteModelType::kProtobuf,
|
||||
bool record_info = false);
|
||||
|
||||
virtual ~PaddlePredictor() = default;
|
||||
|
||||
protected:
|
||||
int threads_{1};
|
||||
lite_api::PowerMode mode_{lite_api::LITE_POWER_NO_BIND};
|
||||
};
|
||||
|
||||
/// Base class for all the configs.
|
||||
class LITE_API ConfigBase {
|
||||
std::string model_dir_;
|
||||
int threads_{1};
|
||||
PowerMode mode_{LITE_POWER_NO_BIND};
|
||||
|
||||
public:
|
||||
explicit ConfigBase(PowerMode mode = LITE_POWER_NO_BIND, int threads = 1);
|
||||
// set Model_dir
|
||||
void set_model_dir(const std::string& x) { model_dir_ = x; }
|
||||
const std::string& model_dir() const { return model_dir_; }
|
||||
// set Power_mode
|
||||
void set_power_mode(PowerMode mode);
|
||||
PowerMode power_mode() const { return mode_; }
|
||||
// set Thread
|
||||
void set_threads(int threads);
|
||||
int threads() const { return threads_; }
|
||||
};
|
||||
|
||||
/// CxxConfig is the config for the Full feature predictor.
|
||||
class LITE_API CxxConfig : public ConfigBase {
|
||||
std::vector<Place> valid_places_;
|
||||
std::string model_file_;
|
||||
std::string param_file_;
|
||||
std::vector<std::string> passes_internal_{};
|
||||
bool model_from_memory_{false};
|
||||
#ifdef LITE_WITH_X86
|
||||
int x86_math_library_math_threads_ = 1;
|
||||
#endif
|
||||
#ifdef LITE_WITH_CUDA
|
||||
bool multi_stream_{false};
|
||||
#endif
|
||||
#ifdef LITE_WITH_MLU
|
||||
lite_api::MLUCoreVersion mlu_core_version_{lite_api::MLUCoreVersion::MLU_270};
|
||||
int mlu_core_number_{1};
|
||||
DataLayoutType mlu_input_layout_{DATALAYOUT(kNCHW)};
|
||||
bool mlu_use_first_conv_{false};
|
||||
std::vector<float> mlu_first_conv_mean_;
|
||||
std::vector<float> mlu_first_conv_std_;
|
||||
#endif
|
||||
|
||||
public:
|
||||
void set_valid_places(const std::vector<Place>& x) { valid_places_ = x; }
|
||||
void set_model_file(const std::string& path) { model_file_ = path; }
|
||||
void set_param_file(const std::string& path) { param_file_ = path; }
|
||||
void set_model_buffer(const char* model_buffer,
|
||||
size_t model_buffer_size,
|
||||
const char* param_buffer,
|
||||
size_t param_buffer_size) {
|
||||
model_file_ = std::string(model_buffer, model_buffer + model_buffer_size);
|
||||
param_file_ = std::string(param_buffer, param_buffer + param_buffer_size);
|
||||
model_from_memory_ = true;
|
||||
}
|
||||
// internal inference to choose passes for model optimizing,
|
||||
// it's designed for internal developer and not recommanded
|
||||
// for comman users.
|
||||
void set_passes_internal(
|
||||
const std::vector<std::string>& passes_internal = {}) {
|
||||
passes_internal_ = passes_internal;
|
||||
}
|
||||
const std::vector<std::string>& get_passes_internal() const {
|
||||
return passes_internal_;
|
||||
}
|
||||
const std::vector<Place>& valid_places() const { return valid_places_; }
|
||||
std::string model_file() const { return model_file_; }
|
||||
std::string param_file() const { return param_file_; }
|
||||
bool model_from_memory() const { return model_from_memory_; }
|
||||
|
||||
#ifdef LITE_WITH_X86
|
||||
void set_x86_math_library_num_threads(int threads) {
|
||||
x86_math_library_math_threads_ = threads;
|
||||
}
|
||||
int x86_math_library_num_threads() const {
|
||||
return x86_math_library_math_threads_;
|
||||
}
|
||||
#endif
|
||||
#ifdef LITE_WITH_CUDA
|
||||
void set_multi_stream(bool multi_stream) { multi_stream_ = multi_stream; }
|
||||
bool multi_stream() const { return multi_stream_; }
|
||||
#endif
|
||||
|
||||
#ifdef LITE_WITH_MLU
|
||||
// set MLU core version, which is used when compiling MLU kernels
|
||||
void set_mlu_core_version(lite_api::MLUCoreVersion core_version);
|
||||
// set MLU core number, which is used when compiling MLU kernels
|
||||
void set_mlu_core_number(int core_number);
|
||||
// set MLU input layout. User can specify layout of input data to be NHWC,
|
||||
// default is NCHW
|
||||
void set_mlu_input_layout(DataLayoutType layout);
|
||||
// whether use MLU's first conv kernel. First conv is a special kernel
|
||||
// provided by MLU, its input is uint8, and also needs two 3-dimentional
|
||||
// vectors which save all inputs' mean and std values
|
||||
void set_mlu_use_first_conv(bool use_first_conv);
|
||||
// set the 3-dimentional mean vector used by MLU's first conv
|
||||
void set_mlu_first_conv_mean(const std::vector<float>& mean);
|
||||
// set the 3-dimentional std vector used by MLU's first conv
|
||||
void set_mlu_first_conv_std(const std::vector<float>& std);
|
||||
|
||||
lite_api::MLUCoreVersion mlu_core_version() const;
|
||||
int mlu_core_number() const;
|
||||
DataLayoutType mlu_input_layout() const;
|
||||
bool mlu_use_first_conv() const;
|
||||
const std::vector<float>& mlu_first_conv_mean() const;
|
||||
const std::vector<float>& mlu_first_conv_std() const;
|
||||
#endif
|
||||
|
||||
// XPU only, set the size of the workspace memory from L3 cache for the
|
||||
// current thread.
|
||||
void set_xpu_workspace_l3_size_per_thread(int l3_size = 0xfffc00);
|
||||
// XPU only, specify the target device ID for the current thread.
|
||||
// **DEPRECATED**, use xpu_set_device() at the very beginning of each worker
|
||||
// thread
|
||||
void set_xpu_dev_per_thread(int dev_no = 0);
|
||||
};
|
||||
|
||||
/// MobileConfig is the config for the light weight predictor, it will skip
|
||||
/// IR optimization or other unnecessary stages.
|
||||
class LITE_API MobileConfig : public ConfigBase {
|
||||
// whether to load data from memory. Model data will be loaded from memory
|
||||
// buffer if model_from_memory_ is true.
|
||||
bool model_from_memory_{false};
|
||||
|
||||
// model data readed from file or memory buffer in combined format.
|
||||
std::string lite_model_file_;
|
||||
|
||||
// NOTE: This is a deprecated variable and will be removed in latter release.
|
||||
std::string model_buffer_;
|
||||
std::string param_buffer_;
|
||||
|
||||
public:
|
||||
// set model data in combined format, `set_model_from_file` refers to loading
|
||||
// model from file, set_model_from_buffer refers to loading model from memory
|
||||
// buffer
|
||||
void set_model_from_file(const std::string& x);
|
||||
void set_model_from_buffer(const std::string& x);
|
||||
// return model data in lite_model_file_, which is in combined format.
|
||||
const std::string& lite_model_file() const { return lite_model_file_; }
|
||||
|
||||
// return model_from_memory_, which indicates whether to load model from
|
||||
// memory buffer.
|
||||
bool model_from_memory() const { return model_from_memory_; }
|
||||
|
||||
// NOTE: This is a deprecated API and will be removed in latter release.
|
||||
void set_model_buffer(const char* model_buffer,
|
||||
size_t model_buffer_size,
|
||||
const char* param_buffer,
|
||||
size_t param_buffer_size);
|
||||
|
||||
// NOTE: This is a deprecated API and will be removed in latter release.
|
||||
const std::string& model_buffer() const { return model_buffer_; }
|
||||
|
||||
// NOTE: This is a deprecated API and will be removed in latter release.
|
||||
const std::string& param_buffer() const { return param_buffer_; }
|
||||
};
|
||||
|
||||
template <typename ConfigT>
|
||||
LITE_API std::shared_ptr<PaddlePredictor> CreatePaddlePredictor(const ConfigT&);
|
||||
|
||||
} // namespace lite_api
|
||||
} // namespace paddle
|
||||
|
||||
#endif // NOLINT
|
||||
@ -1,44 +0,0 @@
|
||||
// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*
|
||||
* This file defines some MACROS that explicitly determine the op, kernel, mir
|
||||
* passes used in the inference lib.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
// some platform-independent defintion
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define UNUSED
|
||||
#define __builtin_expect(EXP, C) (EXP)
|
||||
#else
|
||||
#define UNUSED __attribute__((unused))
|
||||
#endif
|
||||
|
||||
#define USE_LITE_OP(op_type__) \
|
||||
extern int touch_op_##op_type__(); \
|
||||
int LITE_OP_REGISTER_FAKE(op_type__) UNUSED = touch_op_##op_type__();
|
||||
|
||||
#define USE_LITE_KERNEL(op_type__, target__, precision__, layout__, alias__) \
|
||||
extern int touch_##op_type__##target__##precision__##layout__##alias__(); \
|
||||
int op_type__##target__##precision__##layout__##alias__##__use_lite_kernel \
|
||||
UNUSED = touch_##op_type__##target__##precision__##layout__##alias__();
|
||||
|
||||
#define USE_MIR_PASS(name__) \
|
||||
extern bool mir_pass_registry##name__##_fake(); \
|
||||
static bool mir_pass_usage##name__ UNUSED = \
|
||||
mir_pass_registry##name__##_fake();
|
||||
|
||||
#define LITE_OP_REGISTER_FAKE(op_type__) op_type__##__registry__
|
||||
@ -1,223 +0,0 @@
|
||||
// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
// Generic helper definitions for shared library support
|
||||
#if defined _WIN32 || defined __CYGWIN__
|
||||
#define PADDLE_LITE_HELPER_DLL_IMPORT __declspec(dllimport)
|
||||
#define PADDLE_LITE_HELPER_DLL_EXPORT __declspec(dllexport)
|
||||
#define PADDLE_LITE_HELPER_DLL_LOCAL
|
||||
#else
|
||||
#if __GNUC__ >= 4
|
||||
#define PADDLE_LITE_HELPER_DLL_IMPORT __attribute__((visibility("default")))
|
||||
#define PADDLE_LITE_HELPER_DLL_EXPORT __attribute__((visibility("default")))
|
||||
#else
|
||||
#define PADDLE_LITE_HELPER_DLL_IMPORT
|
||||
#define PADDLE_LITE_HELPER_DLL_EXPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LITE_ON_TINY_PUBLISH
|
||||
#define LITE_API PADDLE_LITE_HELPER_DLL_EXPORT
|
||||
#define LITE_API_IMPORT PADDLE_LITE_HELPER_DLL_IMPORT
|
||||
#else
|
||||
#define LITE_API
|
||||
#define LITE_API_IMPORT
|
||||
#endif
|
||||
|
||||
namespace paddle {
|
||||
namespace lite_api {
|
||||
|
||||
enum class TargetType : int {
|
||||
kUnk = 0,
|
||||
kHost = 1,
|
||||
kX86 = 2,
|
||||
kCUDA = 3,
|
||||
kARM = 4,
|
||||
kOpenCL = 5,
|
||||
kAny = 6, // any target
|
||||
kFPGA = 7,
|
||||
kNPU = 8,
|
||||
kXPU = 9,
|
||||
kBM = 10,
|
||||
kMLU = 11,
|
||||
kRKNPU = 12,
|
||||
kAPU = 13,
|
||||
NUM = 14, // number of fields.
|
||||
};
|
||||
enum class PrecisionType : int {
|
||||
kUnk = 0,
|
||||
kFloat = 1,
|
||||
kInt8 = 2,
|
||||
kInt32 = 3,
|
||||
kAny = 4, // any precision
|
||||
kFP16 = 5,
|
||||
kBool = 6,
|
||||
kInt64 = 7,
|
||||
kInt16 = 8,
|
||||
NUM = 9, // number of fields.
|
||||
};
|
||||
enum class DataLayoutType : int {
|
||||
kUnk = 0,
|
||||
kNCHW = 1,
|
||||
kNHWC = 3,
|
||||
kImageDefault = 4, // for opencl image2d
|
||||
kImageFolder = 5, // for opencl image2d
|
||||
kImageNW = 6, // for opencl image2d
|
||||
kAny = 2, // any data layout
|
||||
NUM = 7, // number of fields.
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
LITE_POWER_HIGH = 0,
|
||||
LITE_POWER_LOW = 1,
|
||||
LITE_POWER_FULL = 2,
|
||||
LITE_POWER_NO_BIND = 3,
|
||||
LITE_POWER_RAND_HIGH = 4,
|
||||
LITE_POWER_RAND_LOW = 5
|
||||
} PowerMode;
|
||||
|
||||
typedef enum { MLU_220 = 0, MLU_270 = 1 } MLUCoreVersion;
|
||||
|
||||
enum class ActivationType : int {
|
||||
kIndentity = 0,
|
||||
kRelu = 1,
|
||||
kRelu6 = 2,
|
||||
kPRelu = 3,
|
||||
kLeakyRelu = 4,
|
||||
kSigmoid = 5,
|
||||
kTanh = 6,
|
||||
kSwish = 7,
|
||||
kExp = 8,
|
||||
kAbs = 9,
|
||||
kHardSwish = 10,
|
||||
kReciprocal = 11,
|
||||
NUM = 12,
|
||||
};
|
||||
|
||||
static size_t PrecisionTypeLength(PrecisionType type) {
|
||||
switch (type) {
|
||||
case PrecisionType::kFloat:
|
||||
return 4;
|
||||
case PrecisionType::kInt8:
|
||||
return 1;
|
||||
case PrecisionType::kInt32:
|
||||
return 4;
|
||||
case PrecisionType::kInt64:
|
||||
return 8;
|
||||
case PrecisionType::kFP16:
|
||||
return 2;
|
||||
default:
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct PrecisionTypeTrait {
|
||||
constexpr static PrecisionType Type() { return PrecisionType::kUnk; }
|
||||
};
|
||||
|
||||
#define _ForEachPrecisionTypeHelper(callback, cpp_type, precision_type) \
|
||||
callback(cpp_type, ::paddle::lite_api::PrecisionType::precision_type);
|
||||
|
||||
#define _ForEachPrecisionType(callback) \
|
||||
_ForEachPrecisionTypeHelper(callback, bool, kBool); \
|
||||
_ForEachPrecisionTypeHelper(callback, float, kFloat); \
|
||||
_ForEachPrecisionTypeHelper(callback, int8_t, kInt8); \
|
||||
_ForEachPrecisionTypeHelper(callback, int16_t, kInt16); \
|
||||
_ForEachPrecisionTypeHelper(callback, int, kInt32); \
|
||||
_ForEachPrecisionTypeHelper(callback, int64_t, kInt64);
|
||||
|
||||
#define DefinePrecisionTypeTrait(cpp_type, precision_type) \
|
||||
template <> \
|
||||
struct PrecisionTypeTrait<cpp_type> { \
|
||||
constexpr static PrecisionType Type() { return precision_type; } \
|
||||
}
|
||||
|
||||
_ForEachPrecisionType(DefinePrecisionTypeTrait);
|
||||
|
||||
#undef _ForEachPrecisionTypeHelper
|
||||
#undef _ForEachPrecisionType
|
||||
#undef DefinePrecisionTypeTrait
|
||||
|
||||
#define TARGET(item__) paddle::lite_api::TargetType::item__
|
||||
#define PRECISION(item__) paddle::lite_api::PrecisionType::item__
|
||||
#define DATALAYOUT(item__) paddle::lite_api::DataLayoutType::item__
|
||||
|
||||
const std::string& ActivationTypeToStr(ActivationType act);
|
||||
|
||||
const std::string& TargetToStr(TargetType target);
|
||||
|
||||
const std::string& PrecisionToStr(PrecisionType precision);
|
||||
|
||||
const std::string& DataLayoutToStr(DataLayoutType layout);
|
||||
|
||||
const std::string& TargetRepr(TargetType target);
|
||||
|
||||
const std::string& PrecisionRepr(PrecisionType precision);
|
||||
|
||||
const std::string& DataLayoutRepr(DataLayoutType layout);
|
||||
|
||||
// Get a set of all the elements represented by the target.
|
||||
std::set<TargetType> ExpandValidTargets(TargetType target = TARGET(kAny));
|
||||
|
||||
// Get a set of all the elements represented by the precision.
|
||||
std::set<PrecisionType> ExpandValidPrecisions(
|
||||
PrecisionType precision = PRECISION(kAny));
|
||||
|
||||
// Get a set of all the elements represented by the layout.
|
||||
std::set<DataLayoutType> ExpandValidLayouts(
|
||||
DataLayoutType layout = DATALAYOUT(kAny));
|
||||
|
||||
/*
|
||||
* Place specifies the execution context of a Kernel or input/output for a
|
||||
* kernel. It is used to make the analysis of the MIR more clear and accurate.
|
||||
*/
|
||||
struct LITE_API Place {
|
||||
TargetType target{TARGET(kUnk)};
|
||||
PrecisionType precision{PRECISION(kUnk)};
|
||||
DataLayoutType layout{DATALAYOUT(kUnk)};
|
||||
int16_t device{0}; // device ID
|
||||
|
||||
Place() = default;
|
||||
Place(TargetType target,
|
||||
PrecisionType precision = PRECISION(kFloat),
|
||||
DataLayoutType layout = DATALAYOUT(kNCHW),
|
||||
int16_t device = 0)
|
||||
: target(target), precision(precision), layout(layout), device(device) {}
|
||||
|
||||
bool is_valid() const {
|
||||
return target != TARGET(kUnk) && precision != PRECISION(kUnk) &&
|
||||
layout != DATALAYOUT(kUnk);
|
||||
}
|
||||
|
||||
size_t hash() const;
|
||||
|
||||
bool operator==(const Place& other) const {
|
||||
return target == other.target && precision == other.precision &&
|
||||
layout == other.layout && device == other.device;
|
||||
}
|
||||
|
||||
bool operator!=(const Place& other) const { return !(*this == other); }
|
||||
|
||||
friend bool operator<(const Place& a, const Place& b);
|
||||
|
||||
std::string DebugString() const;
|
||||
};
|
||||
|
||||
} // namespace lite_api
|
||||
} // namespace paddle
|
||||
@ -1,104 +0,0 @@
|
||||
#pragma once
|
||||
#include "paddle_lite_factory_helper.h"
|
||||
|
||||
USE_LITE_KERNEL(yolo_box, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(fetch, kHost, kAny, kAny, def);
|
||||
USE_LITE_KERNEL(relu, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(leaky_relu, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(relu_clipped, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(prelu, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(sigmoid, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(tanh, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(swish, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(relu6, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(log, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(exp, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(floor, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(hard_sigmoid, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(rsqrt, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(square, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(hard_swish, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(reciprocal, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(abs, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(fc, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(fc, kARM, kInt8, kNCHW, int8out);
|
||||
USE_LITE_KERNEL(fc, kARM, kInt8, kNCHW, fp32out);
|
||||
USE_LITE_KERNEL(feed, kHost, kAny, kAny, def);
|
||||
USE_LITE_KERNEL(calib, kARM, kInt8, kNCHW, fp32_to_int8);
|
||||
USE_LITE_KERNEL(calib, kARM, kInt8, kNCHW, int8_to_fp32);
|
||||
USE_LITE_KERNEL(calib, kARM, kInt8, kNHWC, fp32_to_int8);
|
||||
USE_LITE_KERNEL(calib, kARM, kInt8, kNHWC, int8_to_fp32);
|
||||
USE_LITE_KERNEL(calib_once, kARM, kInt8, kNCHW, fp32_to_int8);
|
||||
USE_LITE_KERNEL(calib_once, kARM, kInt8, kNCHW, int8_to_fp32);
|
||||
USE_LITE_KERNEL(calib_once, kARM, kInt8, kNHWC, fp32_to_int8);
|
||||
USE_LITE_KERNEL(calib_once, kARM, kInt8, kNHWC, int8_to_fp32);
|
||||
USE_LITE_KERNEL(reduce_mean, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(cast, kARM, kAny, kNCHW, def);
|
||||
USE_LITE_KERNEL(transpose, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(transpose2, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(affine_channel, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(grid_sampler, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(fill_constant_batch_size_like, kARM, kAny, kNCHW, def);
|
||||
USE_LITE_KERNEL(pad2d, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(slice, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(slice, kARM, kInt32, kNCHW, def);
|
||||
USE_LITE_KERNEL(unsqueeze, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(unsqueeze2, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(stack, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(concat, kARM, kAny, kNCHW, def);
|
||||
USE_LITE_KERNEL(squeeze, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(squeeze2, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(dropout, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(mul, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(conv2d, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(depthwise_conv2d, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(conv2d, kARM, kInt8, kNCHW, int8_out);
|
||||
USE_LITE_KERNEL(conv2d, kARM, kInt8, kNCHW, fp32_out);
|
||||
USE_LITE_KERNEL(depthwise_conv2d, kARM, kInt8, kNCHW, int8_out);
|
||||
USE_LITE_KERNEL(depthwise_conv2d, kARM, kInt8, kNCHW, fp32_out);
|
||||
USE_LITE_KERNEL(arg_max, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(scale, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(scale, kARM, kInt32, kNCHW, def);
|
||||
USE_LITE_KERNEL(conv2d_transpose, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(reshape, kHost, kAny, kAny, def);
|
||||
USE_LITE_KERNEL(reshape2, kHost, kAny, kAny, def);
|
||||
USE_LITE_KERNEL(flatten, kHost, kAny, kAny, def);
|
||||
USE_LITE_KERNEL(flatten2, kHost, kAny, kAny, def);
|
||||
USE_LITE_KERNEL(elementwise_add, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(fusion_elementwise_add_activation, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(elementwise_sub, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(fusion_elementwise_sub_activation, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(elementwise_mul, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(elementwise_mul, kARM, kInt32, kNCHW, def);
|
||||
USE_LITE_KERNEL(elementwise_mul, kARM, kInt64, kNCHW, def);
|
||||
USE_LITE_KERNEL(fusion_elementwise_mul_activation, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(elementwise_max, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(fusion_elementwise_max_activation, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(elementwise_div, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(fusion_elementwise_div_activation, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(prior_box, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(split, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(pool2d, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(subgraph, kNPU, kAny, kNCHW, def);
|
||||
USE_LITE_KERNEL(batch_norm, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(matmul, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(box_coder, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(softmax, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(fill_constant, kARM, kAny, kNCHW, def);
|
||||
USE_LITE_KERNEL(layout, kARM, kFloat, kNCHW, nchw2nhwc);
|
||||
USE_LITE_KERNEL(layout, kARM, kFloat, kNCHW, nhwc2nchw);
|
||||
USE_LITE_KERNEL(layout, kARM, kInt8, kNCHW, int8_nchw2nhwc);
|
||||
USE_LITE_KERNEL(layout, kARM, kInt8, kNCHW, int8_nhwc2nchw);
|
||||
USE_LITE_KERNEL(layout_once, kARM, kFloat, kNCHW, nchw2nhwc);
|
||||
USE_LITE_KERNEL(layout_once, kARM, kFloat, kNCHW, nhwc2nchw);
|
||||
USE_LITE_KERNEL(layout_once, kARM, kInt8, kNCHW, int8_nchw2nhwc);
|
||||
USE_LITE_KERNEL(layout_once, kARM, kInt8, kNCHW, int8_nhwc2nchw);
|
||||
USE_LITE_KERNEL(multiclass_nms, kHost, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(multiclass_nms2, kHost, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(density_prior_box, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(shuffle_channel, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(bilinear_interp, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(nearest_interp, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(instance_norm, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(range, kARM, kFloat, kNCHW, def);
|
||||
USE_LITE_KERNEL(expand, kARM, kFloat, kNCHW, def);
|
||||
@ -1,80 +0,0 @@
|
||||
#pragma once
|
||||
#include "paddle_lite_factory_helper.h"
|
||||
|
||||
USE_LITE_OP(prior_box);
|
||||
USE_LITE_OP(matmul);
|
||||
USE_LITE_OP(grid_sampler);
|
||||
USE_LITE_OP(fake_channel_wise_dequantize_max_abs);
|
||||
USE_LITE_OP(split);
|
||||
USE_LITE_OP(box_coder);
|
||||
USE_LITE_OP(subgraph);
|
||||
USE_LITE_OP(scale);
|
||||
USE_LITE_OP(fusion_elementwise_sub_activation);
|
||||
USE_LITE_OP(fusion_elementwise_add_activation);
|
||||
USE_LITE_OP(fusion_elementwise_mul_activation);
|
||||
USE_LITE_OP(fusion_elementwise_max_activation);
|
||||
USE_LITE_OP(fusion_elementwise_div_activation);
|
||||
USE_LITE_OP(calib);
|
||||
USE_LITE_OP(fake_quantize_moving_average_abs_max);
|
||||
USE_LITE_OP(squeeze);
|
||||
USE_LITE_OP(squeeze2);
|
||||
USE_LITE_OP(fill_constant_batch_size_like);
|
||||
USE_LITE_OP(nearest_interp);
|
||||
USE_LITE_OP(bilinear_interp);
|
||||
USE_LITE_OP(stack);
|
||||
USE_LITE_OP(concat);
|
||||
USE_LITE_OP(io_copy_once);
|
||||
USE_LITE_OP(fake_quantize_dequantize_moving_average_abs_max);
|
||||
USE_LITE_OP(fake_quantize_range_abs_max);
|
||||
USE_LITE_OP(fake_quantize_abs_max);
|
||||
USE_LITE_OP(sequence_topk_avg_pooling);
|
||||
USE_LITE_OP(affine_channel);
|
||||
USE_LITE_OP(arg_max);
|
||||
USE_LITE_OP(sigmoid);
|
||||
USE_LITE_OP(tanh);
|
||||
USE_LITE_OP(relu);
|
||||
USE_LITE_OP(leaky_relu);
|
||||
USE_LITE_OP(relu6);
|
||||
USE_LITE_OP(prelu);
|
||||
USE_LITE_OP(transpose);
|
||||
USE_LITE_OP(transpose2);
|
||||
USE_LITE_OP(search_fc);
|
||||
USE_LITE_OP(fetch);
|
||||
USE_LITE_OP(fill_constant);
|
||||
USE_LITE_OP(range);
|
||||
USE_LITE_OP(mul);
|
||||
USE_LITE_OP(softmax);
|
||||
USE_LITE_OP(multiclass_nms);
|
||||
USE_LITE_OP(multiclass_nms2);
|
||||
USE_LITE_OP(shuffle_channel);
|
||||
USE_LITE_OP(density_prior_box);
|
||||
USE_LITE_OP(instance_norm);
|
||||
USE_LITE_OP(fake_dequantize_max_abs);
|
||||
USE_LITE_OP(yolo_box);
|
||||
USE_LITE_OP(conv2d_transpose);
|
||||
USE_LITE_OP(depthwise_conv2d_transpose);
|
||||
USE_LITE_OP(expand);
|
||||
USE_LITE_OP(pad2d);
|
||||
USE_LITE_OP(slice);
|
||||
USE_LITE_OP(pool2d);
|
||||
USE_LITE_OP(io_copy);
|
||||
USE_LITE_OP(flatten);
|
||||
USE_LITE_OP(flatten2);
|
||||
USE_LITE_OP(unsqueeze);
|
||||
USE_LITE_OP(unsqueeze2);
|
||||
USE_LITE_OP(reshape);
|
||||
USE_LITE_OP(reshape2);
|
||||
USE_LITE_OP(conv2d);
|
||||
USE_LITE_OP(depthwise_conv2d);
|
||||
USE_LITE_OP(feed);
|
||||
USE_LITE_OP(batch_norm);
|
||||
USE_LITE_OP(elementwise_sub);
|
||||
USE_LITE_OP(elementwise_add);
|
||||
USE_LITE_OP(elementwise_mul);
|
||||
USE_LITE_OP(elementwise_max);
|
||||
USE_LITE_OP(elementwise_div);
|
||||
USE_LITE_OP(dropout);
|
||||
USE_LITE_OP(fc);
|
||||
USE_LITE_OP(cast);
|
||||
USE_LITE_OP(reduce_mean);
|
||||
USE_LITE_OP(layout);
|
||||
@ -1,58 +0,0 @@
|
||||
// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
#include "paddle_lite_factory_helper.h" // NOLINT
|
||||
|
||||
USE_MIR_PASS(demo);
|
||||
USE_MIR_PASS(static_kernel_pick_pass);
|
||||
USE_MIR_PASS(variable_place_inference_pass);
|
||||
USE_MIR_PASS(type_target_cast_pass);
|
||||
USE_MIR_PASS(generate_program_pass);
|
||||
|
||||
USE_MIR_PASS(io_copy_kernel_pick_pass);
|
||||
USE_MIR_PASS(argument_type_display_pass);
|
||||
USE_MIR_PASS(runtime_context_assign_pass);
|
||||
USE_MIR_PASS(graph_visualize_pass);
|
||||
|
||||
USE_MIR_PASS(lite_conv_bn_fuse_pass);
|
||||
USE_MIR_PASS(lite_fc_fuse_pass);
|
||||
USE_MIR_PASS(lite_shuffle_channel_fuse_pass);
|
||||
USE_MIR_PASS(lite_transpose_softmax_transpose_fuse_pass);
|
||||
USE_MIR_PASS(lite_interpolate_fuse_pass);
|
||||
USE_MIR_PASS(lite_sequence_pool_concat_fuse_pass);
|
||||
USE_MIR_PASS(identity_scale_eliminate_pass);
|
||||
USE_MIR_PASS(identity_dropout_eliminate_pass);
|
||||
USE_MIR_PASS(lite_conv_elementwise_fuse_pass);
|
||||
USE_MIR_PASS(lite_conv_activation_fuse_pass);
|
||||
USE_MIR_PASS(lite_var_conv_2d_activation_fuse_pass);
|
||||
USE_MIR_PASS(lite_elementwise_add_activation_fuse_pass);
|
||||
USE_MIR_PASS(lite_quant_dequant_fuse_pass);
|
||||
USE_MIR_PASS(type_precision_cast_pass);
|
||||
USE_MIR_PASS(type_layout_cast_pass);
|
||||
USE_MIR_PASS(type_layout_cast_preprocess_pass);
|
||||
USE_MIR_PASS(memory_optimize_pass);
|
||||
USE_MIR_PASS(multi_stream_analysis_pass);
|
||||
USE_MIR_PASS(elementwise_mul_constant_eliminate_pass)
|
||||
USE_MIR_PASS(npu_subgraph_pass);
|
||||
USE_MIR_PASS(xpu_subgraph_pass);
|
||||
USE_MIR_PASS(mlu_subgraph_pass);
|
||||
USE_MIR_PASS(mlu_postprocess_pass);
|
||||
USE_MIR_PASS(weight_quantization_preprocess_pass);
|
||||
USE_MIR_PASS(apu_subgraph_pass);
|
||||
USE_MIR_PASS(quantized_op_attributes_inference_pass);
|
||||
USE_MIR_PASS(__xpu__resnet_fuse_pass);
|
||||
USE_MIR_PASS(__xpu__multi_encoder_fuse_pass);
|
||||
USE_MIR_PASS(__xpu__embedding_with_eltwise_add_fuse_pass);
|
||||
USE_MIR_PASS(__xpu__fc_fuse_pass);
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,21 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
Binary file not shown.
@ -1,20 +0,0 @@
|
||||
{
|
||||
"version": 1,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "com.example.administrator.baiduvoicetest",
|
||||
"variantName": "release",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"properties": [],
|
||||
"versionCode": 100000,
|
||||
"versionName": "1.0",
|
||||
"enabled": true,
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
|
||||
@ -1,26 +0,0 @@
|
||||
package com.example.administrator.baiduvoicetest;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
assertEquals("com.baidu.paddle.lite.demo", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@ -1,105 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.example.administrator.baiduvoicetest"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".LoginActivity"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".NotesActivity"
|
||||
android:label="@string/title_activity_notes" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".RigisterActivity"
|
||||
android:label="@string/title_activity_rigister" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".SettingsActivity"
|
||||
android:label="Settings">
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity">
|
||||
</activity>
|
||||
|
||||
<meta-data android:name="com.baidu.speech.APP_ID" android:value="8888274"/>
|
||||
<meta-data android:name="com.baidu.speech.API_KEY" android:value="FOFOGnjFERG3UTZC4FdDnXhM"/>
|
||||
<meta-data android:name="com.baidu.speech.SECRET_KEY" android:value="63830985f5b05d2863f13ad07c7feaa3"/>
|
||||
<service android:name="com.baidu.speech.VoiceRecognitionService" android:exported="false" />
|
||||
<activity
|
||||
android:name="com.baidu.voicerecognition.android.ui.BaiduASRDigitalDialog"
|
||||
android:configChanges="orientation|keyboardHidden|screenLayout"
|
||||
android:theme="@android:style/Theme.Dialog"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="com.baidu.action.RECOGNIZE_SPEECH" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- end : baidu speech sdk-->
|
||||
</application>
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
|
||||
</manifest>
|
||||
<!--<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.baidu.paddle.lite.demo.image_classification">
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".MainActivity1">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".SettingsActivity"
|
||||
android:label="Settings">
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>-->
|
||||
@ -1,4 +0,0 @@
|
||||
百度语音识别SDK在demo程序中assets目录的文件解释说明:
|
||||
license-android-easr_recognizedemo.txt 离线授权文件, 该文件与包名相关, 故请勿放置到自己的app中
|
||||
WakeUp.bin 唤醒功能的唤醒词配置文件, 需要在百度语音开发平台中定义和导出
|
||||
baidu_speech_grammar.bsg 自定义语义以及离线识别共用的语法文件, 需要在百度语音开发平台中定义和导出
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 136 KiB |
@ -1,40 +0,0 @@
|
||||
0 其他垃圾/一次性快餐盒
|
||||
1 其他垃圾/污损塑料
|
||||
2 其他垃圾/烟蒂
|
||||
3 其他垃圾/牙签
|
||||
4 其他垃圾/破碎花盆及碟碗
|
||||
5 其他垃圾/竹筷
|
||||
6 厨余垃圾/剩饭剩菜
|
||||
7 厨余垃圾/大骨头
|
||||
8 厨余垃圾/水果果皮
|
||||
9 厨余垃圾/水果果肉
|
||||
10 厨余垃圾/茶叶渣
|
||||
11 厨余垃圾/菜叶菜根
|
||||
12 厨余垃圾/蛋壳
|
||||
13 厨余垃圾/鱼骨
|
||||
14 可回收物/充电宝
|
||||
15 可回收物/包
|
||||
16 可回收物/化妆品瓶
|
||||
17 可回收物/塑料玩具
|
||||
18 可回收物/塑料碗盆
|
||||
19 可回收物/塑料衣架
|
||||
20 可回收物/快递纸袋
|
||||
21 可回收物/插头电线
|
||||
22 可回收物/旧衣服
|
||||
23 可回收物/易拉罐
|
||||
24 可回收物/枕头
|
||||
25 可回收物/毛绒玩具
|
||||
26 可回收物/洗发水瓶
|
||||
27 可回收物/玻璃杯
|
||||
28 可回收物/皮鞋
|
||||
29 可回收物/砧板
|
||||
30 可回收物/纸板箱
|
||||
31 可回收物/调料瓶
|
||||
32 可回收物/酒瓶
|
||||
33 可回收物/金属食品罐
|
||||
34 可回收物/锅
|
||||
35 可回收物/食用油桶
|
||||
36 可回收物/饮料瓶
|
||||
37 有害垃圾/干电池
|
||||
38 有害垃圾/软膏
|
||||
39 有害垃圾/过期药物
|
||||
@ -1 +0,0 @@
|
||||
acfcb9c8b0260c3716134d26152f47ac60a08c922ac4c612cf9b769e2feca9574aa981255bcd9bc0d0cb306cee8f7bc7bad433108240724160c9fd95d580e36e518b285fe595f8e2394013fb17f07a580acfe74e6454e1a27b3916fcd52bcd4a192b3cda88ddb3dcf267dd7a9ee0148211803b6d6cb0b4ac3450528b545e1f3b822fd78e8db3c35847b21d673d61d89ae3ab3178e4a584d5e0a7f38deedbe0dbb90ec907955b5f08015cdb50e97adadc8c1e935cf66127e7ba8036e63df77560a76d86c4781a7f3cc24a04d595472216df3905965643a36bdaffeedcfc0b35f090ac02b268698a77ec092ce0548a3e1e5e2c9a6ffb5d949c202be3367af75f6a
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,202 +0,0 @@
|
||||
package com.example.administrator.baiduvoicetest;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SettingsActivity extends AppCompatPreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
ListPreference lpChoosePreInstalledModel = null;
|
||||
CheckBoxPreference cbEnableCustomSettings = null;
|
||||
EditTextPreference etModelPath = null;
|
||||
EditTextPreference etLabelPath = null;
|
||||
EditTextPreference etImagePath = null;
|
||||
ListPreference lpCPUThreadNum = null;
|
||||
ListPreference lpCPUPowerMode = null;
|
||||
ListPreference lpInputColorFormat = null;
|
||||
EditTextPreference etInputShape = null;
|
||||
EditTextPreference etInputMean = null;
|
||||
EditTextPreference etInputStd = null;
|
||||
|
||||
List<String> preInstalledModelPaths = null;
|
||||
List<String> preInstalledLabelPaths = null;
|
||||
List<String> preInstalledImagePaths = null;
|
||||
List<String> preInstalledCPUThreadNums = null;
|
||||
List<String> preInstalledCPUPowerModes = null;
|
||||
List<String> preInstalledInputShapes = null;
|
||||
List<String> preInstalledInputColorFormats = null;
|
||||
List<String> preInstalledInputMeans = null;
|
||||
List<String> preInstalledInputStds = null;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.settings);
|
||||
ActionBar supportActionBar = getSupportActionBar();
|
||||
if (supportActionBar != null) {
|
||||
supportActionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
// Initialized pre-installed models
|
||||
preInstalledModelPaths = new ArrayList<String>();
|
||||
preInstalledLabelPaths = new ArrayList<String>();
|
||||
preInstalledImagePaths = new ArrayList<String>();
|
||||
preInstalledInputShapes = new ArrayList<String>();
|
||||
preInstalledCPUThreadNums = new ArrayList<String>();
|
||||
preInstalledCPUPowerModes = new ArrayList<String>();
|
||||
preInstalledInputColorFormats = new ArrayList<String>();
|
||||
preInstalledInputMeans = new ArrayList<String>();
|
||||
preInstalledInputStds = new ArrayList<String>();
|
||||
// Add mobilenet_v1_for_cpu
|
||||
preInstalledModelPaths.add(getString(R.string.MODEL_PATH_DEFAULT));
|
||||
preInstalledLabelPaths.add(getString(R.string.LABEL_PATH_DEFAULT));
|
||||
preInstalledImagePaths.add(getString(R.string.IMAGE_PATH_DEFAULT));
|
||||
preInstalledCPUThreadNums.add(getString(R.string.CPU_THREAD_NUM_DEFAULT));
|
||||
preInstalledCPUPowerModes.add(getString(R.string.CPU_POWER_MODE_DEFAULT));
|
||||
preInstalledInputColorFormats.add(getString(R.string.INPUT_COLOR_FORMAT_DEFAULT));
|
||||
preInstalledInputShapes.add(getString(R.string.INPUT_SHAPE_DEFAULT));
|
||||
preInstalledInputMeans.add(getString(R.string.INPUT_MEAN_DEFAULT));
|
||||
preInstalledInputStds.add(getString(R.string.INPUT_STD_DEFAULT));
|
||||
// Add mobilenet_v1_for_npu if Soc is kirin 810 or 990
|
||||
if (Utils.isSupportedNPU()) {
|
||||
preInstalledModelPaths.add("models/mobilenet_v1_for_npu");
|
||||
preInstalledLabelPaths.add("labels/synset_words.txt");
|
||||
preInstalledImagePaths.add("images/tabby_cat.jpg");
|
||||
preInstalledCPUThreadNums.add("1"); // Useless for NPU
|
||||
preInstalledCPUPowerModes.add("LITE_POWER_HIGH"); // Useless for NPU
|
||||
preInstalledInputColorFormats.add("RGB");
|
||||
preInstalledInputShapes.add("1,3,224,224");
|
||||
preInstalledInputMeans.add("0.485,0.456,0.406");
|
||||
preInstalledInputStds.add("0.229,0.224,0.225");
|
||||
} else {
|
||||
Toast.makeText(this, "NPU model is not supported by your device.", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
// Setup UI components
|
||||
lpChoosePreInstalledModel =
|
||||
(ListPreference) findPreference(getString(R.string.CHOOSE_PRE_INSTALLED_MODEL_KEY));
|
||||
String[] preInstalledModelNames = new String[preInstalledModelPaths.size()];
|
||||
for (int i = 0; i < preInstalledModelPaths.size(); i++) {
|
||||
preInstalledModelNames[i] =
|
||||
preInstalledModelPaths.get(i).substring(preInstalledModelPaths.get(i).lastIndexOf("/") + 1);
|
||||
}
|
||||
lpChoosePreInstalledModel.setEntries(preInstalledModelNames);
|
||||
lpChoosePreInstalledModel.setEntryValues(preInstalledModelPaths.toArray(new String[preInstalledModelPaths.size()]));
|
||||
lpCPUThreadNum =
|
||||
(ListPreference) findPreference(getString(R.string.CPU_THREAD_NUM_KEY));
|
||||
lpCPUPowerMode =
|
||||
(ListPreference) findPreference(getString(R.string.CPU_POWER_MODE_KEY));
|
||||
cbEnableCustomSettings =
|
||||
(CheckBoxPreference) findPreference(getString(R.string.ENABLE_CUSTOM_SETTINGS_KEY));
|
||||
etModelPath = (EditTextPreference) findPreference(getString(R.string.MODEL_PATH_KEY));
|
||||
etModelPath.setTitle("Model Path (SDCard: " + Utils.getSDCardDirectory() + ")");
|
||||
etLabelPath = (EditTextPreference) findPreference(getString(R.string.LABEL_PATH_KEY));
|
||||
etImagePath = (EditTextPreference) findPreference(getString(R.string.IMAGE_PATH_KEY));
|
||||
lpInputColorFormat =
|
||||
(ListPreference) findPreference(getString(R.string.INPUT_COLOR_FORMAT_KEY));
|
||||
etInputShape = (EditTextPreference) findPreference(getString(R.string.INPUT_SHAPE_KEY));
|
||||
etInputMean = (EditTextPreference) findPreference(getString(R.string.INPUT_MEAN_KEY));
|
||||
etInputStd = (EditTextPreference) findPreference(getString(R.string.INPUT_STD_KEY));
|
||||
}
|
||||
|
||||
private void reloadPreferenceAndUpdateUI() {
|
||||
SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
|
||||
boolean enableCustomSettings =
|
||||
sharedPreferences.getBoolean(getString(R.string.ENABLE_CUSTOM_SETTINGS_KEY), false);
|
||||
String modelPath = sharedPreferences.getString(getString(R.string.CHOOSE_PRE_INSTALLED_MODEL_KEY),
|
||||
getString(R.string.MODEL_PATH_DEFAULT));
|
||||
int modelIdx = lpChoosePreInstalledModel.findIndexOfValue(modelPath);
|
||||
if (modelIdx >= 0 && modelIdx < preInstalledModelPaths.size()) {
|
||||
if (!enableCustomSettings) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(getString(R.string.MODEL_PATH_KEY), preInstalledModelPaths.get(modelIdx));
|
||||
editor.putString(getString(R.string.LABEL_PATH_KEY), preInstalledLabelPaths.get(modelIdx));
|
||||
editor.putString(getString(R.string.IMAGE_PATH_KEY), preInstalledImagePaths.get(modelIdx));
|
||||
editor.putString(getString(R.string.CPU_THREAD_NUM_KEY), preInstalledCPUThreadNums.get(modelIdx));
|
||||
editor.putString(getString(R.string.CPU_POWER_MODE_KEY), preInstalledCPUPowerModes.get(modelIdx));
|
||||
editor.putString(getString(R.string.INPUT_COLOR_FORMAT_KEY),
|
||||
preInstalledInputColorFormats.get(modelIdx));
|
||||
editor.putString(getString(R.string.INPUT_SHAPE_KEY), preInstalledInputShapes.get(modelIdx));
|
||||
editor.putString(getString(R.string.INPUT_MEAN_KEY), preInstalledInputMeans.get(modelIdx));
|
||||
editor.putString(getString(R.string.INPUT_STD_KEY), preInstalledInputStds.get(modelIdx));
|
||||
editor.commit();
|
||||
}
|
||||
lpChoosePreInstalledModel.setSummary(modelPath);
|
||||
}
|
||||
cbEnableCustomSettings.setChecked(enableCustomSettings);
|
||||
etModelPath.setEnabled(enableCustomSettings);
|
||||
etLabelPath.setEnabled(enableCustomSettings);
|
||||
etImagePath.setEnabled(enableCustomSettings);
|
||||
lpCPUThreadNum.setEnabled(enableCustomSettings);
|
||||
lpCPUPowerMode.setEnabled(enableCustomSettings);
|
||||
lpInputColorFormat.setEnabled(enableCustomSettings);
|
||||
etInputShape.setEnabled(enableCustomSettings);
|
||||
etInputMean.setEnabled(enableCustomSettings);
|
||||
etInputStd.setEnabled(enableCustomSettings);
|
||||
modelPath = sharedPreferences.getString(getString(R.string.MODEL_PATH_KEY),
|
||||
getString(R.string.MODEL_PATH_DEFAULT));
|
||||
String labelPath = sharedPreferences.getString(getString(R.string.LABEL_PATH_KEY),
|
||||
getString(R.string.LABEL_PATH_DEFAULT));
|
||||
String imagePath = sharedPreferences.getString(getString(R.string.IMAGE_PATH_KEY),
|
||||
getString(R.string.IMAGE_PATH_DEFAULT));
|
||||
String cpuThreadNum = sharedPreferences.getString(getString(R.string.CPU_THREAD_NUM_KEY),
|
||||
getString(R.string.CPU_THREAD_NUM_DEFAULT));
|
||||
String cpuPowerMode = sharedPreferences.getString(getString(R.string.CPU_POWER_MODE_KEY),
|
||||
getString(R.string.CPU_POWER_MODE_DEFAULT));
|
||||
String inputColorFormat = sharedPreferences.getString(getString(R.string.INPUT_COLOR_FORMAT_KEY),
|
||||
getString(R.string.INPUT_COLOR_FORMAT_DEFAULT));
|
||||
String inputShape = sharedPreferences.getString(getString(R.string.INPUT_SHAPE_KEY),
|
||||
getString(R.string.INPUT_SHAPE_DEFAULT));
|
||||
String inputMean = sharedPreferences.getString(getString(R.string.INPUT_MEAN_KEY),
|
||||
getString(R.string.INPUT_MEAN_DEFAULT));
|
||||
String inputStd = sharedPreferences.getString(getString(R.string.INPUT_STD_KEY),
|
||||
getString(R.string.INPUT_STD_DEFAULT));
|
||||
etModelPath.setSummary(modelPath);
|
||||
etModelPath.setText(modelPath);
|
||||
etLabelPath.setSummary(labelPath);
|
||||
etLabelPath.setText(labelPath);
|
||||
etImagePath.setSummary(imagePath);
|
||||
etImagePath.setText(imagePath);
|
||||
lpCPUThreadNum.setValue(cpuThreadNum);
|
||||
lpCPUThreadNum.setSummary(cpuThreadNum);
|
||||
lpCPUPowerMode.setValue(cpuPowerMode);
|
||||
lpCPUPowerMode.setSummary(cpuPowerMode);
|
||||
lpInputColorFormat.setValue(inputColorFormat);
|
||||
lpInputColorFormat.setSummary(inputColorFormat);
|
||||
etInputShape.setSummary(inputShape);
|
||||
etInputShape.setText(inputShape);
|
||||
etInputMean.setSummary(inputMean);
|
||||
etInputMean.setText(inputMean);
|
||||
etInputStd.setSummary(inputStd);
|
||||
etInputStd.setText(inputStd);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
||||
reloadPreferenceAndUpdateUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
if (key.equals(getString(R.string.CHOOSE_PRE_INSTALLED_MODEL_KEY))) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putBoolean(getString(R.string.ENABLE_CUSTOM_SETTINGS_KEY), false);
|
||||
editor.commit();
|
||||
}
|
||||
reloadPreferenceAndUpdateUI();
|
||||
}
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
package com.example.administrator.baiduvoicetest;
|
||||
|
||||
/**
|
||||
* 实体类
|
||||
*/
|
||||
public class Uploadfile {
|
||||
|
||||
public int fid;
|
||||
public String dateline;
|
||||
public String userip;
|
||||
public String uploadfile;
|
||||
public int status;
|
||||
|
||||
public int getFid() {
|
||||
return fid;
|
||||
}
|
||||
|
||||
public void setFid(int fid) {
|
||||
this.fid = fid;
|
||||
}
|
||||
|
||||
public String getDateline() {
|
||||
return dateline;
|
||||
}
|
||||
|
||||
public void setDateline(String dateline) {
|
||||
this.dateline = dateline;
|
||||
}
|
||||
|
||||
public String getUserip() {
|
||||
return userip;
|
||||
}
|
||||
|
||||
public void setUserip(String userip) {
|
||||
this.userip = userip;
|
||||
}
|
||||
|
||||
public String getUploadfile() {
|
||||
return uploadfile;
|
||||
}
|
||||
|
||||
public void setUploadfile(String uploadfile) {
|
||||
this.uploadfile = uploadfile;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Uploadfile{" +
|
||||
"fid=" + fid +
|
||||
", dateline='" + dateline + '\'' +
|
||||
", userip='" + userip + '\'' +
|
||||
", uploadfile='" + uploadfile + '\'' +
|
||||
", status=" + status +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,87 +0,0 @@
|
||||
package com.example.administrator.baiduvoicetest;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Environment;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class Utils {
|
||||
private static final String TAG = Utils.class.getSimpleName();
|
||||
|
||||
public static void copyFileFromAssets(Context appCtx, String srcPath, String dstPath) {
|
||||
if (srcPath.isEmpty() || dstPath.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
InputStream is = null;
|
||||
OutputStream os = null;
|
||||
try {
|
||||
is = new BufferedInputStream(appCtx.getAssets().open(srcPath));
|
||||
os = new BufferedOutputStream(new FileOutputStream(new File(dstPath)));
|
||||
byte[] buffer = new byte[1024];
|
||||
int length = 0;
|
||||
while ((length = is.read(buffer)) != -1) {
|
||||
os.write(buffer, 0, length);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
os.close();
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyDirectoryFromAssets(Context appCtx, String srcDir, String dstDir) {
|
||||
if (srcDir.isEmpty() || dstDir.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (!new File(dstDir).exists()) {
|
||||
new File(dstDir).mkdirs();
|
||||
}
|
||||
for (String fileName : appCtx.getAssets().list(srcDir)) {
|
||||
String srcSubPath = srcDir + File.separator + fileName;
|
||||
String dstSubPath = dstDir + File.separator + fileName;
|
||||
if (new File(srcSubPath).isDirectory()) {
|
||||
copyDirectoryFromAssets(appCtx, srcSubPath, dstSubPath);
|
||||
} else {
|
||||
copyFileFromAssets(appCtx, srcSubPath, dstSubPath);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static float[] parseFloatsFromString(String string, String delimiter) {
|
||||
String[] pieces = string.trim().toLowerCase().split(delimiter);
|
||||
float[] floats = new float[pieces.length];
|
||||
for (int i = 0; i < pieces.length; i++) {
|
||||
floats[i] = Float.parseFloat(pieces[i].trim());
|
||||
}
|
||||
return floats;
|
||||
}
|
||||
|
||||
public static long[] parseLongsFromString(String string, String delimiter) {
|
||||
String[] pieces = string.trim().toLowerCase().split(delimiter);
|
||||
long[] longs = new long[pieces.length];
|
||||
for (int i = 0; i < pieces.length; i++) {
|
||||
longs[i] = Long.parseLong(pieces[i].trim());
|
||||
}
|
||||
return longs;
|
||||
}
|
||||
|
||||
public static String getSDCardDirectory() {
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
}
|
||||
|
||||
public static boolean isSupportedNPU() {
|
||||
String hardware = android.os.Build.HARDWARE;
|
||||
return hardware.equalsIgnoreCase("kirin810") || hardware.equalsIgnoreCase("kirin990");
|
||||
}
|
||||
}
|
||||
@ -1,190 +0,0 @@
|
||||
package com.example.administrator.baiduvoicetest.fragment;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.lidroid.xutils.BitmapUtils;
|
||||
import com.lidroid.xutils.HttpUtils;
|
||||
import com.lidroid.xutils.exception.HttpException;
|
||||
import com.lidroid.xutils.http.RequestParams;
|
||||
import com.lidroid.xutils.http.ResponseInfo;
|
||||
import com.lidroid.xutils.http.callback.RequestCallBack;
|
||||
import com.lidroid.xutils.http.client.HttpRequest;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
public class ShanChuan {
|
||||
|
||||
// 测试路径(默认值)
|
||||
static String testPath = "/sdcard/Pictures/t.jpg";//"/storage/sdcard/Download/t.jpg";
|
||||
//Environment.getExternalStorageDirectory().getAbsolutePath()
|
||||
//+ "/test.jpg";///storage/sdcard/Download/android-env.jpg
|
||||
|
||||
// Button btn_send;// "上传"按钮
|
||||
// ImageView iv; // 图片框
|
||||
|
||||
static String baseUrl = "http://192.168.56.1/demo/";
|
||||
static String infoUrl = baseUrl + "uploadfile_get.php";
|
||||
static String upUrl = baseUrl + "uploadfile.php";
|
||||
private final Activity activity;
|
||||
|
||||
public ShanChuan(Activity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
// 发送文件
|
||||
public void sendFile(Bitmap pic, String name) throws IOException {
|
||||
// 接口地址
|
||||
String url = upUrl;
|
||||
// String filepath = testPath;
|
||||
File file = saveFile(pic,name);
|
||||
if (file.exists()) {
|
||||
upload(url, file);
|
||||
}else{
|
||||
// show("你给的文件路径不存在");
|
||||
Log.d("myTag", "你给的文件路径不存在");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成上传文件
|
||||
* @param url 上传接口的网址
|
||||
* @param uploadfile 要上传文件对象
|
||||
*/
|
||||
public void upload(String url, File uploadfile) {
|
||||
RequestParams params = new RequestParams();
|
||||
// 这里必须按照文档写
|
||||
params.addBodyParameter("uploadfile", uploadfile);
|
||||
// btn_send.setEnabled(false);
|
||||
// 发送请求
|
||||
new HttpUtils().send(
|
||||
HttpRequest.HttpMethod.POST,// 上传必须是POST
|
||||
url,
|
||||
params,
|
||||
new RequestCallBack<String>() {
|
||||
@Override
|
||||
public void onSuccess(ResponseInfo<String> info) {
|
||||
|
||||
String result = info.result.trim();// 上传文件的数据库ID
|
||||
// show("上传后的结果:"+result);
|
||||
Log.d("myTag", "上传后的结果");
|
||||
|
||||
result = result.substring(result.indexOf("{")+1);// 从{开始截取,包含{
|
||||
if (result.equals("0")) {
|
||||
//show("上传失败");
|
||||
Log.d("myTag", "上传失败");
|
||||
Toast.makeText(activity, "上传失败", Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
//show("上传成功,新ID是:" + result);
|
||||
Toast.makeText(activity, "图片上传成功", Toast.LENGTH_LONG).show();
|
||||
Log.d("myTag", "上传成功");
|
||||
}
|
||||
// btn_send.setEnabled(true);
|
||||
// 获取服务器信息,展示上传的图片
|
||||
Log.d("myTag", "取服务器信息,展示上传的图片");
|
||||
//getUploadedInfo(infoUrl,result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException e, String s) {
|
||||
//show("网络失败:" + s);
|
||||
// btn_send.setEnabled(true);
|
||||
Log.d("myTag", "网络失败");
|
||||
Toast.makeText(activity, "网络失败", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/* public void show(String msg){
|
||||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
|
||||
Log.i("spl",msg);
|
||||
}*/
|
||||
/**
|
||||
* 获取上传文件的信息
|
||||
* @param url 接口的网址
|
||||
* @param fid ID
|
||||
*/
|
||||
public void getUploadedInfo(String url, String fid) {
|
||||
int ifid = Integer.parseInt(fid.trim());
|
||||
url = infoUrl + "?fid="+ifid;
|
||||
// show("url="+url);
|
||||
// 发送请求
|
||||
new HttpUtils().send(
|
||||
HttpRequest.HttpMethod.GET,
|
||||
url,
|
||||
|
||||
new RequestCallBack<String>() {
|
||||
@Override
|
||||
public void onSuccess(ResponseInfo<String> info) {
|
||||
|
||||
String result = info.result.trim();
|
||||
//show("刚获取的:"+result);
|
||||
result = result.substring(result.indexOf("{"));// 从{开始截取,包含{
|
||||
// show("截取后的:"+result);
|
||||
Uploadfile uploadfile = JSON.parseObject(result, Uploadfile.class);
|
||||
|
||||
String picUrl = baseUrl+uploadfile.getUploadfile();
|
||||
if (uploadfile == null) {
|
||||
// show("失败");
|
||||
} else {
|
||||
// show("成功,图片地址是:" + picUrl);
|
||||
}
|
||||
|
||||
//showPic(picUrl);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException e, String s) {
|
||||
//show("网络失败:" + s);
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/* private void showPic(String picUrl) {
|
||||
//show("图片地址:"+picUrl);
|
||||
//new BitmapUtils(this).display(iv,picUrl);
|
||||
}*/
|
||||
public File saveFile(Bitmap bm, String name) throws IOException {
|
||||
String fileName = "";
|
||||
if (name != null && name.contains("/")) {
|
||||
fileName = name.split("/")[1];
|
||||
} else {
|
||||
fileName = name;
|
||||
}
|
||||
|
||||
fileName =fileName+ new Date().getTime() + ".jpg";
|
||||
// String path = "/sdcard/Pictures" + "/cads";
|
||||
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/";
|
||||
File dirFile = new File(path);
|
||||
if (!dirFile.exists()) {
|
||||
dirFile.mkdir();
|
||||
}
|
||||
File myCaptureFile = new File(path + fileName);
|
||||
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile));
|
||||
bm.compress(Bitmap.CompressFormat.JPEG, 80, bos);
|
||||
bos.flush();
|
||||
bos.close();
|
||||
Log.d("myTag", "file转换");
|
||||
return myCaptureFile;
|
||||
}
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
package com.example.administrator.baiduvoicetest.fragment;
|
||||
|
||||
/**
|
||||
* 实体类
|
||||
*/
|
||||
public class Uploadfile {
|
||||
|
||||
public int fid;
|
||||
public String dateline;
|
||||
public String userip;
|
||||
public String uploadfile;
|
||||
public int status;
|
||||
|
||||
public int getFid() {
|
||||
return fid;
|
||||
}
|
||||
|
||||
public void setFid(int fid) {
|
||||
this.fid = fid;
|
||||
}
|
||||
|
||||
public String getDateline() {
|
||||
return dateline;
|
||||
}
|
||||
|
||||
public void setDateline(String dateline) {
|
||||
this.dateline = dateline;
|
||||
}
|
||||
|
||||
public String getUserip() {
|
||||
return userip;
|
||||
}
|
||||
|
||||
public void setUserip(String userip) {
|
||||
this.userip = userip;
|
||||
}
|
||||
|
||||
public String getUploadfile() {
|
||||
return uploadfile;
|
||||
}
|
||||
|
||||
public void setUploadfile(String uploadfile) {
|
||||
this.uploadfile = uploadfile;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Uploadfile{" +
|
||||
"fid=" + fid +
|
||||
", dateline='" + dateline + '\'' +
|
||||
", userip='" + userip + '\'' +
|
||||
", uploadfile='" + uploadfile + '\'' +
|
||||
", status=" + status +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue