Fabric Classification Using OpenCV2 is a machine learning and computer vision project that automatically identifies fabric types from images based on their texture characteristics.
The system uses image processing techniques and Local Binary Pattern (LBP) feature extraction to analyse fabric textures. These features are then classified using a Support Vector Machine (SVM) model. A simple Streamlit-based web interface allows users to upload fabric images and receive instant predictions.
This project was developed as an Industrial-Oriented Mini Project for the Bachelor of Technology degree in Computer Science and Engineering (AI & ML).
- Fabric image classification using texture analysis
- Local Binary Pattern (LBP) feature extraction
- Support Vector Machine (SVM) classifier
- Streamlit-based user interface
- Real-time fabric prediction
- Confidence score for predictions
- Image preprocessing using OpenCV2
- Python
- OpenCV
- NumPy
- Scikit-learn
- Scikit-image
- Streamlit
- Pillow
- Joblib
Fabric-Classification/
│
├── app.py
├── model.py
├── requirements.txt
├── README.md
│
└── FabricDataset/
├── Cotton/
├── Denim/
├── Nylon/
├── Silk/
├── Velvet/
└── ...
- Upload a fabric image through the Streamlit interface.
- The image is preprocessed using OpenCV.
- Local Binary Pattern (LBP) features are extracted.
- Extracted features are passed to the trained SVM model.
- The model predicts the fabric type.
- The predicted class and confidence score are displayed.
The project includes:
- Image resizing
- Grayscale conversion
- Noise reduction
- Texture feature extraction using LBP
- Feature normalisation
- Local Binary Pattern (LBP)
- Support Vector Machine (SVM)
- Accuracy
- Precision
- Recall
- F1 Score
git clone https://github.com/yourusername/fabric-classification.git
cd fabric-classificationpip install -r requirements.txtstreamlit run app.pyThe training dataset is not included in this repository due to ownership and distribution restrictions. The project was trained using a fabric image dataset containing multiple fabric categories, such as:
- Cotton
- Denim
- Silk
- Nylon
- Velvet
- Wool
- Oxford Cotton
Images should be organised into separate folders, where each folder name represents the fabric class.
Example:
datasets/
├── Cotton/
├── Denim/
├── Nylon/
├── Silk/
├── Velvet/
└── Wool/
If you wish to reproduce the project, you may use publicly available fabric texture datasets such as:
Ten Fabrics Dataset https://www.kaggle.com/datasets
or any equivalent textile/fabric texture dataset suitable for image classification research.
Please ensure that you comply with the original dataset license and usage terms before downloading or distributing the dataset.
Predicted Fabric Type: Denim
Confidence: 100.00%
- Deep learning-based classification using CNNs
- Support for additional fabric categories
- Mobile application deployment
- Real-time camera-based classification
- Improved feature extraction using GLCM and Gabor filters
- Cloud deployment for online access
- Textile Manufacturing
- Quality Control
- Inventory Management
- Fabric Identification
- Textile Research
- E-commerce Product Classification
B. Saaketh Computer Science and Engineering (AI & ML) Mahatma Gandhi Institute of Technology
Aman Adusumilli Computer Science and Engineering (AI & ML) Mahatma Gandhi Institute of Technology