Adil Khan 9 months ago
AdiKhanOfficial #FYP Ideas

Detecting Food Freshness through Machine Learning and Image Processing

To analyze whether or not the food served to us is fresh or otherwise is a challenging task. There have been occasions where we have been exposed to unhealthy food that resulted in some medical ailments. So, the general idea of the project is to develop an android application through which a user ca

Project Title

Detecting Food Freshness through Machine Learning and Image Processing

Project Area of Specialization

Artificial Intelligence

Project Summary

To analyze whether or not the food served to us is fresh or otherwise is a challenging task. There have been occasions where we have been exposed to unhealthy food that resulted in some medical ailments. So, the general idea of the project is to develop an android application through which a user can capture a food image and it gives back a prediction that whether the food is fresh or expired. For this purpose, the things our project depends upon are

  1. Dataset (Images of fresh and expired food). 
  2. A deep learning model.
  3. A server on which the model will be deployed.
  4. An android application linked with the server.

First of all, around 600 images of both fresh and expired food were collected to train and test our deep learning model. After collecting the images, we applied Data Augmentation technique on those images to increase our dataset to 8200 images. Then all the images were resized to 400 x 400 size for better resolution. As far as the deep learning model is concerned pre trained models such as Resnet50 and MobileNet were preferred to perform this project. The deep learning model was trained with highest possible accuracy. Secondly, this model was deployed on to a local server using Flask web service. Thirdly, an android application was developed using Flutter framework. Through this application the user can take a picture of the food and a prediction is given back that either the food is fresh or expired. This whole project can benefit different food authorities which raid different food places now and then and even the common people in consuming healthy food.

Project Objectives

We aim at launching an android application in the market specifically for the food authorities in the country which would make their work efficient and time saving and also for common people in consuming healthy food. Following are the project objectives:

  1. Build a deep learning model to distinguish between fresh and expired food.
  2. Keep on improving the model's accuracy.
  3. Create a server to deploy the model on it.
  4. Develop an android application to practically run this project.
  5. Improving existing model’s accuracy.
  6. Launch the application on Google Playstore.

Project Implementation Method

The project was implemented in eight phases which are as follow:

1- Data Collection:

In this phase around 600 images were collected. Three hundred were of fresh food and the remaining of expired food. Images were captured using mobile phone's camera.

2- Data Preprocessing:

As a deep learning model requires a lot of data to train upon so, during the preprocessing phase we applied different Data Augmentation techniques to increase our dataset from 600 images to 8200 images. Moreover all the raw images of higher dimensions were resized to 400 x 400 size.

3- Transfer Learning:

During this phase we chose two pretrained models (Resnet50 and MobileNet) to use for training purpose. The weights of the pretrained models were used and retrained according to the problem we are dealing with using our dataset. Plus the fully connected layer of the models were also changed. Resnet50 gave us better results so it was used in this project.

4- Training of the Model:

In this phase after applying transfer learning and changing the fully connected layers of our Resnet50 model, we trained it with 6000 training images out of which 3000 were of fresh food and remaining 3000 were of expired food and 1000 validation images containing 500 images for each class. Resnet50 gave us good results.

5- Testing of the Model:

In the testing phase we tested our Resnet50 model with 1200 images containing 600 images for each class. These images were new to the model and were not used in the training phase. We got a testing accuracy of about 83.5%. Later on the model was tested using different metrics such as precision, recall and F1 scores which also showed good results. 

6- Creating Server:

After training and testing our model we created local server on our laptop using Flask web service.

7- Deploying the Model:

Once the server was created we deployed our model over it.

8- Developing Android Application:

We developed an android application using flutter framework and linked it with the server using IP address of the laptop. The application simply captures an image and sends the image to the server from where the prediction is displayed back on the application.

Benefits of the Project

There have been a lot of occasions were we have been served with unhealthy and expired food which after consuming leads to a number of health related issues. We often hear now and then that many people die due to food poisoning and if not they become severely ill which also leads to spending a lot of money on recovering and affording medicines. So, this project can help minimize all of this by providing the users an application through which they can access the quality of the food that they are eating before consuming it. This can also help everyone in consuming healthy food and living a healthy life. Moreover, different food authorities can also use this application in analyzing the quality of the food items of a place which they raid without tasting them.

Technical Details of Final Deliverable

The final deliverable of the project will be an android application which would basically run on any mobile phone using the android operating system. Following is the detail of the application:

  1. The user opens the application and is asked to grant access of the camera to the application.
  2. Once the permission is granted then a screen showing the camera preview is displayed having a capture button at the bottom of the screen. 
  3. The user adjusts the camera and captures the food image by pressing the capture button.
  4. After the image is captured another screen is displayed showing the captured image and a predict button to get a prediction on the screen.
  5. Once the predict button is pressed the image is sent to the server as a http request which is then passed to the deployed model and it analyzes the image and returns back the prediction as a http response.
  6. The prediction is displayed on the mobile's screen.
  7. The application and the server are connected over the internet.

Final Deliverable of the Project

Software System

Core Industry

Food

Other Industries

Health

Core Technology

Artificial Intelligence(AI)

Other Technologies

Cloud Infrastructure, Big Data

Sustainable Development Goals

Good Health and Well-Being for People, Responsible Consumption and Production

Required Resources

Item Name Type No. of Units Per Unit Cost (in Rs) Total (in Rs)
SSD hard drive Equipment165006500
Android Phone Equipment12000020000
Online Course Miscellaneous 118001800
Documentation Miscellaneous 28501700
Total in (Rs) 30000
If you need this project, please contact me on contact@adikhanofficial.com
Prosthetic Hand with Expanded Gestures Using Sequential AI Models

Limb loss is very common among army veterans and it renders the capability of the affected...

1675638330.png
Adil Khan
9 months ago
Go and Green Pakistan

In this busy era of life, we do not have time to do lots of things at one time. But we wan...

1675638330.png
Adil Khan
9 months ago
Nagahban

Nagaban is an online COVID-19 awareness platform which will be accessible to everyday user...

1675638330.png
Adil Khan
9 months ago
Solved - Lab Assignment - Assignment for Sessional Marks

1675638330.png
Adil Khan
6 years ago
Identification and Functionality of Corona Virus using Genome Sequenci...

 Coronaviruses are enveloped RNA viruses prevalent in birds and mammals including&nbs...

1675638330.png
Adil Khan
9 months ago