From 0bbc2cf5cd8dab822b3337c664e487ad9964234e Mon Sep 17 00:00:00 2001 From: Cheng Yang Date: Sun, 10 Jan 2021 17:50:21 +0800 Subject: [PATCH 1/2] make project run with Android Studio 4 --- ImageSegmentation/build.gradle | 2 +- ImageSegmentation/gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ImageSegmentation/build.gradle b/ImageSegmentation/build.gradle index 6754c23d..04baf1e7 100644 --- a/ImageSegmentation/build.gradle +++ b/ImageSegmentation/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath "com.android.tools.build:gradle:4.0.1" + classpath 'com.android.tools.build:gradle:4.1.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/ImageSegmentation/gradle/wrapper/gradle-wrapper.properties b/ImageSegmentation/gradle/wrapper/gradle-wrapper.properties index 8eba0e70..db97decb 100644 --- a/ImageSegmentation/gradle/wrapper/gradle-wrapper.properties +++ b/ImageSegmentation/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip From 225cf7593d9f9e3c10ecf7a9fdf4e342acc4cf1a Mon Sep 17 00:00:00 2001 From: Cheng Yang Date: Sun, 10 Jan 2021 17:54:24 +0800 Subject: [PATCH 2/2] fix width/height indexing error for case when image is not a square --- .../app/src/main/assets/dog_landscape.jpg | Bin 0 -> 5756 bytes .../pytorch/imagesegmentation/MainActivity.java | 8 +++++--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 ImageSegmentation/app/src/main/assets/dog_landscape.jpg diff --git a/ImageSegmentation/app/src/main/assets/dog_landscape.jpg b/ImageSegmentation/app/src/main/assets/dog_landscape.jpg new file mode 100644 index 0000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cFZg&DtK#Lc!DSa`06aw|T|qAbXMC>M`A3+9(99;-6W?N&&G6yC~vbUc#%Lq-|H2b1ux_YkJl_ zgFLyYWaBfkpsp&9!wDHJg{!pTCR-1g35uMO>>j literal 0 HcmV?d00001 diff --git a/ImageSegmentation/app/src/main/java/org/pytorch/imagesegmentation/MainActivity.java b/ImageSegmentation/app/src/main/java/org/pytorch/imagesegmentation/MainActivity.java index f25da3cc..5520409b 100644 --- a/ImageSegmentation/app/src/main/java/org/pytorch/imagesegmentation/MainActivity.java +++ b/ImageSegmentation/app/src/main/java/org/pytorch/imagesegmentation/MainActivity.java @@ -75,8 +75,10 @@ protected void onCreate(Bundle savedInstanceState) { final Button buttonRestart = findViewById(R.id.restartButton); buttonRestart.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { - if (mImagename == "deeplab.jpg") + if (mImagename.equals("deeplab.jpg")) mImagename = "dog.jpg"; + else if (mImagename.equals("dog.jpg")) + mImagename = "dog_landscape.jpg"; else mImagename = "deeplab.jpg"; try { @@ -123,8 +125,8 @@ public void run() { int width = mBitmap.getWidth(); int height = mBitmap.getHeight(); int[] intValues = new int[width * height]; - for (int j = 0; j < width; j++) { - for (int k = 0; k < height; k++) { + for (int j = 0; j < height; j++) { + for (int k = 0; k < width; k++) { int maxi = 0, maxj = 0, maxk = 0; double maxnum = -Double.MAX_VALUE; for (int i = 0; i < CLASSNUM; i++) {