Fabric Defect Detection
Fabric inspection is an essential step in every textile industry. Fabric detection is an important part of maintaining the fabric’s quality. The automatic fabric fault detection system is required to reduce the cost and waste of time. Quality inspection is a major aspect of the modern industrial manufacturing process. Due to a lack of consistency in quality inspection, defective fabric may be introduced to the market. This causes the industry’s name at stake, leading to heavy losses. With this concept moving forward, a new detection method, which has high detection accuracy and detection speed, is needed to replace the manual work currently used this problem can be resolved by using initial image processing techniques, and then a designed AI system can start working on finding the defect in the fabric. Our designed system is responsible for the quality of the fabric by capturing images from the rolling fabric with a camera.
What is Fabric Defect Detection?
Fabric defect detection is the technique of identifying and categorizing defects in textile materials like yarns, textiles, and garments. These defects can include missing threads, holes, stains, and gaps in the fabric or knitting. Detecting these defects is critical to keeping product quality and guaranteeing customer happiness.
Traditional Methods vs. Deep Learning
Traditionally, humans performed manual inspections to discover fabric defects. This method is difficult, not adaptable, and prone to errors. Deep learning systems, on the other hand, are capable of accurately identifying defects in fabric images through autonomous analysis.
Objectives
The major objectives of this project are:
- Fabric inspection is done completely automatic, with no human involvement.
- By using the latest trend Al (Machine Learning), the system self-learns by detecting the new defects on the fabric.
- The faulty fabric is automatically stamped by the robotic arm.
Methodology
Explanation Of Block Diagram
As we can see from the block diagram, here we use the camera to capture the fabric, after capturing the image of the fabric the DIP(Digital Machine Learning) module does image processing through its algorithms & by this, the trained system performs Machine Learning(ML). After this the system decides whether the fabric is defective or non-defective if it’s defective then the robotic arm stamp at that particular area of the fabric, or if it is nondefective then the fabric passed through the roller and the process repeats
Features
- The system is 24/7 capable for operation.
- The system works efficiently.
- The system is fully automatic, no human involvement.
- AI based system with continuous self-learning.
Challenges in Fabric Defect Detection
Despite its benefits, fabric defect detection using deep learning poses some challenges:
Data Quality: Deep learning algorithms require substantial, high-quality labeled data to train efficiently. This can be difficult to get, especially in unusual or complex abnormalities.
Deep learning algorithms are complex and require specialized knowledge to create and deploy.
Interpretability: Deep learning algorithms might need help grasping how they make judgments.
Generalization: Deep learning algorithms may need help generalizing to new, previously unknown faults, particularly if they are underrepresented in training data.
Fabric defect detection using deep learning
To make a fabric defect detection system using deep learning, download a dataset from Kaggle.
# Importing Libraries
import os
import cv2
import numpy as np
import tensorflow as tf
from sklearn.model_selection import train_test_split
This block imports necessary libraries for file operations, image processing, numerical operations, deep learning, and dataset splitting.
# Function to load and preprocess images
def load_images(folder_path):
images = []
for filename in os.listdir(folder_path):
img = cv2.imread(os.path.join(folder_path, filename))
img = cv2.resize(img, (224, 224)) # Resize images if needed
img = img / 255.0 # Normalize pixel values
images.append(img)
return np.array(images)
This block defines a function load_images
that takes a folder path as input and returns a numpy array of preprocessed images. It reads each image using OpenCV (cv2
), resizes it to 224×224 pixels, and normalizes pixel values to the range [0, 1].
# Load images from folders
defect_images = load_images("Defect_images")
non_defect_images = load_images("nondefect")
This block loads images from two folders: “Defect_images” and “nondefect”. It uses the load_images
function defined earlier to preprocess the images.
labels = np.zeros((len(defect_images) + len(non_defect_images), 2))
labels[:len(defect_images), 0] = 1
labels[len(defect_images):, 1] = 1
This block creates labels for the images. It creates a numpy array of zeros with dimensions (len(defect_images) + len(non_defect_images), 2)
. It sets the first column to 1 for defect images and the second column to 1 for non-defect images.
all_images = np.concatenate((defect_images, non_defect_images), axis=0)
This block concatenates the defect and non-defect images into a single numpy array called all_images
.
# Split data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(all_images, labels, test_size=0.2, random_state=42)
This block splits the data into training and testing sets using the train_test_split
function from sklearn.model_selection
. It uses 80% of the data for training and 20% for testing.
# Define and train a simple CNN model
model = tf.keras.Sequential([
tf.keras.layers.Conv2D(32, (3, 3), activation='relu', input_shape=(224, 224, 3)),
tf.keras.layers.MaxPooling2D((2, 2)),
tf.keras.layers.Conv2D(64, (3, 3), activation='relu'),
tf.keras.layers.MaxPooling2D((2, 2)),
tf.keras.layers.Conv2D(128, (3, 3), activation='relu'),
tf.keras.layers.MaxPooling2D((2, 2)),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dense(2, activation='softmax')
])
This block defines a simple CNN model using the Sequential
API in TensorFlow. It consists of three convolutional layers with max-pooling, followed by a flatten layer and two dense layers. The output layer uses the softmax activation function to output probabilities for the two classes.
model.compile(optimizer='adam',
loss='categorical_crossentropy',
metrics=['accuracy'])
This block compiles the model with the Adam optimizer and categorical cross-entropy loss function. It also specifies that accuracy should be used as a metric for evaluation.
model.fit(X_train, y_train, epochs=10, validation_data=(X_test, y_test))
This block trains the model on the training data for 10 epochs, using the validation data for evaluation.
# Evaluate the model
loss, accuracy = model.evaluate(X_test, y_test)
print(f"Test Loss: {loss}, Test Accuracy: {accuracy}")
This block evaluates the trained model on the test data and prints the test loss and accuracy.
#input from camera
new_image = cv2.imread("test2.png")
new_image = cv2.resize(new_image, (224, 224))
new_image = new_image / 255.0
new_image = np.expand_dims(new_image, axis=0)
prediction = model.predict(new_image)
if prediction[0][0] > prediction[0][1]:
print("Apply Stamp")
else:
print("No stamp ")
This block loads a new image (“test2.png”) from disk, preprocesses it, and passes it through the trained model to make a prediction. If the predicted probability of the first class (defect) is higher than the second class (non-defect), it prints “Apply Stamp”; otherwise, it prints “No stamp”.
Fabric defect identification using deep learning can transform the textile business. By automating fault identification, deep learning algorithms can improve product quality, lower costs, and increase customer happiness. However, specific issues such as data quality and interpretability remain to be addressed. Deep learning algorithms will improve their ability to detect fabric problems with more study and development.
Final Year Projects
Data Science Projects
Blockchain Projects
Python Projects
Cyber Security Projects
Web dev Projects
IOT Projects
C++ Projects
-
Top 20 Machine Learning Project Ideas for Final Years with Code
-
10 Deep Learning Projects for Final Year in 2024
-
10 Advance Final Year Project Ideas with Source Code
-
Realtime Object Detection
-
E Commerce sales forecasting using machine learning
-
AI Music Composer project with source code
-
Stock market Price Prediction using machine learning
-
30 Final Year Project Ideas for IT Students
-
c++ Projects for beginners
-
Python Projects For Final Year Students With Source Code
-
20 Exiciting Cyber Security Final Year Projects
-
Top 10 Best JAVA Final Year Projects
-
C++ Projects with Source Code
-
Artificial Intelligence Projects For Final Year
-
How to Host HTML website for free?
-
How to Download image in HTML
-
Hate Speech Detection Using Machine Learning
-
10 Web Development Projects for beginners
-
Fake news detection using machine learning source code
-
Credit Card Fraud detection using machine learning
-
Best Machine Learning Final Year Project
-
15 Exciting Blockchain Project Ideas with Source Code
-
10 advanced JavaScript project ideas for experts in 2024
-
Best 21 Projects Using HTML, CSS, Javascript With Source Code
-
Hand Gesture Recognition in python
-
Data Science Projects with Source Code
-
Ethical Hacking Projects
-
20 Advance IOT Projects For Final Year in 2024
-
Python Projects For Beginners with Source Code
-
Top 7 Cybersecurity Final Year Projects in 2024
-
Phishing website detection using Machine Learning with Source Code
-
Artificial Intelligence Projects for the Final Year
-
17 Easy Blockchain Projects For Beginners
-
Plant Disease Detection using Machine Learning
-
portfolio website using javascript
-
Top 13 IOT Projects With Source Code
-
Fabric Defect Detection
-
Heart Disease Prediction Using Machine Learning
-
Best 13 IOT Project Ideas For Final Year Students
-
10 Exciting Next.jS Project Ideas
-
How to Change Color of Text in JavaScript
-
10 Exciting C++ projects with source code in 2024
-
Wine Quality Prediction Using Machine Learning
-
Diabetes Prediction Using Machine Learning
-
Maize Leaf Disease Detection
-
Why Creators Choose YouTube: Exploring the Four Key Reasons
-
Chronic Kidney Disease Prediction Using Machine Learning
-
10 Final Year Projects For Computer Science With Source Code
-
Titanic Survival Prediction Using Machine Learning
-
10 TypeScript Projects With Source Code