GroceryNet: Web-based Application for Simultaneous Segmentation and Classification of Grocery Product Images
GroceryNet is a web-based application for grocery product classification and segmentation using a dual-input parallel CNN model. It leverages multicolor spaces and pre-trained ResNeXt50_32x4d encoders to achieve accurate results. This project was developed as part of a thesis titled "Grocery Product Image Analysis using Multicolor Dual-Input Parallel CNN for Simultaneous Semantic Segmentation and Classification".
GroceryNet is designed to classify and segment grocery product images using a deep learning model. The application provides:
- Image Classification: Predicts the class of a grocery product.
- Semantic Segmentation: Highlights the product in the image.
- Top-5 Predictions: Displays the top 5 probable classes with confidence scores.
The model is built using PyTorch and Streamlit for the web interface.
- Dual-Input CNN: Utilizes RGB and XYZ color spaces for improved accuracy.
- Pre-Trained Encoders: Uses ResNeXt50_32x4d encoders for feature extraction.
- Interactive Web Interface: Built with Streamlit for easy user interaction.
- Top-5 Predictions: Visualizes the top 5 predictions with confidence scores.
- Segmentation Overlay: Displays the segmentation mask over the input image.
- Python 3.8 or higher (https://www.python.org/downloads/)
- pip (Python Package Manager)
- Jupyter Notebook (optional, for going through how the model was trained)
- Git (optional, for cloning the repository)
- Streamlit (https://streamlit.io/)
- A code editor (e.g., VSCode or PyCharm)
-
Clone the Repository (Optional): If you have not already downloaded the project files, you can clone the repository, where the “your-username” is your github username:
git clone https://github.com/your-username/GroceryNet.git cd GroceryNet
Alternatively, if the files were manually downloaded, ensure you are in the correct project directory.
-
Set Up a Virtual Environment (Optional but Recommended): To avoid package conflicts, create and activate a virtual environment:
Windows:
python -m venv venv # for Mac/Linux: python3 -m venv venv venv\Scripts\activate # source venv/bin/activate
-
Download the Model and Dataset:
-
Download the pre-trained model (best_run.pth) and dataset from the Google Drive link.
-
Place the best_run.pth file in the root directory of the project.
-
Extract the dataset and place it in the appropriate directory (e.g., Hierarchical Grocery Store Dataset with Masks).
- Run the Application: streamlit run "app.py"
- Upload an Image: Use the file uploader in the web interface to upload a grocery product image (JPG or PNG format).
The application will display:
-
The input image.
-
The segmentation map overlaid on the image.
-
The top-5 predictions with confidence scores.
Dataset: The dataset used for training and testing is the Hierarchical Grocery Store Dataset (Klasson et al., 2019). It contains images of grocery products along with their corresponding masks.
Model: The model is a Parallel U-Net with pre-trained ResNeXt50_32x4d encoders. It was trained on the dataset mentioned above and achieves high accuracy in both classification and segmentation tasks.
-
Model: Download "best_run.pth" https://drive.google.com/file/d/1Ew-54l0w0p4EDOTzy-urv_eaVSQ-wP2s/view?usp=sharing
-
Dataset: Download and extract "Hierarchical Grocery Store Dataset with Masks.zip" https://drive.google.com/file/d/1swV1AqYNt6miggjxV9pImcS4W_Ef8DB9/view?usp=sharing
-
Model Training: Download "GroceryNetImplementation.ipynb" https://drive.google.com/file/d/1w1wdFu67Zuy9zPtBJrKUnmYyXjSt-mjN/view?usp=sharing
Note: The "Model Training" link is provided for those who want to go through how the model was trained.
University of the Philippines Tacloban College: For providing the resources and support for this project.
-
Streamlit: For the easy-to-use web framework.
-
PyTorch: For the deep learning framework.
-
Segmentation Models PyTorch: For the U-Net implementation.