From 0195a08bcf6d7ed554898844c40b2e60abd0c977 Mon Sep 17 00:00:00 2001 From: Aadarsha Bastola Date: Tue, 8 Oct 2024 18:34:28 -0700 Subject: [PATCH 01/11] removed grayscale function --- mobile/ios/Podfile.lock | 7 +++++++ mobile/lib/screens/homepage.dart | 27 +++++++++++++++++---------- mobile/lib/widgets/sherd_details.dart | 12 ++++++++++-- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/mobile/ios/Podfile.lock b/mobile/ios/Podfile.lock index b830997..638b94a 100644 --- a/mobile/ios/Podfile.lock +++ b/mobile/ios/Podfile.lock @@ -1367,6 +1367,9 @@ PODS: - Flutter - FlutterMacOS - RecaptchaInterop (100.0.0) + - shared_preferences_foundation (0.0.1): + - Flutter + - FlutterMacOS - TensorFlowLiteC (2.12.0): - TensorFlowLiteC/Core (= 2.12.0) - TensorFlowLiteC/Core (2.12.0) @@ -1409,6 +1412,7 @@ DEPENDENCIES: - image_cropper (from `.symlinks/plugins/image_cropper/ios`) - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) + - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - tflite_flutter (from `.symlinks/plugins/tflite_flutter/ios`) - tflite_flutter_helper_plus (from `.symlinks/plugins/tflite_flutter_helper_plus/ios`) - tflite_flutter_plus (from `.symlinks/plugins/tflite_flutter_plus/ios`) @@ -1465,6 +1469,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/image_picker_ios/ios" path_provider_foundation: :path: ".symlinks/plugins/path_provider_foundation/darwin" + shared_preferences_foundation: + :path: ".symlinks/plugins/shared_preferences_foundation/darwin" tflite_flutter: :path: ".symlinks/plugins/tflite_flutter/ios" tflite_flutter_helper_plus: @@ -1508,6 +1514,7 @@ SPEC CHECKSUMS: nanopb: fad817b59e0457d11a5dfbde799381cd727c1275 path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 RecaptchaInterop: 7d1a4a01a6b2cb1610a47ef3f85f0c411434cb21 + shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 TensorFlowLiteC: 20785a69299185a379ba9852b6625f00afd7984a TensorFlowLiteSwift: 3a4928286e9e35bdd3e17970f48e53c80d25e793 tflite_flutter: 9433d086a3060431bbc9f3c7c20d017db0e72d08 diff --git a/mobile/lib/screens/homepage.dart b/mobile/lib/screens/homepage.dart index 6504d4a..842eed2 100644 --- a/mobile/lib/screens/homepage.dart +++ b/mobile/lib/screens/homepage.dart @@ -129,6 +129,10 @@ class _HomePageState extends State { return; } + setState(() { + selectedImage = File(croppedFile.path); + }); + //convert croppedFile to grayscale // Read the image file final File imageFile = File(croppedFile.path); @@ -142,19 +146,22 @@ class _HomePageState extends State { } // Convert the image to grayscale - img.Image grayscaleImage = img.grayscale(image); - imageForModel = grayscaleImage; + // img.Image grayscaleImage = img.grayscale(image); + + imageForModel = image; + + // imageForModel = grayscaleImage; // Encode the grayscale image back to PNG format - final List grayscaleBytes = img.encodePng(grayscaleImage); + // final List grayscaleBytes = img.encodePng(grayscaleImage); - // Save the grayscale image as a new file - final File grayscaleFile = - await File(croppedFile.path).writeAsBytes(grayscaleBytes); + // // Save the grayscale image as a new file + // final File grayscaleFile = + // await File(croppedFile.path).writeAsBytes(grayscaleBytes); - setState(() { - selectedImage = grayscaleFile; - }); + // setState(() { + // selectedImage = grayscaleFile; + // }); } void resetScreen() { @@ -535,7 +542,7 @@ class _HomePageState extends State { FittedBox( fit: BoxFit.contain, child: Text( - 'ABOUT\nTUYSAYAN\nWHITE\nWARE', + 'ABOUT\nTUSAYAN\nWHITE\nWARE', style: TextStyle( fontSize: 20, fontFamily: 'Uber', diff --git a/mobile/lib/widgets/sherd_details.dart b/mobile/lib/widgets/sherd_details.dart index 10f1184..a4eaca9 100644 --- a/mobile/lib/widgets/sherd_details.dart +++ b/mobile/lib/widgets/sherd_details.dart @@ -69,8 +69,16 @@ class SherdDetails extends StatelessWidget { ClipRRect( borderRadius: BorderRadius.circular(5), child: (!fromHive) - ? Image.network(imageUrl) - : Image.file(File(imageUrl)), + ? Image.network( + imageUrl, + width: double.infinity, + fit: BoxFit.cover, + ) + : Image.file( + File(imageUrl), + width: double.infinity, + fit: BoxFit.cover, + ), ), ExpansionTile( title: const Text('Model Confidence'), From c3834124a4f640fb8e74e87632c726d07e36f24a Mon Sep 17 00:00:00 2001 From: Aadarsha Bastola Date: Tue, 8 Oct 2024 18:40:07 -0700 Subject: [PATCH 02/11] minor details changes --- mobile/lib/widgets/sherd_details.dart | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/mobile/lib/widgets/sherd_details.dart b/mobile/lib/widgets/sherd_details.dart index a4eaca9..1395fb3 100644 --- a/mobile/lib/widgets/sherd_details.dart +++ b/mobile/lib/widgets/sherd_details.dart @@ -107,13 +107,16 @@ class SherdDetails extends StatelessWidget { ), ), const SizedBox(height: 16), - Center( - child: FilledButton( - onPressed: () { - Navigator.of(context).pop(); - }, - child: const Text('Dismiss'), - ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + FilledButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: const Text('Dismiss'), + ), + ], ), ], ), From a15eea430f8416cf57749d6f131900a4fb69025f Mon Sep 17 00:00:00 2001 From: Aadarsha Bastola Date: Wed, 9 Oct 2024 10:20:23 -0700 Subject: [PATCH 03/11] removed image grayscale feature --- mobile/lib/screens/homepage.dart | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/mobile/lib/screens/homepage.dart b/mobile/lib/screens/homepage.dart index 842eed2..dd3b77a 100644 --- a/mobile/lib/screens/homepage.dart +++ b/mobile/lib/screens/homepage.dart @@ -150,6 +150,8 @@ class _HomePageState extends State { imageForModel = image; + classifyImage(); + // imageForModel = grayscaleImage; // Encode the grayscale image back to PNG format @@ -225,7 +227,11 @@ class _HomePageState extends State { Map resultMap = {}; for (int i = 0; i < labels.length; i++) { - resultMap[labels[i]] = _outputBuffer.getDoubleList()[i]; + // resultMap[labels[i]] = _outputBuffer.getDoubleList()[i]; + double confidence = _outputBuffer.getDoubleList()[i]; + if (confidence > 0.1) { + resultMap[labels[i]] = confidence; + } } String highestConfidenceLabel = ''; double highestConfidenceValue = 0.0; @@ -687,14 +693,24 @@ class _HomePageState extends State { padding: const EdgeInsets.all(12.0), child: Column( children: [ - const Text('Primary Classification:'), + // const Text('Primary Classification:', + // style: + // TextStyle(fontWeight: FontWeight.bold)), Text( - "${classificatoinMap!['primaryClassification'].toString()} [${classificatoinMap!['allClassificatoins']?[classificatoinMap!['primaryClassification'].toString()].toStringAsFixed(3)}]", + "${classificatoinMap!['primaryClassification'].toString()} [${classificatoinMap!['allClassificatoins']?[classificatoinMap!['primaryClassification'].toStringAsFixed(3)] ?? ""}]", style: const TextStyle( fontSize: 20, fontWeight: FontWeight.bold), ), - Text( - "Location: ${classificatoinMap!['lattitude'].toStringAsFixed(4)}, ${classificatoinMap!['longitude'].toStringAsFixed(4)}"), + const Text( + 'All classifications and confidence:', + style: TextStyle(fontWeight: FontWeight.bold), + ), + ...classificatoinMap!['allClassificatoins'] + .entries + .map((entry) => Text( + '${entry.key}: ${entry.value.toStringAsFixed(3)}')), + // Text( + // "Location: ${classificatoinMap!['lattitude'].toStringAsFixed(4)}, ${classificatoinMap!['longitude'].toStringAsFixed(4)}"), // const Text("Other Classifications:"), ], )), From 99978d77a7897b932d793f9d17a0c5d94ab19072 Mon Sep 17 00:00:00 2001 From: Aadarsha Bastola Date: Mon, 14 Oct 2024 10:18:51 -0700 Subject: [PATCH 04/11] output disply change --- mobile/lib/screens/homepage.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mobile/lib/screens/homepage.dart b/mobile/lib/screens/homepage.dart index dd3b77a..3c67c27 100644 --- a/mobile/lib/screens/homepage.dart +++ b/mobile/lib/screens/homepage.dart @@ -697,12 +697,12 @@ class _HomePageState extends State { // style: // TextStyle(fontWeight: FontWeight.bold)), Text( - "${classificatoinMap!['primaryClassification'].toString()} [${classificatoinMap!['allClassificatoins']?[classificatoinMap!['primaryClassification'].toStringAsFixed(3)] ?? ""}]", + "${classificatoinMap!['primaryClassification'].toString()} [${classificatoinMap!['allClassificatoins']?[classificatoinMap!['primaryClassification']]?.toStringAsFixed(3) ?? "0.0"}]", style: const TextStyle( fontSize: 20, fontWeight: FontWeight.bold), ), const Text( - 'All classifications and confidence:', + 'Model Prediction:', style: TextStyle(fontWeight: FontWeight.bold), ), ...classificatoinMap!['allClassificatoins'] From 6f67ff267448d9e872941a8f1759d961c0a1294e Mon Sep 17 00:00:00 2001 From: Aadarsha Bastola Date: Wed, 6 Nov 2024 12:28:26 -0700 Subject: [PATCH 05/11] leszek suggestions --- mobile/android/app/src/main/AndroidManifest.xml | 3 ++- mobile/lib/screens/about/about_knaa.dart | 2 +- mobile/lib/screens/homepage.dart | 11 +++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mobile/android/app/src/main/AndroidManifest.xml b/mobile/android/app/src/main/AndroidManifest.xml index 527fe38..69838d2 100644 --- a/mobile/android/app/src/main/AndroidManifest.xml +++ b/mobile/android/app/src/main/AndroidManifest.xml @@ -13,7 +13,8 @@ android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" - android:windowSoftInputMode="adjustResize"> + android:windowSoftInputMode="adjustResize" + android:screenOrientation="portrait">