File size: 2,223 Bytes
03959ff
 
f4ec8c6
 
 
 
03959ff
 
 
f4ec8c6
 
03959ff
f4ec8c6
 
 
03959ff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f4ec8c6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
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)