Three methods to convert an image path to a NumPy array:
Use OpenCV
# OpenCV import cv2 img = cv2.imread(image_path) # reads an image in the BGR format img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # BGR -> RGB
Use Matplotlib
# Use Matplotlib from matplotlib.image import imread img = imread(image_path)
Use PIL
from PIL import Image img = Image.open(image_path) img = np.array(img)
The result below: