Skip to content

Commit

Permalink
Rephrase model checks as what if version 1 or else
Browse files Browse the repository at this point in the history
  • Loading branch information
jtklein committed Jun 18, 2024
1 parent 17258cb commit 01dc6f7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,15 @@ private void convertBitmapToByteBuffer(Bitmap bitmap) {
for (int x = 0; x < ImageClassifier.DIM_IMG_SIZE_X; x++) {
for (int y = 0; y < ImageClassifier.DIM_IMG_SIZE_Y; y++) {
int pixel = bitmap.getPixel(x, y);
// TODO: rephrase to check for 1.0 version and have 2 as else
if (mModelVersion.equals("2.3") || mModelVersion.equals("2.4")) {
input[0][x][y][0] = Color.red(pixel);
input[0][x][y][1] = Color.green(pixel);
input[0][x][y][2] = Color.blue(pixel);
} else {
if (mModelVersion.equals("1.0")) {
// Normalize channel values to [0.0, 1.0] for version 1.0
input[0][x][y][0] = Color.red(pixel) / 255.0f;
input[0][x][y][1] = Color.green(pixel) / 255.0f;
input[0][x][y][2] = Color.blue(pixel) / 255.0f;
} else {
input[0][x][y][0] = Color.red(pixel);
input[0][x][y][1] = Color.green(pixel);
input[0][x][y][2] = Color.blue(pixel);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public Node(String line, String version) {
this.key = parts[1];
this.rank = Float.parseFloat(parts[2]);
this.leafId = parts[3];
if (version.equals("2.3") || version.equals("2.4")) {
if (version.equals("1.0")) {
this.name = parts[4];
} else {
this.iconicId = parts[4];
this.spatialId = parts[5];
this.name = parts[6];
} else {
this.name = parts[4];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public static Map nodeToMap(Prediction prediction) {
result.put("score", prediction.probability);
result.put("rank_level", (double) prediction.node.rank);
result.put("rank", RANK_LEVEL_TO_NAME.get(prediction.node.rank));
if (mModelVersion.equals("2.3") || mModelVersion.equals("2.4")) {
if (!mModelVersion.equals("1.0")) {
if ((prediction.node.iconicId != null) && (prediction.node.iconicId.length() > 0)) {
result.put("iconic_class_id", Integer.valueOf(prediction.node.iconicId));
}
Expand Down

0 comments on commit 01dc6f7

Please sign in to comment.