Write a Python script that performs image classification using a pre-trained deep learning model from the TensorFlow library. The user should be able to provide an image file as input, and the script should display the top 5 predicted classes along with their probabilities. PLAINFORMAT
import tensorflow as tf
from tensorflow.keras.applications.resnet50 import ResNet50, preprocess_input, decode_predictions
from tensorflow.keras.preprocessing import image
import numpy as np
import sys

def load_image(img_path):
    img = image.load_img(img_path, target_size=(224, 224))
    x = image.img_to_array(img)
    x = np.expand_dims(x, axis=0)
    x = preprocess_input(x)
    return x

def predict_top_5_classes(image_path):
    model = ResNet50(weights='imagenet')
    img = load_image(image_path)
    preds = model.predict(img)
    top_preds = decode_predictions(preds, top=5)[0]
    
    print("Predicted classes:")
    for i, (class_id, class_name, prob) in enumerate(top_preds):
        print(f"{i+1}. {class_name} ({prob:.2f})")

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print("Usage: python script.py <image_path>")
        exit(1)

    image_path = sys.argv[1]
    predict_top_5_classes(image_path)