Skip to content

Commit

Permalink
V2.8
Browse files Browse the repository at this point in the history
Add option to use 32bit model
  • Loading branch information
woheller69 committed Apr 7, 2024
1 parent c926976 commit 54396b0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "org.woheller69.whobird"
minSdk 30
targetSdk 33
versionCode 27
versionName "2.7"
versionCode 28
versionName "2.8"
}

aaptOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ public class Downloader {
static String modelFILE = "model.tflite";
static String metaModelFILE = "metaModel.tflite";
static String modelURL = "https://raw.githubusercontent.com/woheller69/whoBIRD-TFlite/master/BirdNET_GLOBAL_6K_V2.4_Model_FP16.tflite";
static String model32URL = "https://raw.githubusercontent.com/woheller69/whoBIRD-TFlite/master/BirdNET_GLOBAL_6K_V2.4_Model_FP32.tflite";
static String metaModelURL = "https://raw.githubusercontent.com/woheller69/whoBIRD-TFlite/master/BirdNET_GLOBAL_6K_V2.4_MData_Model_FP16.tflite";
static String modelMD5 = "b1c981fe261910b473b9b7eec9ebcd4e";
static String model32MD5 = "6c7c42106e56550fc8563adb31bc120e";
static String metaModelMD5 ="f1a078ae0f244a1ff5a8f1ccb645c805";

public static boolean checkModels(final Activity activity) {
Expand All @@ -55,10 +57,10 @@ public static boolean checkModels(final Activity activity) {
}
}

if (modelFile.exists() && !calcModelMD5.equals(modelMD5)) modelFile.delete();
if (modelFile.exists() && !(calcModelMD5.equals(modelMD5) || calcModelMD5.equals(model32MD5))) modelFile.delete();
if (metaModelFile.exists() && !calcMetaModelMD5.equals(metaModelMD5)) metaModelFile.delete();

return calcModelMD5.equals(modelMD5) && calcMetaModelMD5.equals(metaModelMD5);
return (calcModelMD5.equals(modelMD5) || calcModelMD5.equals(model32MD5)) && calcMetaModelMD5.equals(metaModelMD5);
}

public static void downloadModels(final Activity activity, ActivityDownloadBinding binding) {
Expand All @@ -67,7 +69,10 @@ public static void downloadModels(final Activity activity, ActivityDownloadBindi
Log.d("whoBIRD", "model file does not exist");
Thread thread = new Thread(() -> {
try {
URL url = new URL(modelURL);
URL url;
if (binding.option32bit.isChecked()) url = new URL(model32URL);
else url = new URL(modelURL);

Log.d("whoBIRD", "Download model");

URLConnection ucon = url.openConnection();
Expand Down Expand Up @@ -99,7 +104,7 @@ public static void downloadModels(final Activity activity, ActivityDownloadBindi
throw new IOException(); //throw exception if there is no modelFile at this point
}

if (!calcModelMD5.equals(modelMD5)){
if (!(calcModelMD5.equals(modelMD5) || calcModelMD5.equals(model32MD5) )){
modelFile.delete();
activity.runOnUiThread(() -> {
Toast.makeText(activity, activity.getResources().getString(R.string.error_download), Toast.LENGTH_SHORT).show();
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/layout/activity_download.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
android:gravity="center"
android:textSize="18dp"
android:text="@string/download_model_text" />
<CheckBox
android:id="@+id/option32bit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="32bit (~55MB)"
android:textColor="@color/orange500"/>

<ImageButton
android:id="@+id/download_button"
Expand Down
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/28.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add option to use 32bit model

0 comments on commit 54396b0

Please sign in to comment.