Numpy to tensor
Hi @WenTheProgrammer, 
It seems like you havent filled the issue [template](https://github.com/tensorflow/tensorflow/issues/new/choose), please fill the template for better assistance.

It's possible that the issue is related to the difference in color channel ordering between OpenCV and TensorFlow. In OpenCV, the color channels are ordered as Blue-Green-Red (BGR), while in TensorFlow the color channels are ordered as Red-Green-Blue (RGB). This means that if your model was trained on RGB images, it might not perform well when given input in BGR format. 
You can try reversing the order of the color channels in your numpy array before feeding it to your model with `cv2.cvtColor(image, cv2.COLOR_BGR2RGB)`. Modify your code like below and let us know if the issue still persists.
```
array = cv2.imread('image.jpg')
array = cv2.cvtColor(array, cv2.COLOR_BGR2RGB)
image = tf.convert_to_tensor(array/255, dtype=tf.float32)
image = tf.image.resize(images=image, size=[imsize, imsize])
image = tf.keras.applications.resnet50.preprocess_input(image)
predictions = model.predict(np.expand_dims(image, axis=0))
```
Thank you! Hi @synandi,

Your suggestion worked! However, I needed to slightly modify the code by not dividing the array by 255 when feeding it into the `tf.convert_to_tensor` function:
```
array = cv2.imread('image.jpg')
array = cv2.cvtColor(array, cv2.COLOR_BGR2RGB)
image = tf.convert_to_tensor(array, dtype=tf.float32)
image = tf.image.resize(images=image, size=[imsize, imsize])
image = tf.keras.applications.resnet50.preprocess_input(image)
predictions = model.predict(np.expand_dims(image, axis=0))
```
Another observation that I had was, I obtained nearly yet not fully identical prediction results when reading the same image using `tf.io.read_file` and `cv2.imread` respectively:

![1](https://user-images.githubusercontent.com/67032259/222210689-3d2d48bf-03cd-4247-a653-2f43fe7f5163.png)                ![2](https://user-images.githubusercontent.com/67032259/222210706-a76b9b20-f20e-4929-a0b0-bee762209246.png)

Do you know what might be the reason for that?

Thank you! *****
This might help. Pls tell you reviews @WenTheProgrammer 
****

The difference in prediction results you are seeing could be due to the fact that when you read the image file using tf.io.read_file and tf.image.decode_image, the image is decoded and resized using the default settings, whereas when you directly load the image into memory using cv2.imread and then resize it using tf.image.resize, you are specifying the size explicitly. This can result in differences in the pixel values of the images, which can affect the prediction results.
To ensure that the image data you are using to make predictions is consistent, you should try to use the same image loading and preprocessing steps for both cases. You can achieve this by converting the numpy array to a tensor using tf.convert_to_tensor and then following the same image processing steps as before.

#Code
import cv2

# Load image into memory as a numpy array
array = cv2.imread('image.jpg')

# Convert numpy array to tensor and normalize the pixel values
image = tf.convert_to_tensor(array, dtype=tf.float32) / 255

# Resize the image to the desired size
image = tf.image.resize(images=image, size=[imsize, imsize])

# Apply the same preprocessing steps as before
image = tf.keras.applications.resnet50.preprocess_input(image)

# Make the prediction
predictions = model.predict(np.expand_dims(image, axis=0))
 Hi @NiharJani2002 

The only difference between your suggestion and my code is that you divided the image by 255 after converting the numpy array into a tensor: `image = tf.convert_to_tensor(array, dtype=tf.float32) / 255`. I tested this method, and obtained prediction results that are way off from what I obtained using `tf.convert_to_tensor`. It seems like images should not be divided by 255 after tensor conversion. 


> Another observation that I had was, I obtained nearly yet not fully identical prediction results when reading the same image using `tf.io.read_file` and `cv2.imread` respectively:
> 
> ![1](https://user-images.githubusercontent.com/67032259/222210689-3d2d48bf-03cd-4247-a653-2f43fe7f5163.png) ![2](https://user-images.githubusercontent.com/67032259/222210706-a76b9b20-f20e-4929-a0b0-bee762209246.png)
> 
> Do you know what might be the reason for that?
> 
> Thank you!

@WenTheProgrammer, The two images don't seem to vary in any way. However, one possibility is that the two libraries use different algorithms for decoding the image, which can result in small differences in the pixel values. If the differences are very small and do not significantly affect the performance of your model, then it may not be a cause for concern. Thank you!


 Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/59841">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/59841">No</a>

I apologize for posting a very simple question here as I could not solve the issue myself or find an answer elsewhere.

I was trying to make a prediction using a model and a 3D array with 3 channels as inputs. When this 3D array was saved as an image file, I was able to make a proper prediction using my model:
`image = tf.io.read_file('image.jpg')`
`image = tf.image.decode_image(image, channels=3)`
`image = tf.image.resize(images=image, size=[imsize, imsize])`
`image = tf.keras.applications.resnet50.preprocess_input(image)`
`predictions = model.predict(np.expand_dims(image, axis=0))`

However, when this 3D array was readily available in memory as a numpy array in uint8 format, and I tried to directly use this array to make a prediction, I get a different prediction result. I used `cv2.imread` to simulate the array in memory:
`array = cv2.imread('image.jpg')`
`image = tf.convert_to_tensor(array/255, dtype=tf.float32) `
`image = tf.image.resize(images=image, size=[imsize, imsize])`
`image = tf.keras.applications.resnet50.preprocess_input(image)`
`predictions = model.predict(np.expand_dims(image, axis=0))`

Any help is greatly appreciated! 