title: Preprocessing image for Tensorflow model instead Pytorch preprocessing
body: <p>I had a pytorch resnet101 encoder model, when input image got this preprocessing:</p>
  <pre><code>import torchvision as tv
  from PIL import Image
  
  data_transforms = tv.transforms.Compose([
      tv.transforms.Resize((224, 224)),
      tv.transforms.ToTensor(),
      tv.transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])])
  img = Image.open(img_path)
  img = img.convert('RGB')
  img = data_transforms(img)
  img = torch.FloatTensor(img)
  img = img.unsqueeze(0)
  print(img)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/c1gzu.jpg" rel="nofollow noreferrer">pytorch image tensor</a></p>
  <p>Shape of input for encoder in this case is [1, 3, 224, 224], and this picture is normalized with the mean and std of ImageNet.
  <strong>Now I'm export this model to tensorflow, so, how to make the same image preprocessing for tf-model?</strong></p>
  <p>I tried to do something like this:</p>
  <pre><code>from PIL import Image
  
  img = Image.open(img_path)
  img = img.convert('RGB')
  img = tf.keras.preprocessing.image.img_to_array(img)
  img = tf.image.resize(tf_img, (224, 224))
  img = tf.keras.applications.resnet.preprocess_input(img)# now shape is [224, 224, 3]
  img = tf.reshape(img, [1, 3, 224, 224])
  print(img)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/EQh79.jpg" rel="nofollow noreferrer">tensorflow image tensor</a></p>
  <p>but I'm sure that I did something wrong, becouse torch and tf tensors looks very different for one image and give completely different output results from one encoder model.</p>
  <p>Can anyone helps, what should I fix in tf preprocessing?</p>