Downloads · 30 days
0
nipunsgeeth/Cats_vs_Dogs_cnn_v2
Cats_vs_Dogs_cnn_v2 is a image classification model from nipunsgeeth. Use it when you need a label for an image. It is set up for tensorflow. The card lists the license as mit.
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…
Downloads · 30 days
0
Access
Public
Updated Dec 10, 2025
Repo size
47.9 MB
Likes
0
Public
Click a slice to open those files.
.keras47.9 MB · 97%
From the Hugging Face model README
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.
| 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.
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)