Instructions to use ramanat1968/mnist-ann-model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use ramanat1968/mnist-ann-model with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://ramanat1968/mnist-ann-model") - Notebooks
- Google Colab
- Kaggle
| import tensorflow as tf | |
| import numpy as np | |
| # Load model | |
| model = tf.keras.models.load_model("mnist_ann_model.keras") | |
| def predict_digit(image_array): | |
| # Expect shape (28, 28) | |
| image_array = image_array / 255.0 | |
| image_array = np.expand_dims(image_array, axis=0) | |
| prediction = model.predict(image_array) | |
| return np.argmax(prediction) | |
| # Example usage | |
| if __name__ == "__main__": | |
| sample = np.random.rand(28, 28) | |
| print("Predicted digit:", predict_digit(sample)) | |