Skip to content

Commit

Permalink
Release 0.2;
Browse files Browse the repository at this point in the history
Auto download faceboxes and tensorflow libs;
Fixes;
Refactored;
  • Loading branch information
iglaweb committed Oct 10, 2020
1 parent 49a5358 commit cd79c9b
Show file tree
Hide file tree
Showing 32 changed files with 294 additions and 9,571 deletions.
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ gen/
out/
obj/

*.apk

# Local configuration file (sdk path, etc)
local.properties

Expand Down Expand Up @@ -128,4 +126,8 @@ out

*.so
*.dylib
*.dat
*.dat

libs/

*.pb
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'com.igla.tensorflow_easy'
version '0.0.1'
version '0.0.2'

allprojects {
repositories {
Expand All @@ -10,14 +10,16 @@ allprojects {
}

buildscript {
ext.kotlin_version = '1.4.10'
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'de.undercouch:gradle-download-task:3.4.3'
classpath 'com.github.jengelman.gradle.plugins:shadow:5.2.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
Expand Down
7 changes: 6 additions & 1 deletion jvm-sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
plugins {
id 'java'
id 'de.undercouch.download'
}

// Download default models; if you wish to use your own models then
// place them in the "assets" directory and comment out this line.
apply from:'download_model.gradle'

group 'com.igla.tensorflow_easy'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

//java instructions https://www.tensorflow.org/install/lang_java
def TENSORFLOW_LIB = 'jvm-sample/libs/libtensorflow_jni-cpu-darwin-x86_64-2.3.0'
def TENSORFLOW_LIB = './jvm-sample/libs'
//TF jar https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-2.3.0.jar

repositories {
Expand Down
73 changes: 73 additions & 0 deletions jvm-sample/download_model.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
def tensorflowDownloadUrl = 'https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow_jni-cpu-darwin-x86_64-2.3.0.tar.gz'
def faceboxesDownloadUrl = 'https://drive.google.com/uc?export=download&id=18XrleLvdSujoNTgxHsJFtNPHOirnWlbV'

project.ext.tensorFlowTempLocalFolder = "tensorflow.tar.gz"
project.ext.faceboxesTempLocalFile = "faceboxes_model.pb"

project.ext.faceboxes = 'faceboxes'
project.ext.tensorflow = 'tensorflow'

project.ext.ASSET_DIR_TF = projectDir.toString() + '/libs/' //for tf dylib
project.ext.ASSET_DIR = projectDir.toString() + '/src/main/resources/'
project.ext.TMP_DIR = project.buildDir.toString() + '/downloads'

def targetFaceboxesFolder = project.ext.ASSET_DIR + project.ext.faceboxes
def targetTensorFlowFolder = project.ext.ASSET_DIR_TF

////////// TensorFlow

task downloadTensorFlow(type: Download) {
doFirst {
println "Build dir ${buildDir}"
println "Downloading ${tensorflowDownloadUrl}"
}
src tensorflowDownloadUrl
dest new File(buildDir, project.ext.tensorFlowTempLocalFolder)
overwrite false
}

task downloadAndCopyTensorFlow(dependsOn: downloadTensorFlow, type: Copy) {
doFirst {
println "Copying ${downloadTensorFlow.dest}"
}
from tarTree(downloadTensorFlow.dest)
into targetTensorFlowFolder
doLast {
println "Copied to ${targetTensorFlowFolder}"
}
}


////////// Faceboxes

task downloadFaceboxes(type: Download) {
doFirst {
println "Downloading ${faceboxesDownloadUrl}"
}
src faceboxesDownloadUrl
dest new File(buildDir, project.ext.faceboxesTempLocalFile)
overwrite false
}

task downloadAndCopyFaceboxes(dependsOn: downloadFaceboxes, type: Copy) {
doFirst {
println "Copying ${downloadFaceboxes.dest}"
}
from downloadFaceboxes.dest
into targetFaceboxesFolder
doLast {
println "Copied to ${targetFaceboxesFolder}"
}
}


task extractModels(type: Copy) {
dependsOn downloadAndCopyFaceboxes
dependsOn downloadAndCopyTensorFlow
}

tasks.whenTaskAdded { task ->
if (task.name == 'assemble') {
task.dependsOn 'extractModels'
}
}
Binary file added jvm-sample/libs/libopencv_java440.dylib
Binary file not shown.
203 changes: 0 additions & 203 deletions jvm-sample/libs/libtensorflow_jni-cpu-darwin-x86_64-2.3.0/LICENSE

This file was deleted.

Loading

0 comments on commit cd79c9b

Please sign in to comment.