This project is an online tool that uses image analysis to classify food freshness. The system predicts if the food item is fresh or rotten and delivers a concentration percentage reflecting the level of freshness or deterioration using Convolutional Neural Networks (CNN) for picture classification.
/project-root
│── /backend # Flask backend (image processing + ML inference)
│── /frontend # React frontend
│── /testing # Unit and integration test scripts
│── trainmodel.py # CNN training script
│── requirements.txt # Python dependencies
│── package.json # Node dependencies
└── README.md # Project documentation
- Frontend: React.js
- Backend: Flask (Python)
- Machine Learning: TensorFlow / Keras (CNN)
- Image Processing: OpenCV, NumPy
- Testing: Python unit & integration tests
- Calibration Model: Colorimetric regression model
This project uses a publicly available fruit freshness dataset from Mendeley Data:
https://data.mendeley.com/datasets/bdd69gyhv8/1
The dataset is not included in this repository due to size limitations.
To reproduce the model:
1. Download the dataset from the link above.
2. Place it inside a /dataset folder.
3. Run trainmodel.py.
The trained CNN model (.keras) and calibration model (.pkl) files are excluded from this repository due to GitHub size limitations.
To regenerate:
1. Run trainmodel.py to retrain the CNN model.
2. The calibration model will be generated automatically during training.
Prerequisites Python 3.x Node.js and npm TensorFlow Flask
- Navigate to the backend directory: cd backend
- Install the required Python packages: pip install -r requirements.txt
- Navigate to the src directory: cd src
- Install the dependencies: npm install
Backend Run the Flask server: python app.py
Frontend Start the React development server: npm start
Once both the backend and frontend servers are running, you can access the web application at: http://localhost:3000
The /testing directory contains unit, integration and system test scripts to validate different components of the application.
- Classification: Fresh vs Rotten
- Test Accuracy: 99.56%
- Model: Convolutional Neural Network (CNN)
- Calibration: Colorimetric analysis provides a concentration percentage reflecting freshness or deterioration
The uploaded food image is classified as Fresh or Rotten using a trained CNN model.
A concentration percentage based on colorimetric analysis is also provided to indicate spoilage level.