Downloads · 30 days
14
12% of all-time downloads
kaitongg/best_tomato_model
best_tomato_model is a image classification model from kaitongg. Use it when you need a label for an image. It is set up for keras.
This model is a convolutional neural network trained to classify images of tomatoes into two categories (presumably ripe and unripe, based on the dataset name and binary classification setup).
Downloads · 30 days
14
12% of all-time downloads
All-time downloads
119
Public
Repo size
101 MB
Likes
0
Public
Click a slice to open those files.
.keras101 MB · 100%
From the Hugging Face model README
This model is a convolutional neural network trained to classify images of tomatoes into two categories (presumably ripe and unripe, based on the dataset name and binary classification setup).
The model architecture was determined using Keras Tuner's Hyperband algorithm. Based on the previous tuning results, the best hyperparameters found were:
conv_blocks: 2filters_0: 32dense_units: 64dropout: 0.1lr: 0.001filters_1: 16The model consists of:
augmented split was used for training, and the original split was used for validation.Based on the evaluation on the validation set, the model achieved the following performance:
Classification Report:
import tensorflow as tf
from PIL import Image
import numpy as np
#Load the model
model = tf.keras.models.load_model('best_tomato_model.keras')
#Load and preprocess an image
img_path = 'path/to/your/image.jpg' # Replace with your image path
img = Image.open(img_path).convert('RGB').resize((128, 128))
img_array = np.array(img) / 255.0
img_array = np.expand_dims(img_array, axis=0) # Add batch dimension
#Make a prediction
prediction = model.predict(img_array)
#Interpret the prediction
predicted_class = int(prediction > 0.5)
print(f"Prediction: {prediction[0][0]:.4f}")
print(f"Predicted class: {predicted_class}")