Skip to content

Kevinbui16/Vegetable-Detection-Deep-Learning

Repository files navigation

Vegetable Classification Using Deep Learning🌱

Introduction📖

This project has implemented two deep-learning models in classifying vegetables through pictures, videos, and live feeds from cameras: a self-built CNN, and a pre-trained ResNet50 model. It was noted that the ResNet50 model performed much better in accuracy from the first epoch itself at 98%, while the custom-built model took about nine epochs before getting such performance.🚀

Motivation 🌟

I started with the basic models of CNNs but soon hit a wall in the real-time classification of vegetables—my models weren't good enough then! 🥦🎥 Fueled by this challenge, I tried out several architectures, though none cut it until I came across ResNet50. Known for its depth and efficiency, it seemed like a perfect fit, considering how depth correlates positively with model performance.🚀

I'm diving deep into using ResNet50 for changing vegetable classification in dynamic environments. Let's see this baby grow!🌱💪

Data Source📊

This dataset is taken from Kaggle, the link to which is:

File Descriptions📄

  • dataset.py: Script for loading and preprocessing the dataset.
  • model.py: Contains the architectures of both the ResNet50 and the custom CNN model.
  • train.py: Scripts to train ResNet models, with TensorBoard integration for monitoring.
  • train_build_model.py: Scripts to train CNN models from the file model.py, with TensorBoard integration for monitoring.
  • inference.py, inference_video.py, inference_live_camera.py: These scripts handle inference for images, videos, and real-time camera feeds, respectively.

How to use my code🤔

- Usage -🔧

  • Run dataset model by running python dataset.py
  • Train Resnet50 model by running python train.py .You can change the parameters inside it.For example: python train.py -e 30
  • Train CNN(self-built) model by running train_build_model.py .You can change the parameters inside it.For example: python train_build_model.py -e 50
  • Test your trained model with image by running python inference.py. For example: python inference.py -e path/to/image.jpg
  • Test your trained model with video by running python inference_video.py. For example: python inference_video.py -e path/to/video.mp4
  • Test your trained model with live camera by running python inference_live_camera.py

Testing model🔍

--ResNet50--

-Live Camera Prediction(ResNet50)-

final_Resnet.mp4

The demo could also be found at: https://youtu.be/2jMpMTP0_S8

-Video Prediction(ResNet50)-

result_ResNet.mp4

The demo could also be found at: https://youtu.be/JpxL3SVMqXg


ResNet50 picture prediction demo

-TensorBoard Training Visualizations(ResNet50)📈-


--CNN--

-Live Camera Prediction(CNN)-

final_build_model.mp4

The demo could also be found at: https://youtu.be/zskBZvCnLAc

-Video Prediction(CNN)-

result_build_model.mp4

The demo could also be found at: https://youtu.be/E7zyE_TDg-s


CNN picture prediction demo

-TensorBoard Training Visualizations(CNN)-


TensorBoard Model Comparison ⚖️

Results📝

The ResNet50 model outperforms the custom-built CNN, achieving higher accuracy in fewer epochs. This efficiency highlights the advantages of using pre-trained models for specific image classification tasks.

Requirements🛠️

To run this project, you will need the following libraries:

Libraries
Pytorch
Sklearn
OpenCV
Numpy
argparse
os
shutil
Matplotlib

About

Deep learning-based system using ResNet50 and CNN for real-time vegetable classification from images and videos.

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages