Ex 07
Ex 07
def classify_image_vgg16(image_path):
# Load the VGG16 model pre-trained on ImageNet data
model = VGG16(weights='imagenet', include_top=True)
try:
# Load an image file
img = image.load_img(image_path, target_size=(224, 224))
# Make predictions
predictions = model.predict(x)
except FileNotFoundError:
print("Error: Image file not found.")
except Exception as e:
print("An error occurred:", e)
if __name__ == "__main__":
# Replace 'image_path.jpg' with the path to your image file
image_path = 'car.jpg'
classify_image_vgg16(image_path)