Instructions to use Mr00Magician/Number-Recogniser-api with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use Mr00Magician/Number-Recogniser-api 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://Mr00Magician/Number-Recogniser-api") - Notebooks
- Google Colab
- Kaggle
Download app.py from Mr00Magician/Number-Recogniser-api: direct link, hf CLI and curl.
- Browser
- Download file 601 Bytes
-
https://huggingface.co/Mr00Magician/Number-Recogniser-api/resolve/main/app.py
- Command line
-
hf download hf://Mr00Magician/Number-Recogniser-api/app.py
-
curl -L -o app.py https://huggingface.co/Mr00Magician/Number-Recogniser-api/resolve/main/app.py
601 Bytes
| from flask import Flask, request | |
| import numpy as np | |
| import tensorflow as tf | |
| import cv2 | |
| app = Flask(__name__) | |
| loaded_CNN = tf.keras.models.load_model('CNN_extended_dataset.h5') | |
| def get_prediction(): | |
| img_array = request.json.get('data') | |
| img_array = np.array(img_array, dtype=np.uint8).reshape(400, 400) | |
| img_array = cv2.resize(img_array, (28, 28)) | |
| img_array = img_array.reshape(1, 28, 28) | |
| pred = loaded_CNN.predict([img_array]) | |
| final_pred = np.argmax(pred) | |
| return str(final_pred) | |
| if __name__ == '__main__': | |
| app.run() |