cats-vs-dogs
21
license:mit
by
sirunchained
Image Model
OTHER
0B params
New
21 downloads
Early-stage
Edge AI:
Mobile
Laptop
Server
Unknown
Mobile
Laptop
Server
Quick Summary
AI model with specialized capabilities.
Code Examples
How to Usepythontensorflow
import tensorflow as tf
from PIL import Image
from huggingface_hub import hf_hub_download
import numpy as np
# Download the model from Hugging Face Hub
model_path = hf_hub_download(
repo_id="sirunchained/cats-vs-dogs",
filename="cats-vs-dogs.keras"
)
# Load the model
model = tf.keras.models.load_model(model_path)
classes = ["Cat", "Dog"]
IMG_SIZE = 150
def predict_image(image_path):
img = Image.open(image_path).resize((IMG_SIZE, IMG_SIZE))
img_array = np.array(img)
img_array = tf.expand_dims(img_array, axis=0)
img_array = tf.cast(img_array, tf.float32)
predictions = model.predict(img_array)
predicted_confidence = predictions[0][0] # Since it's a binary classifier with sigmoid output
if predicted_confidence >= 0.5:
predicted_class = "Dog"
confidence = predicted_confidence
else:
predicted_class = "Cat"
confidence = 1 - predicted_confidence
return predicted_class, confidence
# Example usage:
# predicted_class, confidence = predict_image("path/to/your/image.jpg")
# print(f"Predicted: {predicted_class} with confidence: {confidence:.2f}")Deploy This Model
Production-ready deployment in minutes
Together.ai
Instant API access to this model
Production-ready inference API. Start free, scale to millions.
Try Free APIReplicate
One-click model deployment
Run models in the cloud with simple API. No DevOps required.
Deploy NowDisclosure: We may earn a commission from these partners. This helps keep LLMYourWay free.