I managed to transform the ssd_mobilenet_v1_coco_2017_11_17 model to a dlc file.
The model ran on Android but the output is practically blank (only 1.0 for scores, 0.0 for boxes and classes)
I'm not sure what exactly is wrong.
float[] loadRgbBitmapAsFloat(Bitmap image) {
final int[] pixels = new int[image.getWidth() * image.getHeight()];
image.getPixels(pixels, 0, image.getWidth(), 0, 0,
image.getWidth(), image.getHeight());
final float[] pixelsBatched = new float[pixels.length * 3];
for (int y = 0; y < image.getHeight(); y++) {
for (int x = 0; x < image.getWidth(); x++) {
final int idx = y * image.getWidth() + x;
final int batchIdx = idx * 3;
final float[] rgb = extractColorChannels(pixels[idx]);
pixelsBatched[batchIdx] = rgb[0];
pixelsBatched[batchIdx + 1] = rgb[1];
pixelsBatched[batchIdx + 2] = rgb[2];
}
}
return pixelsBatched;
}
private float[] extractColorChannels(int pixel) {
float b = ((pixel) & 0xFF);
float g = ((pixel >> 8) & 0xFF);
float r = ((pixel >> 16) & 0xFF);
return new float[] {r,g,b};
}
this is how I preprocessed the already cropped Image, which in this case is 300x300 (basically took it from the demo app). The model is unquantized and I am using FloatTensor. I did try to use UserBufferTensor but I got an error instead saying that the forward propagation did not work.
the model seems to be running at about 30-40 (execution time) ms so I assume that the input is wrong.
Hi mahendra,
You can try swap R and B channel, NN's input should be BGR format. and also make sure you don't involved Alpha channel in bitmap.
Update: I get same problem with DSP as backend, but CPU and GPU mode is ok.
Hello mr. Mahendra,
I know it's been quite a while since you posted this question but I'm currrently struggiling with the exact same issue, and couldn't find any inforamtion on the matter.
Can you please shed some light as to how you solved the blank SSD output problem?
Thank you very much!