Instructions to use AIM-Focus-DEV/Image_classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use AIM-Focus-DEV/Image_classifier 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://AIM-Focus-DEV/Image_classifier") - Notebooks
- Google Colab
- Kaggle
Download app.py from AIM-Focus-DEV/Image_classifier: direct link, hf CLI and curl.
- Browser
- Download file 505 Bytes
-
https://huggingface.co/AIM-Focus-DEV/Image_classifier/resolve/main/app.py
- Command line
-
hf download hf://AIM-Focus-DEV/Image_classifier/app.py
-
curl -L -o app.py https://huggingface.co/AIM-Focus-DEV/Image_classifier/resolve/main/app.py
505 Bytes
| from flask import Flask, jsonify, request | |
| from torch_utils import transform_image | |
| from torch_utils import get_prediction | |
| app = Flask(__name__) | |
| def classify(): | |
| if request.method == 'POST': | |
| file = request.files['file'] | |
| img_bytes = file.read() | |
| img = transform_image(img_bytes) | |
| pred = get_prediction(img) | |
| return jsonify({'classification': int(pred[0])}) | |
| if __name__ == '__main__': | |
| app.run(port=5000, debug=True) |