-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Image Segmentation App Signed-off-by: QAIHM Team <[email protected]>
- Loading branch information
Showing
66 changed files
with
3,456 additions
and
341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
opencv45/native/3rdparty/libs/**/*.a filter=lfs diff=lfs merge=lfs -text | ||
opencv45/** filter=lfs diff=lfs merge=lfs -text | ||
snpe-release/** filter=lfs diff=lfs merge=lfs -text | ||
app/src/main/assets/* filter=lfs diff=lfs merge=lfs -text | ||
sdk/** filter=lfs diff=lfs merge=lfs -text | ||
app/src/main/jniLibs/** filter=lfs diff=lfs merge=lfs -text | ||
AIMET_4W8A_hrnet_posnet.onnx filter=lfs diff=lfs merge=lfs -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
### Requirements | ||
|
||
1. Java, android-sdk and sdkmanager is already set at user's end | ||
2. User should have Linux QNN SDK in local machine. | ||
3. ANDROID_HOME is set to android-sdk path | ||
4. AI-Hub is properly configured with user token. | ||
|
||
|
||
## Info | ||
Please execute build_apk.py. This script will compile and download a model from AI-Hub and paste it in your Android Project and Generate app-debug.apk | ||
Here, we resize the input image based on model input and gives a segmented map as output which marks every pixek into its corresponding class. | ||
|
||
## Preprocessing | ||
|
||
|
||
``` | ||
Bitmap scaledBitmap = Bitmap.createScaledBitmap(modelInputBitmap,inpDims_w, inpDims_h,true); | ||
float[][][][] floatInputArray = new float[1][inpDims_h][inpDims_w][3]; | ||
for (int x = 0; x < inpDims_h; x++) { | ||
for (int y = 0; y < inpDims_w; y++) { | ||
int pixel = scaledBitmap.getPixel(y, x); | ||
floatInputArray[0][x][y][0] = (((float)Color.red(pixel))/225f); | ||
floatInputArray[0][x][y][1] = ((float)Color.green(pixel)/255f); | ||
floatInputArray[0][x][y][2] = ((float)Color.blue(pixel)/255f); | ||
} | ||
} | ||
``` | ||
|
||
|
||
## PostProcessing | ||
|
||
|
||
``` | ||
float[] temparr = new float[outDims_w]; | ||
for (int i = 0; i < outDims_h; i++) { | ||
for (int j = 0; j < outDims_w; j++) { // Looping through the columns | ||
float max_val=Float.NEGATIVE_INFINITY; | ||
float maxIndex =-1; // Initializing the max value | ||
for (int k = 0; k < noOfClasses; k++) { // Looping through the remaining elements in the first axis | ||
if (output[0][i][j][k] > max_val) { // Comparing the current element with the max value | ||
maxIndex=k; | ||
max_val = output[0][i][j][k]; // Updating the max value if the current element is large | ||
} | ||
} | ||
temparr[j]=maxIndex; | ||
} | ||
src.put(i,0,temparr); | ||
} | ||
Imgproc.resize(src, dst, dst.size(), 0, 0, Imgproc.INTER_AREA); | ||
int z=0; | ||
for (int x = 0; x <modelInputBitmap.getHeight(); x++) { | ||
for (int y = 0; y <modelInputBitmap.getWidth(); y++){ | ||
segMap[z++] =(int)dst.get(x, y)[0]; | ||
} | ||
} | ||
``` | ||
|
||
### Build App: | ||
|
||
You have to run build_apk.py for Image Classification. It will generate superresolution-debug.apk and install it in connected device. | ||
|
||
|
||
build_apk.py [-h] -q QNNSDK [-m MODEL_NAME] [-path MODEL_PATH] | ||
|
||
``` | ||
options: | ||
-h, --help show this help message and exit | ||
-q QNNSDK, --qnnsdk QNNSDK Give path of QNN SDK (REQUIRED) | ||
-m MODEL_NAME, --model_name MODEL_NAME Model Name (Optional) | ||
-path MODEL_PATH, --model_path MODEL_PATH Model Path (Optional) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## This file must *NOT* be checked into Version Control Systems, | ||
# as it contains information specific to your local configuration. | ||
# | ||
# Location of the SDK. This is only used by Gradle. | ||
# For customization when using a Version Control System, please read the | ||
# header note. | ||
#Sat Jan 07 01:53:02 IST 2023 | ||
sdk.dir=C\:\\Users\\shubgoya\\AppData\\Local\\Android\\Sdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
41 changes: 41 additions & 0 deletions
41
apps/android/SemanticSegmentation/app/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.qcom.aihub_segmentation"> | ||
|
||
<uses-permission android:name="android.permission.CAMERA" /> | ||
<uses-feature android:name="android.hardware.camera" /> | ||
<application | ||
android:configChanges="orientation|screenSize" | ||
android:extractNativeLibs="true" | ||
android:allowBackup="true" | ||
android:hardwareAccelerated="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
|
||
<uses-native-library | ||
android:name="libcdsprpc.so" | ||
android:required="true"/> | ||
|
||
<uses-native-library | ||
android:name="libOpenCL.so" | ||
android:required="true"/> | ||
|
||
<activity android:name="com.qcom.aihub_segmentation.HomeScreenActivity" | ||
android:exported="true" | ||
android:screenOrientation="portrait"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<activity android:name="com.qcom.aihub_segmentation.MainActivity" | ||
android:screenOrientation="portrait"> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
3 changes: 3 additions & 0 deletions
3
apps/android/SemanticSegmentation/app/src/main/assets/ReadMe.txt
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
apps/android/SemanticSegmentation/app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.