Instructions to use Matteo25000/howest-hf-ai with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use Matteo25000/howest-hf-ai 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://Matteo25000/howest-hf-ai") - Notebooks
- Google Colab
- Kaggle
Animal CNN (Cat / Dog / Panda)
A small convolutional neural network that classifies 64ร64 RGB images as Cat, Dog or Panda. Trained with Keras 3.15.1 / TensorFlow in an Azure ML pipeline (Howest MLOps course).
Files
| File | Content |
|---|---|
config.json, metadata.json, model.weights.h5 |
The Keras model, saved unpacked (model.save(..., zipped=False)) |
preprocessing.json |
Input contract: labels, input shape, colour mode, resize method, scaling |
Input contract
The model must get images preprocessed exactly as during training:
- Convert to RGB
- Resize to 64ร64 with bicubic interpolation (Pillow's default
resize) float32, raw 0โ255 pixel values โ do not divide by 255, the model has no rescaling layer and was trained on unscaled pixels- Output: softmax over
["Cat", "Dog", "Panda"](in that order)
Usage
import numpy as np
from huggingface_hub import snapshot_download
from keras.models import load_model
from PIL import Image
path = snapshot_download("Matteo25000/howest-hf-ai")
model = load_model(path)
image = Image.open("panda.jpg").convert("RGB").resize((64, 64), Image.Resampling.BICUBIC)
x = np.expand_dims(np.asarray(image, dtype="float32"), axis=0)
print(["Cat", "Dog", "Panda"][model.predict(x).argmax()])
- Downloads last month
- 32