Hope this would help
    cv::Mat img = cv::imread(img_file);
    at::Tensor tensor_image = torch::from_blob(img.data, {1, img.rows, img.cols, 3}, torch::kByte);
    tensor_image = tensor_image.permute({0, 3, 1, 2});
    tensor_image = tensor_image.toType(at::kFloat);

    tensor_image[0][0].sub_(123.675).div_(58.395); // subtract mean
    tensor_image[0][1].sub_(116.28).div_(57.12);  // divide variance
    tensor_image[0][2].sub_(103.53).div_(57.375);