You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to convert an image to Tensor. For that first I convert the buffered image to float[][][][] array as below. File inputImage = new File(inputName); BufferedImage bufferedImage = ImageIO.read(inputImage); int imgHeight = bufferedImage.getHeight(); int imgWidth = bufferedImage.getWidth(); int numberOfChannels = bufferedImage.getTransparency(); float[][][][] floatImage = new float[1][imgHeight][imgWidth][numberOfChannels]; for(int i = 0; i < imgHeight; i++) { for(int j = 0; j < imgWidth; j++) { for(int k = 0; k < numberOfChannels; k++) { floatImage[0][i][j][k] = (float) (bufferedImage.getData().getSample(i, j, k)/255.0); } } }
Then, I try to convert the float array to Tensor using Tensor inputTensor = Tensor.create(floatImage).
Is there a way to convert an buffered image to Tensor? I am using ´tensorflow-core-api´ version ´0.3´.
Note: Converting the buffered as above takes longer, maybe there is a faster way to do it in Java.