Skip to content

Fruit Recognition App. πŸπŸŒπŸ‰ Show a fruit to your webcam and the app will label it.

Notifications You must be signed in to change notification settings

majdjamal/fruit_classifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

56 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Real-Time Image Classification

This is a project in the Deep Learning course DD2424 at the Royal Institute of Technology.

Abstract

Deep networks are growing deeper and require more energy resources. Previous research has shown that the deep learning field will stop progressing if contributors do not produce lighter and efficient network architectures. This study utilizes MobileNet, the state-of-the-art network for mobile devices, to classify images of fruits and vegetables, and compares its performances to networks with more extensive architectures. Networks were trained from randomly initialized weights and Transfer Learning using ImageNet weights. MobileNet trained with Transfer Learning produced a top-1 accuracy of 96.8% and performed like the more extensive network architectures. This study uses the top-1 MobileNet predictor to conclude a real-time image classification app.

Read paper here.

Graphical User Interface

(Figure 1. Graphical User Interface. The first window shows captured photos live from the user’s webcam. The second window includes prediction bars. The demonstration shows 99% Green Apple. At the bottom, there is a purple button to close the app.)

Test The Program

  • Navigate to the repository

  • Setup a virtual environment

python3 -m venv fruits
source fruits/bin/activate
  • Install Required Utility Packages
pip3 install -r requirements.txt

Test the Real-Time Image Classification App

  • Run,
python3 main.py --realtime

Make a prediction

  • Run,
python3 main.py --predict --img_path 'MyPath/ToThe/Image'

NOTE: Replace MyPath/ToThe/Image with the path to your image to classify. Default: data/test_data/apple.jpg

Train and evaluate a network

This part requires an NVIDIA GPU.

Generate the dataset

Send a request to Majdj@kth.se to obtain the dataset folder, because the dataset is larger than 100MB.

  • Replace data/FRUITS folder with the one obtained from majdj@kth.se.

  • Run,

python3 main.py --generate_data

Training with randomly initialized weight

  • Run,
python3 main.py --train --model "mobilenet"

Training with Transfer Learning

  • Run,
python3 main.py --train --model "mobilenet" --transfer_learning

NOTE: Training supplements: scheduler, pass --scheduler; fine tune a pre-trained model, pass --fine_tune


Evaluate the network

  • Run,
python3 main.py --evaluate --model "mobilenet" --path 'MyPath/To/Weights'

NOTE: If the model was trained with Transfer Learning, pass the --transfer_learning tag.

About

Fruit Recognition App. πŸπŸŒπŸ‰ Show a fruit to your webcam and the app will label it.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages