bujmp
This commit is contained in:
8
.idea/deploymentTargetSelector.xml
generated
8
.idea/deploymentTargetSelector.xml
generated
@@ -2,9 +2,12 @@
|
||||
<project version="4">
|
||||
<component name="deploymentTargetSelector">
|
||||
<selectionStates>
|
||||
<SelectionState runConfigName="mobile">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
</SelectionState>
|
||||
<SelectionState runConfigName="wear">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2025-03-03T16:49:07.365262400Z">
|
||||
<DropdownSelection timestamp="2025-03-03T17:08:48.726190400Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=569cc5b0" />
|
||||
@@ -13,9 +16,6 @@
|
||||
</DropdownSelection>
|
||||
<DialogSelection />
|
||||
</SelectionState>
|
||||
<SelectionState runConfigName="mobile">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
</SelectionState>
|
||||
</selectionStates>
|
||||
</component>
|
||||
</project>
|
||||
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@@ -1,4 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||
|
||||
@@ -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" }
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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(() -> {
|
||||
|
||||
@@ -31,6 +31,7 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
)
|
||||
Downloader.downloadModels(this)
|
||||
|
||||
requestPermissions()
|
||||
soundClassifier = SoundClassifier(this, SoundClassifier.Options())
|
||||
Location.requestLocation(this, soundClassifier)
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user