Instructions to use sdhaos/Aminatron with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use sdhaos/Aminatron with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://sdhaos/Aminatron") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,89 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- ru
|
| 5 |
+
- en
|
| 6 |
---
|
| 7 |
+
|
| 8 |
+
# Aminatron
|
| 9 |
+
|
| 10 |
+
Aminatron is a TensorFlow/Keras image classification model based on MobileNetV2.
|
| 11 |
+
|
| 12 |
+
The model classifies images into three classes:
|
| 13 |
+
|
| 14 |
+
- `cat`
|
| 15 |
+
- `dog`
|
| 16 |
+
- `human`
|
| 17 |
+
|
| 18 |
+
## Model Files
|
| 19 |
+
|
| 20 |
+
This repository contains:
|
| 21 |
+
|
| 22 |
+
- `aminatron.keras` - trained Keras model
|
| 23 |
+
- `class_names.json` - class order used by the model
|
| 24 |
+
|
| 25 |
+
Class order:
|
| 26 |
+
|
| 27 |
+
```json
|
| 28 |
+
["cat", "dog", "human"]
|
| 29 |
+
Architecture
|
| 30 |
+
- Base model: MobileNetV2
|
| 31 |
+
- Task: image classification
|
| 32 |
+
- Input size: 224x224 RGB
|
| 33 |
+
- Output: 3-class softmax prediction
|
| 34 |
+
- Fine-tuning: last MobileNetV2 layers
|
| 35 |
+
- Framework: TensorFlow/Keras
|
| 36 |
+
Usage
|
| 37 |
+
import json
|
| 38 |
+
import numpy as np
|
| 39 |
+
import tensorflow as tf
|
| 40 |
+
from tensorflow.keras.applications.mobilenet_v2 import preprocess_input
|
| 41 |
+
from tensorflow.keras.preprocessing.image import img_to_array, load_img
|
| 42 |
+
|
| 43 |
+
model = tf.keras.models.load_model("aminatron.keras")
|
| 44 |
+
|
| 45 |
+
with open("class_names.json", "r", encoding="utf-8") as file:
|
| 46 |
+
class_names = json.load(file)
|
| 47 |
+
|
| 48 |
+
image = load_img("image.jpg", target_size=(224, 224), color_mode="rgb")
|
| 49 |
+
image_array = img_to_array(image)
|
| 50 |
+
image_array = preprocess_input(image_array)
|
| 51 |
+
image_array = np.expand_dims(image_array, axis=0)
|
| 52 |
+
|
| 53 |
+
logits = model.predict(image_array, verbose=0)[0]
|
| 54 |
+
probabilities = tf.nn.softmax(logits).numpy()
|
| 55 |
+
|
| 56 |
+
best_index = int(np.argmax(probabilities))
|
| 57 |
+
print(class_names[best_index], float(probabilities[best_index]))
|
| 58 |
+
Training
|
| 59 |
+
The model was trained using:
|
| 60 |
+
- TensorFlow Datasets cats_vs_dogs
|
| 61 |
+
- additional custom images for the human class
|
| 62 |
+
- transfer learning with MobileNetV2
|
| 63 |
+
- early stopping
|
| 64 |
+
- model checkpointing
|
| 65 |
+
- learning rate reduction on plateau
|
| 66 |
+
Intended Use
|
| 67 |
+
This model is intended for educational and portfolio purposes.
|
| 68 |
+
It can be used to classify simple images as:
|
| 69 |
+
- cat
|
| 70 |
+
- dog
|
| 71 |
+
- human
|
| 72 |
+
Limitations
|
| 73 |
+
The model may be inaccurate on:
|
| 74 |
+
- drawings
|
| 75 |
+
- low-quality images
|
| 76 |
+
- images with multiple subjects
|
| 77 |
+
- unusual angles
|
| 78 |
+
- objects outside the trained classes
|
| 79 |
+
Repository
|
| 80 |
+
Project code is available on GitHub:
|
| 81 |
+
https://github.com/SDH4114/ai_models
|
| 82 |
+
|
| 83 |
+
В metadata сверху можешь ещё руками поставить:
|
| 84 |
+
|
| 85 |
+
```text
|
| 86 |
+
language: en, ru
|
| 87 |
+
base_model: google/mobilenet_v2_1.0_224
|
| 88 |
+
pipeline_tag: image-classification
|
| 89 |
+
library_name: tensorflow
|