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
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support