public static Classifier create(
AssetManager assetManager,
String modelFilename,
String[] labels,
int inputSize,
int imageMean,
float imageStd,
String inputName,
String outputName) {
final TensorFlowImageClassifier c = new TensorFlowImageClassifier();
c.inputName = inputName;
c.outputName = outputName;
// Read the label names into memory.
Collections.addAll(c.labels, labels);
c.inferenceInterface = new TensorFlowInferenceInterface(assetManager, modelFilename);
// The shape of the output is [N, NUM_CLASSES], where N is the batch size.
final Operation operation = c.inferenceInterface.graphOperation(outputName);
final int numClasses = (int) operation.output(0).shape().size(1);
// Ideally, inputSize could have been retrieved from the shape of the input operation. Alas,
// the placeholder node for input in the graphdef typically used does not specify a shape, so it
// must be passed in as a parameter.
c.inputSize = inputSize;
c.imageMean = imageMean;
c.imageStd = imageStd;
// Pre-allocate buffers.
c.outputNames = new String[]{outputName};
c.intValues = new int[inputSize * inputSize];
c.floatValues = new float[inputSize * inputSize * 3];
c.outputs = new float[numClasses];
return c;
}
У меня есть код обнаружения объектов в Android, я хочу преобразовать его во Flutter, чтобы использовать его и для IOS [code]public static Classifier create( AssetManager assetManager, String modelFilename, String[] labels, int inputSize, int imageMean, float imageStd, String inputName, String outputName) { final TensorFlowImageClassifier c = new TensorFlowImageClassifier(); c.inputName = inputName; c.outputName = outputName;
// Read the label names into memory. Collections.addAll(c.labels, labels);
c.inferenceInterface = new TensorFlowInferenceInterface(assetManager, modelFilename);
// The shape of the output is [N, NUM_CLASSES], where N is the batch size. final Operation operation = c.inferenceInterface.graphOperation(outputName); final int numClasses = (int) operation.output(0).shape().size(1);
// Ideally, inputSize could have been retrieved from the shape of the input operation. Alas, // the placeholder node for input in the graphdef typically used does not specify a shape, so it // must be passed in as a parameter. c.inputSize = inputSize; c.imageMean = imageMean; c.imageStd = imageStd;
// Pre-allocate buffers. c.outputNames = new String[]{outputName}; c.intValues = new int[inputSize * inputSize]; c.floatValues = new float[inputSize * inputSize * 3]; c.outputs = new float[numClasses];
return c; } [/code] Вызывается: [code]create( getAssets(), "file:///android_asset/xxx", getResources().getStringArray(R.array.yyy), INPUT_SIZE, 128, 128, "input", "InceptionV3/Predictions/Reshape_1") [/code] org.tensorflow.contrib.android.TensorFlowInferenceInterface Этот класс не найден во флаттере, чем его заменить?