Model Card for cats_dogs_recognition_tf_nn
Model Details
Model Description
- Developed by: Louie F. Cervantes
- Model type: TensorFlow-based Neural Network for image classification
- Model Architecture:
- Flatten layer (input shape: 128x128x3)
- Dense layer (512 units, ReLU activation)
- Dense layer (512 units, ReLU activation)
- Dense layer (2 units, Softmax activation)
- License: mit
- Finetuned from model: N/A (trained from scratch)
Model Sources
Uses
Direct Use
This model is intended to be used for classifying images of cats and dogs. Given an input image, the model outputs the probability that the image belongs to each class (cat or dog).
Downstream Use
The model can be potentially finetuned for other image classification tasks, especially those involving similar image characteristics or domains.
Out-of-Scope Use
The model may not perform well on images significantly different from the training data (e.g., different animal species, objects other than cats/dogs, images with unusual lighting or angles). It's not intended for safety-critical applications.
Bias, Risks, and Limitations
Bias
The model's performance may vary depending on the characteristics of the input images, such as the breed, pose, and lighting of the animals. It might be biased towards features that are more prevalent in the training dataset.
Risks
Misclassification of images can occur, especially when the input image is ambiguous or different from the training data distribution.
Limitations
- The model is limited by the size and diversity of the training dataset.
- It only recognizes two classes: cats and dogs.
- Performance might degrade on low-quality or heavily obscured images.
Recommendations
Users should be aware of the potential biases and limitations of the model. It is recommended to evaluate the model's performance thoroughly on a representative test set before deploying it in any application.
How to Get Started with the Model
Use the code below to get started with the model.
1from tensorflow import keras
2from PIL import Image
3import numpy as np
4
5# Load the model
6model = keras.models.load_model('cats_dogs_recognition_tf_nn')
7
8# Preprocess the image
9def preprocess_image(image_path):
10 img = Image.open(image_path)
11 img = img.resize((128, 128))
12 img_array = np.array(img) / 255.0
13 img_array = np.expand_dims(img_array, axis=0) # Add batch dimension
14 return img_array
15
16# Make a prediction
17image_path = 'path/to/your/image.jpg' # Replace with the path to your image
18processed_image = preprocess_image(image_path)
19predictions = model.predict(processed_image)
20predicted_class = np.argmax(predictions[0])
21
22# Interpret the results
23class_labels = ['cat', 'dog']
24print(f"Predicted class: {class_labels[predicted_class]}")
25print(f"Probabilities: {predictions[0]}")```