github – AttributeError: The object's str & # 39; has no attribute 'shape'

I'm trying to run this script on my image for image classification using the CNN template:

import cv2
import tensorflow as a tf

CATEGORIES = ("Banana", "Bare ground", "Okra", "Sugar cane")

def prepare (file):
IMG_SIZE = 50
img_array = cv2.imread (file, cv2.IMREAD_GRAYSCALE)
new_array = cv2.resize (img_array, (IMG_SIZE, IMG_SIZE))
returns new_array.reshape (-1, IMG_SIZE, IMG_SIZE, 1)

model = tf.keras.models.load_model ("CNN.model")

image = r "C: / Users / admin / Office / Endline dataset / Dataset / Test / one.jpg" #your image path

prediction = model.predict ((image))
prediction = list (prediction (0))
print (CATEGORIES (prediction.index (max (prediction)))))

But, getting the following error:

AttributeError: The object 'str' has no attribute 'shape'