E/TensorFlowInferenceInterface: Failed to run TensorFlow inference with inputs:[conv2d_1_input], outputs:[dense_2/Softmax]
Uncaught exception on Future: Generic conv implementation does not support grouped convolutions for now.
我试图更改节点名称并运行模型,甚至尝试重新训练模型。我用于我的应用的基本分类器功能。
我正在Android Studio中使用Keras 2.2.4
和Tensorflow 1.13.1
,并生成.pb
文件。
问题:在“运行推理调用”处。
public List<Classifier.Recognize> recognizeImage(Bitmap bitmap) {
// Log this method so that it can be analyzed with systrace.
Trace.beginSection("recognizeImage");
Trace.beginSection("preprocessBitmap");
// Preprocess the image data from 0-255 int to normalized float based
// on the provided parameters.
bitmap.getPixels(intValues, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
for (int i = 0; i < intValues.length; ++i) {
final int val = intValues[i];
floatValues[i * 3 + 0] = (((val >> 16) & 0xFF) - imageMean) / imageStd;
floatValues[i * 3 + 1] = (((val >> 8) & 0xFF) - imageMean) / imageStd;
floatValues[i * 3 + 2] = ((val & 0xFF) - imageMean) / imageStd;
}
Trace.endSection();
// Copy the input data into TensorFlow.
Trace.beginSection("feed");
tensorFlowInferenceInterface.feed(inputName, floatValues, 1, inputsize, inputsize, 3);
Trace.endSection();
// Run the inference call.
Trace.beginSection("run");
tensorFlowInferenceInterface.run(outputNames, logstats);
Trace.endSection();
// Copy the output Tensor back into the output array.
Trace.beginSection("fetch");
tensorFlowInferenceInterface.fetch(outputName, outputs);
Trace.endSection();
// Find the best classifications.
PriorityQueue<Recognize> pq =
new PriorityQueue<Recognize>(
3,
new Comparator<Recognize>() {
@Override
public int compare(Recognize lhs, Recognize rhs) {
// Intentionally reversed to put high confidence at the head of the queue.
return Float.compare(rhs.getGestureConfidence(), lhs.getGestureConfidence());
}
});
for (int i = 0; i < outputs.length; ++i) {
if (outputs[i] > THRESHOLD) {
pq.add(new Recognize("" + i, labels.size() > i ? labels.get(i) : "unknown", outputs[i]));
}
}
final ArrayList<Recognize> recognitions = new ArrayList<Recognize>();
int recognitionsSize = Math.min(pq.size(), MAX_RESULTS);
for (int i = 0; i < recognitionsSize; ++i) {
recognitions.add(pq.poll());
}
Trace.endSection(); // "recognizeImage"
return recognitions;
}
我希望将位图图像发送到网络,分类器应该开始进行比较的过程。