Fruit & Vegetable Image Classification

A Convolutional Neural Network (CNN) model for classifying images of fruits and vegetables into 36 different classes.

Model Details

  • Task: Image Classification
  • Architecture: Convolutional Neural Network (CNN)
  • Framework: TensorFlow / Keras
  • Model Format: Keras
  • Input Size: 180 × 180 pixels
  • Number of Classes: 36
  • Training Epochs: 25

Description

This model was created as part of my machine learning learning journey, following and implementing a practical image-classification tutorial.

The project helped me practice image preprocessing, CNN architecture design, model training, validation, evaluation, saving and loading trained models, and integrating a machine learning model into a web application.

The trained model is provided as Image_classify.keras.

Model Architecture

The CNN consists of:

  • Rescaling layer for image normalization
  • Conv2D layer with 16 filters
  • MaxPooling2D
  • Conv2D layer with 32 filters
  • MaxPooling2D
  • Conv2D layer with 64 filters
  • MaxPooling2D
  • Flatten
  • Dropout
  • Dense layer with 128 neurons
  • Output layer with 36 classes

The model uses ReLU activations in the convolutional layers, Adam optimization, and Sparse Categorical Crossentropy loss.

Performance

Dataset Accuracy
Training ~98.5%
Validation ~95.2%
Test ~95.3%

The final reported test accuracy is approximately 95.26%.

Supported Classes

The model can classify 36 fruit and vegetable categories, including:

apple, banana, beetroot, bell pepper, cabbage, capsicum, carrot, cauliflower, chilli pepper, corn, cucumber, eggplant, garlic, ginger, grapes, jalepeno, kiwi, lemon, lettuce, mango, onion, orange, paprika, pear, peas, pineapple, pomegranate, potato, raddish, soy beans, spinach, sweetcorn, sweetpotato, tomato, turnip, and watermelon.

Usage

import tensorflow as tf

model = tf.keras.models.load_model("Image_classify.keras")

# Prepare an image with the expected 180 × 180 input size
# and add a batch dimension before prediction.

prediction = model.predict(image)

The model returns predictions for the 36 supported classes.

Intended Use

This model is intended for learning, experimentation, and demonstration purposes. It can be used to explore image classification with Convolutional Neural Networks and TensorFlow/Keras.

Limitations

Predictions depend on the quality, resolution, lighting, orientation, and characteristics of the input image.

The model should not be considered a production-grade computer vision system without additional validation, testing, and evaluation on representative real-world data.

Author

Wael Gabsi

Software Engineer | Machine Learning & AI Learner

GitHub: GABSIWAEL

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support