tensorflow / tensorflow/models

.tflite model for SSD MobileNet v3 Object Detection Does Not Make Detections

Open
#7,960 2 comments 0 reactions 3 assignees View on GitHub

@pkulzc is already working on this.

Since Jun 4, 2020.

comp:lite models:research:odapi type:support
Dominant language
Python
Stars
77.7k
Forks
44.8k
PR merge metrics
No merged PRs in 30d

Description

Please go to Stack Overflow for help and support:

http://stackoverflow.com/questions/tagged/tensorflow

Also, please understand that many of the models included in this repository are experimental and research-style code. If you open a GitHub issue, here is our policy:

  1. It must be a bug, a feature request, or a significant problem with documentation (for small docs fixes please send a PR instead).
  2. The form below must be filled out.

Here's why we have that policy: TensorFlow developers respond to issues. We want to focus on work that benefits the whole community, e.g., fixing bugs and adding features. Support only helps individuals. GitHub also notifies thousands of people when issues are filed. We want them to see you communicating an interesting problem, rather than being redirected to Stack Overflow.


System information
Describe the problem

I can get other .tflite models to work for object detection, such as the default ssd_mobilenet_v1, but the ssd_mobilenet_v3 model won't produce a prediction confidence any larger than 10^-15, i.e., it never makes predictions. Unless I'm missing some fundamental difference between the way ssd_mobilenet_v3 takes input data ssd_mobilenet_v1 takes input data (which is possible, but I can't find any documentation that indicates this) then it seems like the ssd_mobilenet_v3 just doesn't work for whatever reason.

Source code / logs

Here is a summary of the code I'm using to feed the model input data:

//Note that the model takes a 320 x 320 image.

//Get image data as integer values
private int[] intValues;
intValues = new int[320 * 320];

private Bitmap croppedBitmap = null;
croppedBitmap = Bitmap.createBitmap(320, 320, Config.ARGB_8888);
croppedBitmap.getPixels(intValues, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());

//create ByteBuffer as input for running ssd_mobilenet_v3
private ByteBuffer imgData;
imgData = ByteBuffer.allocateDirect(320 * 320 * 3);
imgData.order(ByteOrder.nativeOrder());

//Fill Bytebuffer
//Note that & 0xFF is for just getting the last 8 bits, for converting to RGB values here
imgData.rewind();
for (int i = 0; i < inputSize; ++i) {
  for (int j = 0; j < inputSize; ++j) {
    int pixelValue = intValues[i * inputSize + j];
    // Quantized model
    imgData.put((byte) ((pixelValue >> 16) & 0xFF));
    imgData.put((byte) ((pixelValue >> 8) & 0xFF));
    imgData.put((byte) (pixelValue & 0xFF));
  }
}

// Set up output buffers
private float[][][] output0;
private float[][][][] output1;
output0 = new float[1][2034][91];
output1 = new float[1][2034][1][4];

//Create input HashMap and run the model
Object[] inputArray = {imgData};
Map<Integer, Object> outputMap = new HashMap<>();
outputMap.put(0, output0);
outputMap.put(1, output1);
tfLite.runForMultipleInputsOutputs(inputArray, outputMap);

//Examine Confidences
for (int i = 0; i < 2034; i++) {
  for (int j = 0; j < 91; j++) {
    System.out.println(output0[0][i][j]);
  }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.