|
|
--- |
|
|
tags: |
|
|
- image-classification |
|
|
- cats-vs-dogs |
|
|
- tensorflow |
|
|
- efficientnet |
|
|
pipeline_tag: image-classification |
|
|
library_name: tensorflow |
|
|
datasets: |
|
|
- cats_vs_dogs |
|
|
license: mit |
|
|
metrics: |
|
|
- accuracy |
|
|
base_model: |
|
|
- Swardhunter/Efficentnetb07 |
|
|
--- |
|
|
|
|
|
# Cats vs Dogs β EfficientNetB0 Classifier |
|
|
|
|
|
This repository contains a convolutional neural network model trained to classify images of cats and dogs. |
|
|
The model uses **EfficientNetB0 (pretrained on ImageNet)** as a base + custom classification head, and was trained on the `cats_vs_dogs` dataset via TensorFlow Datasets. |
|
|
|
|
|
--- |
|
|
|
|
|
## β
Model Details |
|
|
|
|
|
| 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) | |
|
|
|
|
|
--- |
|
|
|
|
|
## π Performance (Your results β update after training) |
|
|
|
|
|
| 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. |
|
|
|
|
|
--- |
|
|
|
|
|
## π‘ Inference / Usage Example |
|
|
|
|
|
```python |
|
|
import tensorflow as tf |
|
|
import numpy as np |
|
|
from tensorflow.keras.preprocessing import image |
|
|
|
|
|
# Load model (assuming you saved as model.keras or .h5) |
|
|
model = tf.keras.models.load_model("path/to/your_model.keras") |
|
|
|
|
|
# Load and preprocess a new image |
|
|
img = image.load_img("path/to/image.jpg", target_size=(224, 224)) |
|
|
img = image.img_to_array(img) / 255.0 |
|
|
img = np.expand_dims(img, axis=0) |
|
|
|
|
|
# Predict |
|
|
prob = model.predict(img)[0][0] |
|
|
if prob >= 0.5: |
|
|
print("Dog πΆ β confidence:", prob) |
|
|
else: |
|
|
print("Cat π± β confidence:", 1 - prob) |