Views
No views yet
cats_vs_dogs dataset via TensorFlow Datasets.| Item | Description |
|---|---|
| Base architecture | EfficientNetB0 (pretrained, top layers removed) |
| Input shape | 224 × 224 × 3 (RGB image) |
| Output | Single sigmoid output — probability that the image is a “dog” |
| Training data | cats_vs_dogs (split ~80% train / 20% validation) |
| Preprocessing | Resize → 224×224, Normalize pixels to [0,1], optional data-augmentation |
| Loss / Optimizer | binary_crossentropy, Adam |
| Training strategy | Feature-extraction (base frozen) → Optional fine-tuning (unfreeze part of base) |
| Evaluation metric | Accuracy (binary classification) |
| Metric | Value |
|---|---|
| Validation accuracy (after feature-extraction) | ~0.5098… |
| Validation accuracy (after fine-tuning) | ~0.7052… |
⚠️ These metrics depend on training/validation split, augmentation, fine-tuning. Consider re-training or cross-validation for better estimates.
1import tensorflow as tf
2import numpy as np
3from tensorflow.keras.preprocessing import image
4
5# Load model (assuming you saved as model.keras or .h5)
6model = tf.keras.models.load_model("path/to/your_model.keras")
7
8# Load and preprocess a new image
9img = image.load_img("path/to/image.jpg", target_size=(224, 224))
10img = image.img_to_array(img) / 255.0
11img = np.expand_dims(img, axis=0)
12
13# Predict
14prob = model.predict(img)[0][0]
15if prob >= 0.5:
16 print("Dog 🐶 — confidence:", prob)
17else:
18 print("Cat 🐱 — confidence:", 1 - prob)