Skip to content

The method create(float[][][][]) is undefined for the type Tensor (tensorflow-core-api version 0.3) #258

Closed
@micosacak

Description

@micosacak

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions