| from tensorflow.keras.models import load_model
|
| from tensorflow.keras.preprocessing import image_dataset_from_directory
|
| import tensorflow as tf
|
|
|
|
|
| model = load_model('model/cat_dog_neither_classifier_new.h5')
|
|
|
|
|
| test_dataset = image_dataset_from_directory(
|
| 'dataset/test_set',
|
| labels='inferred',
|
| label_mode='categorical',
|
| image_size=(224, 224),
|
| batch_size=32
|
| )
|
|
|
|
|
| test_dataset = test_dataset.map(lambda x, y: (x / 255.0, y)).prefetch(tf.data.AUTOTUNE)
|
|
|
|
|
| loss, accuracy = model.evaluate(test_dataset)
|
| print(f"Test Accuracy: {accuracy:.4f}")
|
|
|