org.tensorflow.lite.Tensor Java Examples
The following examples show how to use
org.tensorflow.lite.Tensor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LiteTrainHeadModel.java From PHONK with GNU General Public License v3.0 | 7 votes |
int[][] getParameterShapes() { Interpreter interpreter = modelWrapper.getInterpreter(); int[][] parameterShapes = new int[interpreter.getInputTensorCount() - 2][]; for (int inputIndex = 2; inputIndex < interpreter.getInputTensorCount(); inputIndex++) { Tensor inputTensor = interpreter.getInputTensor(inputIndex); parameterShapes[inputIndex - 2] = new int[inputTensor.numDimensions()]; System.arraycopy( inputTensor.shape(), 0, parameterShapes[inputIndex - 2], 0, inputTensor.numDimensions()); } return parameterShapes; }
Example #2
Source File: TflitePlugin.java From flutter_tflite with MIT License | 6 votes |
RunYOLO(HashMap args, ByteBuffer imgData, int blockSize, int numBoxesPerBlock, List<Double> anchors, float threshold, int numResultsPerClass, Result result) { super(args, result); this.imgData = imgData; this.blockSize = blockSize; this.numBoxesPerBlock = numBoxesPerBlock; this.anchors = anchors; this.threshold = threshold; this.numResultsPerClass = numResultsPerClass; this.startTime = SystemClock.uptimeMillis(); Tensor tensor = tfLite.getInputTensor(0); inputSize = tensor.shape()[1]; this.gridSize = inputSize / blockSize; this.numClasses = labels.size(); this.output = new float[1][gridSize][gridSize][(numClasses + 5) * numBoxesPerBlock]; }
Example #3
Source File: DeepLabLite.java From ml with Apache License 2.0 | 5 votes |
private static void debugInputs(Interpreter interpreter) { if (interpreter == null) { return; } final int numOfInputs = interpreter.getInputTensorCount(); Logger.debug("[TF-LITE-MODEL] input tensors: [%d]",numOfInputs); for (int i = 0; i < numOfInputs; i++) { Tensor t = interpreter.getInputTensor(i); Logger.debug("[TF-LITE-MODEL] input tensor[%d[: shape[%s]", i, ArrayUtils.intArrayToString(t.shape())); } }
Example #4
Source File: DeepLabLite.java From ml with Apache License 2.0 | 5 votes |
private static void debugOutputs(Interpreter interpreter) { if (interpreter == null) { return; } final int numOfOutputs = interpreter.getOutputTensorCount(); Logger.debug("[TF-LITE-MODEL] output tensors: [%d]",numOfOutputs); for (int i = 0; i < numOfOutputs; i++) { Tensor t = interpreter.getOutputTensor(i); Logger.debug("[TF-LITE-MODEL] output tensor[%d[: shape[%s]", i, ArrayUtils.intArrayToString(t.shape())); } }