Ghostraptor commited on
Commit
23222af
·
verified ·
1 Parent(s): e850bb1

Created Model Card

Browse files
Files changed (1) hide show
  1. README.md +76 -0
README.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: apache-2.0
4
+ library_name: keras
5
+ tags:
6
+ - image-classification
7
+ - tensorflow
8
+ - efficientnet
9
+ - computer-vision
10
+ - cats-vs-dogs
11
+ metrics:
12
+ - accuracy
13
+ - auc
14
+ - precision
15
+ - recall
16
+ - f1
17
+ pipeline_tag: image-classification
18
+ ---
19
+
20
+ # Pet Classification with EfficientNetB0
21
+
22
+ This repository contains a high-performance deep learning model designed to classify images into two categories: **Cats** and **Dogs**. The model leverages the **EfficientNetB0** architecture, utilizing Transfer Learning and specialized Fine-Tuning to achieve professional-grade metrics.
23
+
24
+ ## Model Performance
25
+
26
+ Evaluated on a balanced test set of **5,000 images**, the model demonstrates exceptional stability and discriminative power:
27
+
28
+ | Metric | Score |
29
+ | :--- | :--- |
30
+ | **Test Accuracy** | **97.48%** |
31
+ | **AUC Score** | **0.9974** |
32
+ | **Precision** | **96.77%** |
33
+ | **Recall** | **0.9824** |
34
+ | **F1-Score** | **0.9750** |
35
+
36
+ ### Confusion Matrix Highlights
37
+ * **Total Correct:** 4,874 / 5,000 images.
38
+ * **Sensitivity:** High recall for 'Dog' class (0.9824), ensuring minimal false negatives.
39
+ * **Confidence:** Average Loss of **0.0651**, indicating high certainty in classifications.
40
+
41
+ ## Architecture & Training Strategy
42
+
43
+ The model uses a multi-stage training pipeline to maximize the features learned from the ImageNet-pre-trained EfficientNetB0 base.
44
+
45
+ ### 1. Model Structure
46
+ * **Base:** EfficientNetB0 (Functional)
47
+ * **Pooling:** GlobalAveragePooling2D
48
+ * **Normalization:** BatchNormalization for training stability.
49
+ * **Dense Layers:** 256 units (ReLU) followed by a 2-unit Softmax output.
50
+ * **Regularization:** Dropout (0.4) to ensure high generalization and prevent overfitting.
51
+
52
+ ### 2. Training Phases
53
+ * **Phase 1 (Transfer Learning):** The base model was frozen, and only the custom classification head was trained (Learning Rate: 1e-3).
54
+ * **Phase 2 (Fine-Tuning):** The top 40 layers of the EfficientNet base were unfrozen and trained with a reduced learning rate (1e-4) to refine high-level feature detection.
55
+
56
+ ## How to Use
57
+
58
+ To use this model locally with the `.keras` file:
59
+
60
+ ```python
61
+ import tensorflow as tf
62
+ from tensorflow.keras.applications.efficientnet import preprocess_input
63
+ import cv2
64
+ import numpy as np
65
+
66
+ # Load model
67
+ model = tf.keras.models.load_model('efficientnetb0_pet_classifier_finetuned.keras')
68
+
69
+ def predict(img_path):
70
+ img = cv2.imread(img_path)
71
+ img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
72
+ img = cv2.resize(img, (224, 224))
73
+ img = preprocess_input(np.expand_dims(img, axis=0))
74
+
75
+ preds = model.predict(img)
76
+ return "Dog" if np.argmax(preds) == 1 else "Cat"