microsoft/cats_vs_dogs
Viewer • Updated • 23.4k • 4.9k • 63
How to use sdhaos/Aminatron with Keras:
# Available backend options are: "jax", "torch", "tensorflow".
import os
os.environ["KERAS_BACKEND"] = "jax"
import keras
model = keras.saving.load_model("hf://sdhaos/Aminatron")
Aminatron is a TensorFlow/Keras image classification model based on MobileNetV2.
The model classifies images into three classes:
catdoghumanThis repository contains:
aminatron.keras - trained Keras modelclass_names.json - class order used by the modelClass order:
["cat", "dog", "human"]
Architecture
- Base model: MobileNetV2
- Task: image classification
- Input size: 224x224 RGB
- Output: 3-class softmax prediction
- Fine-tuning: last MobileNetV2 layers
- Framework: TensorFlow/Keras
Usage
import json
import numpy as np
import tensorflow as tf
from tensorflow.keras.applications.mobilenet_v2 import preprocess_input
from tensorflow.keras.preprocessing.image import img_to_array, load_img
model = tf.keras.models.load_model("aminatron.keras")
with open("class_names.json", "r", encoding="utf-8") as file:
class_names = json.load(file)
image = load_img("image.jpg", target_size=(224, 224), color_mode="rgb")
image_array = img_to_array(image)
image_array = preprocess_input(image_array)
image_array = np.expand_dims(image_array, axis=0)
logits = model.predict(image_array, verbose=0)[0]
probabilities = tf.nn.softmax(logits).numpy()
best_index = int(np.argmax(probabilities))
print(class_names[best_index], float(probabilities[best_index]))
Training
The model was trained using:
- TensorFlow Datasets cats_vs_dogs
- additional custom images for the human class
- transfer learning with MobileNetV2
- early stopping
- model checkpointing
- learning rate reduction on plateau
Intended Use
This model is intended for educational and portfolio purposes.
It can be used to classify simple images as:
- cat
- dog
- human
Limitations
The model may be inaccurate on:
- drawings
- low-quality images
- images with multiple subjects
- unusual angles
- objects outside the trained classes
Repository
Project code is available on GitHub:
https://github.com/SDH4114/ai_models
В metadata сверху можешь ещё руками поставить:
```text
language: en, ru
base_model: google/mobilenet_v2_1.0_224
pipeline_tag: image-classification
library_name: tensorflow
Base model
google/mobilenet_v2_1.0_224