Instructions to use nico9ga/fruits-Classification-Model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use nico9ga/fruits-Classification-Model 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://nico9ga/fruits-Classification-Model") - Notebooks
- Google Colab
- Kaggle
Download prediction.py from nico9ga/fruits-Classification-Model: direct link, hf CLI and curl.
- Browser
- Download file 594 Bytes
-
https://huggingface.co/nico9ga/fruits-Classification-Model/resolve/main/prediction.py
- Command line
-
hf download hf://nico9ga/fruits-Classification-Model/prediction.py
-
curl -L -o prediction.py https://huggingface.co/nico9ga/fruits-Classification-Model/resolve/main/prediction.py
594 Bytes
| from tensorflow.keras.preprocessing import image | |
| import numpy as np | |
| def predict_class(model, image_path): | |
| img = image.load_img(image_path, target_size=(100, 100)) | |
| img_array = image.img_to_array(img) | |
| img_array = np.expand_dims(img_array, axis=0) | |
| predictions = model.predict(img_array) | |
| predicted_index = np.argmax(predictions[0]) | |
| classes = ['Banano', 'Durazno', 'Fresa', 'Guanabana', 'Guayaba', 'Kiwi', 'Limon', 'Lulo', 'Mandarina', 'Mango', 'Manzana', 'Manzana Verde', 'Melon', 'Mora', 'Naranja'] | |
| predicted_class = classes[predicted_index] | |
| return predicted_class |