diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml
index 40eaa1f..453ead5 100644
--- a/.idea/deploymentTargetSelector.xml
+++ b/.idea/deploymentTargetSelector.xml
@@ -2,9 +2,12 @@
+
+
+
-
+
@@ -13,9 +16,6 @@
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 74dd639..b2c751a 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,3 @@
-
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 4e02246..4ee5257 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -21,7 +21,7 @@ media3Common = "1.4.0"
composeMaterial3 = "1.0.0-alpha23"
workRuntimeKtx = "2.9.1"
lifecycleRuntimeKtx = "2.6.1"
-litert = "1.0.1"
+#litert = "1.0.1"
[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -51,7 +51,7 @@ androidx-compose-material3 = { group = "androidx.wear.compose", name = "compose-
androidx-work-runtime-ktx = { group = "androidx.work", name = "work-runtime-ktx", version.ref = "workRuntimeKtx" }
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
-litert = { group = "com.google.ai.edge.litert", name = "litert", version.ref = "litert" }
+#litert = { group = "com.google.ai.edge.litert", name = "litert", version.ref = "litert" }
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
diff --git a/mobile/build.gradle.kts b/mobile/build.gradle.kts
index c4eb328..64d2ab7 100644
--- a/mobile/build.gradle.kts
+++ b/mobile/build.gradle.kts
@@ -51,11 +51,13 @@ dependencies {
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
+ implementation("org.tensorflow:tensorflow-lite:2.6.0")
+// implementation("com.google.android.gms:play-services-tflite:20.0.0")
implementation("uk.me.berndporr:iirj:1.7")
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
- implementation(libs.litert)
+// implementation(libs.litert)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
diff --git a/mobile/src/main/java/com/birdsounds/identify/Downloader.java b/mobile/src/main/java/com/birdsounds/identify/Downloader.java
index 151808d..ae96ea5 100644
--- a/mobile/src/main/java/com/birdsounds/identify/Downloader.java
+++ b/mobile/src/main/java/com/birdsounds/identify/Downloader.java
@@ -21,8 +21,8 @@ import java.security.NoSuchAlgorithmException;
@SuppressWarnings("ResultOfMethodCallIgnored")
public class Downloader {
- static final String modelFILE = "model.tflite";
- static final String metaModelFILE = "metaModel.tflite";
+ static final String modelFILE = "modelfx.tflite";
+ static final String metaModelFILE = "metaModelfx.tflite";
static final String modelURL = "https://raw.githubusercontent.com/woheller69/whoBIRD-TFlite/master/BirdNET_GLOBAL_6K_V2.4_Model_FP16.tflite";
static final String model32URL = "https://raw.githubusercontent.com/woheller69/whoBIRD-TFlite/master/BirdNET_GLOBAL_6K_V2.4_Model_FP32.tflite";
static final String metaModelURL = "https://raw.githubusercontent.com/woheller69/whoBIRD-TFlite/master/BirdNET_GLOBAL_6K_V2.4_MData_Model_FP16.tflite";
@@ -63,8 +63,6 @@ public class Downloader {
public static void downloadModels(final Activity activity) {
File modelFile = new File(activity.getDir("filesdir", Context.MODE_PRIVATE) + "/" + modelFILE);
Log.d("Heyy","Model file checking");
- modelFile.delete();
-
if (!modelFile.exists()) {
Log.d("whoBIRD", "model file does not exist");
Thread thread = new Thread(() -> {
@@ -76,6 +74,7 @@ public class Downloader {
Log.d("whoBIRD", "Download model");
URLConnection ucon = url.openConnection();
+ Log.d("whoBIRD", "i am here");
ucon.setReadTimeout(5000);
ucon.setConnectTimeout(10000);
@@ -86,11 +85,12 @@ public class Downloader {
FileOutputStream outStream = new FileOutputStream(modelFile);
byte[] buff = new byte[5 * 1024];
-
int len;
+
while ((len = inStream.read(buff)) != -1) {
outStream.write(buff, 0, len);
}
+
outStream.flush();
outStream.close();
inStream.close();
@@ -117,10 +117,15 @@ public class Downloader {
} catch (NoSuchAlgorithmException | IOException i) {
activity.runOnUiThread(() -> Toast.makeText(activity, activity.getResources().getString(R.string.error_download), Toast.LENGTH_SHORT).show());
modelFile.delete();
- Log.w("whoBIRD", activity.getResources().getString(R.string.error_download), i);
}
});
thread.start();
+
+ try {
+ thread.join();
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
} else {
Log.d("whoBIRD","model exists");
activity.runOnUiThread(() -> {
@@ -181,6 +186,11 @@ public class Downloader {
}
});
thread.start();
+ try {
+ thread.join();
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
} else {
Log.d("whoBIRD", "meta file exists");
activity.runOnUiThread(() -> {
diff --git a/mobile/src/main/java/com/birdsounds/identify/MainActivity.kt b/mobile/src/main/java/com/birdsounds/identify/MainActivity.kt
index 73dabd4..6edb8e6 100644
--- a/mobile/src/main/java/com/birdsounds/identify/MainActivity.kt
+++ b/mobile/src/main/java/com/birdsounds/identify/MainActivity.kt
@@ -31,6 +31,7 @@ class MainActivity : AppCompatActivity() {
}
)
Downloader.downloadModels(this)
+
requestPermissions()
soundClassifier = SoundClassifier(this, SoundClassifier.Options())
Location.requestLocation(this, soundClassifier)
diff --git a/mobile/src/main/java/com/birdsounds/identify/SoundClassifier.kt b/mobile/src/main/java/com/birdsounds/identify/SoundClassifier.kt
index 73f2d4a..1d21321 100644
--- a/mobile/src/main/java/com/birdsounds/identify/SoundClassifier.kt
+++ b/mobile/src/main/java/com/birdsounds/identify/SoundClassifier.kt
@@ -45,9 +45,9 @@ class SoundClassifier(
/** Path of the converted .tflite file, relative to the assets/ directory. */
val assetFile: String = "assets.txt",
/** Path of the converted .tflite file, relative to the assets/ directory. */
- val modelPath: String = "model.tflite",
+ val modelPath: String = "modelfx.tflite",
/** Path of the meta model .tflite file, relative to the assets/ directory. */
- val metaModelPath: String = "metaModel.tflite",
+ val metaModelPath: String = "metaModelfx.tflite",
/** The required audio sample rate in Hz. */
val sampleRate: Int = 48000,
/** Multiplier for audio samples */