UsamaHF/Cat-dog-classification
118
๐ฑ๐ถ Cat vs Dog Classifier (TensorFlow CNN)
A Convolutional Neural Network (CNN) model trained to classify images of cats and dogs using the microsoft/cats_vs_dogs dataset. Built using TensorFlow and trained on a balanced dataset of 23,000+ images.
๐ง Model Details
๐งช Performance
Evaluation done using 20% validation split.
๐ How to Use
from huggingface_hub import from_pretrained_keras
import tensorflow as tf
import numpy as np
from PIL import Image
# Load the model
model = from_pretrained_keras("UsamaHF/Cat-dog-classification")
# Load and preprocess image
img = Image.open("example.jpg").resize((224, 224)).convert("RGB")
img_array = np.expand_dims(np.array(img).astype("float32") / 255.0, axis=0)
# Get inference function
infer = model.signatures["serving_default"]
# Predict
output = infer(tf.constant(img_array))
predictions = output["output_0"].numpy() # Replace "dense_1" if needed
predicted_class = np.argmax(predictions[0])
print("Predicted:", "Dog" if predicted_class == 1 else "Cat")
