This project is all about creating your own dataset from scratch and making a robust classifier. There are in total four classes namely Coke Can, ThumbsUp Can, Mirinda Bottle, Tide Packet! The predictions of the network are stored in the Results
folder.
The model achieves ~97%-98% accuracy on the data stored in the Results
folder with almost 100% accuracy on the training set.
- Clicking pictures from iPhone 6S plus and,
- Recording videos from Laptop.
One of the key aspect while collecting the training data was to make sure all the products have similar backgrounds so that the network learns the meaningful and discriminative features of the products in the images and not the Background
.
Second most important part was to make sure that the distribution of the validation data is almost the same as the testing data. This helped me to boost the performance of my network a lot since I made the architectural and hyperparameter changes based on the validation data that had the distribution similar to what I would expect in a real-life scenario (testing environment).
From the Results
section it should be clear to you that the background in the images is quite diverse and the model is able to classify almost all of the products correctly.
Link to the Video: Product Classification using Self Designed DataSet Playlist
- Install virtual environment
pip3 install virtualenv
- Initiate virtual environment
virtualenv venv
- Activate virtualenv
source venv/bin/activate
- Install the requirements
pip3 install -r requirements.txt
- To create your own dataset from videos, run the below command by specifying the video (from path) and frames (to path). You shall expect for a 1 min. video 60 frames.
python3 video_to_images.py
- Both training and testing (on images) is in the
Classification.ipynb
notebook, which can be opened in a jupyter notebook. Otherwise, run the below command in your virtual environment. Make sure to specify correct training and validation data paths.
python3 Classification.py
- To test the model in real-time using your laptop's web camera the
webcamera.py
script can be useful. Multi-threading is used to avoid the delay in reading each frame and model's prediction on each frame. Both.ipynb
and.py
files are present in the repository.
python3 Web_Camera.py