How to make an image into a Tensor without normalization on Android?

I am making an application that compares two images to find the similarity.
My model has been trained without image normalization.
I want convert to image to Tensor without normalization.
What should I do?


    public Tensor recognize(Bitmap image){

//        Tensor input =  TensorImageUtils.bitmapToFloat32Tensor(
//                image,
//                TensorImageUtils.TORCHVISION_NORM_MEAN_RGB,
//                TensorImageUtils.TORCHVISION_NORM_STD_RGB);

        float[] a = new float[]{1.0f, 1.0f, 1.0f};
        float[] b = new float[]{1.0f, 1.0f, 1.0f};
        Tensor input =  TensorImageUtils.bitmapToFloat32Tensor(
                image, a, b);


        Tensor output = module.forward(IValue.from(input)).toTensor();

        return output;
    }

Assuming the normalization subtracts the mean and divides by the stddev, you could set the mean to zeros and the stddev to ones, which would thus not change the tensor values.

1 Like