for i, (imagenet_id, label, score) in enumerate(decoded_predictions[0]): print(f"{i + 1}. {label}: {score:.2%}") except FileNotFoundError: print("Image not found. Please check the path.") except Exception as e: print(f"An error occurred: {e}") print("Image not recognized.")
# Function to upload and recognize an image (modified)
def upload_and_recognize(): image_path = input("Enter the full path to your image (including the filename and extension): ") if image_path: recognize_image(image_path)
# Call the function to upload and recognize an image