Chr*_*agh 5 java android classification tensorflow tensorflow-lite
尝试运行代码实验室: https://codelabs.developers.google.com/codelabs/recognize-flowers-with-tensorflow-on-android/#6
我已经开发了自己的文件和列表文件,尽管当我开始通过 Android 运行它时似乎收到此错误:
java.lang.IllegalArgumentException: Label number 6 mismatch the shape on axis 1
然后它将我链接到这部分代码:
Map<String, Float> labeledProbability =
new TensorLabel(labels, probabilityProcessor.process(outputProbabilityBuffer))
.getMapWithFloatValue();
Trace.endSection();
Run Code Online (Sandbox Code Playgroud)
这是在分类结果部分
public List<Recognition> recognizeImage(final Bitmap bitmap, int sensorOrientation) {
// Logs this method so that it can be analyzed with systrace.
Trace.beginSection("recognizeImage");
Trace.beginSection("loadImage");
long startTimeForLoadImage = SystemClock.uptimeMillis();
inputImageBuffer = loadImage(bitmap, sensorOrientation);
long endTimeForLoadImage = SystemClock.uptimeMillis();
Trace.endSection();
LOGGER.v("Timecost to load the image: " + (endTimeForLoadImage - startTimeForLoadImage));
// Runs the inference call.
Trace.beginSection("runInference");
long startTimeForReference = SystemClock.uptimeMillis();
tflite.run(inputImageBuffer.getBuffer(), outputProbabilityBuffer.getBuffer().rewind());
long endTimeForReference = SystemClock.uptimeMillis();
Trace.endSection();
LOGGER.v("Timecost to run model inference: " + (endTimeForReference - startTimeForReference));
// Gets the map of label and probability.
Map<String, Float> labeledProbability =
new TensorLabel(labels, probabilityProcessor.process(outputProbabilityBuffer))
.getMapWithFloatValue();
Trace.endSection();
// Gets top-k results.
return getTopKProbability(labeledProbability);
}
Run Code Online (Sandbox Code Playgroud)
不知道为什么这有效任何人都可以帮忙吗?
| 归档时间: |
|
| 查看次数: |
1720 次 |
| 最近记录: |