|
|
--- |
|
|
tags: |
|
|
- tensorflow |
|
|
- efficientnetv2 |
|
|
- transfer-learning |
|
|
license: mit |
|
|
--- |
|
|
|
|
|
# Cat Breed Classification Model |
|
|
|
|
|
## Model Description |
|
|
This model leverages **transfer learning** with the **EfficientNetV2-L** architecture as the backbone to classify images of **five different cat breeds**. The model is fine-tuned to identify distinct types of cats based on image features, and the later layers of the EfficientNetV2-L backbone are exposed and used to create embeddings. |
|
|
|
|
|
The model is trained to classify the following five cat breeds: |
|
|
- Domestic Short-Hair |
|
|
- Siamese |
|
|
- Maine Coon |
|
|
- Bengal |
|
|
- Ragdoll |
|
|
|
|
|
EfficientNetV2-L is a state-of-the-art image classification model that provides a good balance of speed and accuracy while achieving high performance on image recognition tasks. |
|
|
|
|
|
## Intended Use |
|
|
This model is designed for the classification of cat breeds in images. It can be used for: |
|
|
- **Cat breed classification** in images of cats. |
|
|
- **Feature extraction** via embeddings, which can be used for further analysis, clustering, or as a feature for other machine learning tasks. |
|
|
|
|
|
## How to Use |
|
|
You can easily load this model and use it to classify cat images with the following code snippet: |
|
|
|
|
|
```python |
|
|
import tensorflow as tf |
|
|
from tensorflow.keras.models import load_model |
|
|
import numpy as np |
|
|
from tensorflow.keras.preprocessing import image |
|
|
|
|
|
# Load the pre-trained model |
|
|
model = tf.keras.models.load_model("path_to_model") |
|
|
|
|
|
# Example image preprocessing |
|
|
img_path = "path_to_image.jpg" |
|
|
img = image.load_img(img_path, target_size=(128, 128)) # Resize to 128x128 |
|
|
img_array = image.img_to_array(img) |
|
|
img_array = np.expand_dims(img_array, axis=0) # Add batch dimension |
|
|
img_array /= 255.0 # Normalize to [0, 1] |
|
|
|
|
|
# Predict the cat breed |
|
|
predictions = model.predict(img_array) |
|
|
|
|
|
# Predict the cat breed |
|
|
predictions = model.predict(img_array) |
|
|
class_labels = ["Bengal", "Domestic Shorthair", "Maine Coon", "Ragdoll", "Siamese"] |
|
|
predicted_breed = class_labels[np.argmax(predictions)] |
|
|
|
|
|
|
|
|
predicted_breed = class_labels[np.argmax(predictions)] |
|
|
|
|
|
print(f"Predicted Cat Breed: {predicted_breed}") |
|
|
|
|
|
``` |
|
|
|
|
|
## Training Data |
|
|
|
|
|
This model was trained on the **[Cats Breed Dataset](https://www.kaggle.com/datasets/yapwh1208/cats-breed-dataset)**, available on Kaggle. |
|
|
The dataset consists of labeled images for each breed, which were resized to 128x128 pixels for training. The images were also normalized to a [0, 1] range to match the input size required by EfficientNetV2-L. Data augmentation techniques such as random rotations, flips, and scaling were applied to increase model robustness and reduce overfitting. |
|
|
|