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
File size: 594 Bytes
56c045d | 1 2 3 4 5 6 7 8 9 10 11 12 | 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 |