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
File size: 505 Bytes
9d8daba | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | from flask import Flask, jsonify, request
from torch_utils import transform_image
from torch_utils import get_prediction
app = Flask(__name__)
@app.route('/classify', methods=['POST'])
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) |