0% found this document useful (0 votes)
7 views5 pages

Diksha Iot 8

This document outlines an experiment aimed at automating quality inspection of products using cameras and edge computing. It details the objectives, prerequisites, procedures for data collection, image preprocessing, defect detection model, edge computing, and integration with actuators. The conclusion emphasizes the effectiveness of deep learning techniques, particularly using a pre-trained VGG16 model for defect classification and real-time predictions in industrial automation.

Uploaded by

shreyank joshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views5 pages

Diksha Iot 8

This document outlines an experiment aimed at automating quality inspection of products using cameras and edge computing. It details the objectives, prerequisites, procedures for data collection, image preprocessing, defect detection model, edge computing, and integration with actuators. The conclusion emphasizes the effectiveness of deep learning techniques, particularly using a pre-trained VGG16 model for defect classification and real-time predictions in industrial automation.

Uploaded by

shreyank joshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING


EXPERIMENT - 9
Student Name: Riya Kumari UID: 22BCS10382
Branch: BE-CSE Section/Group: IOT_640‘A’
Semester: 6th Date of Performance: 14/04/25
Subject Name: Foundation of Cloud IOT Edge ML Subject Code: 22CSP-367

1. Aim: Automate quality inspection of products using cameras and edge computing.

2. Objective: To design and implement an automated quality inspection system for products using
cameras and edge computing.

3. Pre requisites:
Software Requirements:
1. Python (version 3.8 or above)
2. TensorFlow/Keras or PyTorch
3. OpenCV for image processing
4. Flask/Django for backend integration
5. MQTT or HTTP protocols for IoT data transfer

4. Procedure:
Step 1: Data Collection (Image Acquisition)
1. Cameras: Use high-quality cameras (e.g., industrial cameras or machine vision cameras) to
capture product images. Depending on the application, cameras can be positioned at various
points along the production line.
2. Lighting: Proper lighting is essential to ensure clear and consistent image capture. Lighting can
be adjusted to reduce shadows and enhance defect visibility.
3. Trigger Mechanism: Use sensors (like proximity sensors or conveyors) to trigger the camera
when a product passes through.

Step 2: Preprocessing the Images


4. Image Preprocessing: Raw images may need preprocessing to enhance features and remove
noise.
5. Resizing to a fixed dimension (e.g., 224x224 pixels).
6. Normalization to scale pixel values.
7. Data Augmentation (if training a model) to simulate different conditions such as rotations or
lighting variations.

Step 3: Defect Detection Model


8. Convolutional Neural Networks: A CNN is a deep learning model ideal for image classification
tasks, like defect detection. You can either train your own CNN or use pre-trained models for
defect classification.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
9. Pre-trained Models for Feature Extraction: Use pre-trained models like ResNet or VGG16 for
feature extraction and fine-tune them on your dataset if you have a labeled dataset of defective
vs. non-defective products.
10. Inference on Edge Devices: The trained model is deployed to an edge computing device like a
Raspberry Pi, NVIDIA Jetson, or an industrial-grade embedded system for inference.

Step 4: Edge Computing


11. Real-Time Processing: Edge computing allows processing images locally to minimize latency
and avoid transferring large amounts of data to the cloud. This is particularly important for real-
time applications where immediate decisions are needed (e.g., stopping the production line or
rejecting defective products).
12. Hardware Selection: Use edge devices like Raspberry Pi, NVIDIA Jetson, or Intel NUC,
depending on the complexity of your model and the required processing power.
13. Model Optimization: For efficient inference on edge devices, models can be optimized by:
o Quantization: Reducing the precision of model weights (e.g., from float32 to int8) to speed
up inference without sacrificing much accuracy.
o Model Pruning: Removing unnecessary neurons to reduce the size of the model

Step 5: Integration with Actuators


14. Rejecting Defective Products: Once the defect is detected, the system can trigger an actuator
(e.g., robotic arm, conveyor belt diverter) to reject or separate defective products from the
production line.
15. Alerting Operators: When a defect is detected, the system can send alerts to factory operators or
managers via SMS, email, or the IoT dashboard.

5. Implementation / Code: import cv2 import


numpy as np import tensorflow as tf from
tensorflow.keras.applications import VGG16 from
tensorflow.keras.models import Sequential from
tensorflow.keras.layers import Dense, Flatten

# Load and preprocess image def


preprocess_image(image_path):
image = cv2.imread(image_path)
image_resized = cv2.resize(image, (224, 224))
image_normalized = image_resized / 255.0 return
np.expand_dims(image_normalized, axis=0)

# Load VGG16 pre-trained model


base_model = VGG16(weights='imagenet', include_top=False, input_shape=(224, 224, 3))

# Define custom model for defect classification


model = Sequential([ base_model,
Flatten(),
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Dense(512, activation='relu'),
Dense(2, activation='softmax') # 2 classes: defect or no defect
])
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])
# Load the trained model model =

tf.keras.models.load_model("defect_detection_model.h5")

# Predict function def


predict_defect(image_path): image =
preprocess_image(image_path) prediction =
model.predict(image) class_index =
np.argmax(prediction) if class_index == 0:
print("Product is defective")
send_alert("Defective product detected!")
trigger_actuator()
else:
print("Product is not defective")

# Example usage
predict_defect("product.jpg")

6. Screenshot:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

7. Conclusion:
In this experiment, we explored essential techniques for image preprocessing, transfer learning, and
model deployment to build an effective deep learning pipeline for product defect classification. By
leveraging OpenCV and NumPy, we efficiently loaded, resized, and normalized images to ensure
optimal input for deep learning models.

Using transfer learning with a pre-trained VGG16 model, we extracted meaningful features and
customized the network to differentiate between defective and non-defective products, improving
classification accuracy. Finally, we successfully deployed the trained TensorFlow model, demonstrating
its capability to make real-time predictions and trigger automated responses, such as alerts or actuator
controls. This workflow highlights the practical implementation of deep learning for industrial
automation, enhancing defect detection efficiency and reliability.

You might also like