Download as pdf or txt
Download as pdf or txt
You are on page 1of 39

Gear Defect Detection Using CNN SPPU

1. Introduction:
This project aims to address the challenges of manual gear inspection in
automobile transmission systems by developing an advanced system that employs
computer vision algorithms and machine learning techniques to monitor and
inspect the quality of products or processes in real-time. It utilizes cameras or
sensors to capture live images or video feeds, which are then analyzed and
processed to detect defects or deviations from predetermined quality standards.
Manual inspection is a time-consuming and tedious task that adds to the costs,
particularly for small and medium enterprise industries (SMEs). The proposed
solution utilizes image processing techniques, such as histogram analysis and
quadratic distance, to assess color concentration.[7] Additionally, depth inspection
is conducted using vertical and horizontal reference levels. The project primarily
focuses on Convolutional Neural Networks (CNNs) for image recognition and
processing in order to inspect manufactured gears. Gears play a crucial role in
automobile transmissions, directly impacting the vehicle's overall performance
and the functionality of the transmission system. Transmission faults are
responsible for approximately one-third of automobile chassis issues, with gear
problems being the most common. Despite mature design, materials, and
manufacturing techniques, defects such as dimensional deviations, surface
scratches, crushing, dents, and insufficient filling can occur in high-speed
production lines. Defective gears not only compromise car performance but also
pose security risks and result in significant losses for manufacturers. Due to the
complex shape and structure of gears and the various types of defects they can
have, gear quality inspection is a challenging task. Current manual inspection
methods are inefficient, time-consuming, and fail to ensure consistent and stable
quality. The slow inspection speed also hampers the requirements of high-speed
production lines. While machine vision-based gear defect detection technology
exists, it is mainly focused on inspecting broken teeth and flat surfaces of
conventional gears. There is a lack of research on gears with complex shapes and
structures. Traditional single vision systems are inadequate for capturing
sufficient information due to the multiple measurement tasks and diverse defects
involved. The objective of this project is to develop a system that can quickly and
accurately measure multiple dimensions, detect defects, and classify them
accordingly. By leveraging advanced image recognition techniques, the proposed
solution aims to overcome the limitations of existing methods and provide an
efficient and effective gear inspection solution.[4]

Pimpri Chinchwad College of Engineering, B.E. Mechanical


1
Gear Defect Detection Using CNN SPPU

1.1 Problem Statement

To design and fabricate defect detecting machine for Gear which will analyse the
product by image processing for surface defects.

1.2 Objective
The main aim of the project is to convert the manual operation of surface inspection
into automatic process at the minimum possible cost and based on this following
objectives are to be made.

1)To design and manufacture a defect-detecting machine.

2) To reduce inspection time.

3) To increase accuracy of defect detection.

4)To Design GUI for the system

1.3 Scope
This initiative is specifically designed to address the quality assessment requirements
of small-scale industries engaged in mass production of gears. The project centers
around the creation of an automated, real-time vision-based quality inspection
monitoring system. By automating the inspection process, the project aims to overcome
the limitations of manual gear inspection, which is known to be laborious and time-
intensive. The primary objective is to achieve cost reduction, with a particular emphasis
on small and medium enterprise industries (SMEs).

Pimpri Chinchwad College of Engineering, B.E. Mechanical


2
Gear Defect Detection Using CNN SPPU

2. LITERATURE SURVEY

• Sharifzadeh,S et. al had worked on detection of steel defect using the image
processing algorithms in his work. The paper focuses on detecting and classifying
surface defects in steel using image processing techniques. Specifically, the study
examines four common types of steel defects: holes, scratches, coil breaks, and rust.
The researchers applied various image processing algorithms to identify these
defects in steel surfaces. The results of their analysis demonstrate that the selected
algorithms perform well in detecting steel defects. The numerical findings indicate
the effectiveness of the implemented image processing algorithms for each type of
defect: holes, scratches, coil breaks, and rust. In simple terms, the paper discusses
how image processing algorithms can be used to detect and classify different types
of defects on steel surfaces. The researchers found that the algorithms they applied
worked effectively in identifying holes, scratches, coil breaks, and rust. While the
specific defects discussed in the paper are related to steel surfaces, the general
principles of defect detection and classification can be transferred to the context of
gear inspection. Understanding the methodologies and challenges addressed in the
paper can provide valuable knowledge and insights for designing and implementing
our gear defect detection system.

• Ruiling Liu et. al had worked on a bevel gear quality inspection system based on
multi-camera vision technology. They addressed the challenges associated with
manual inspection of surface defects and dimension measurement in automotive
bevel gears. The manual inspection process was found to be costly, inefficient,
slow, and inaccurate. To overcome these issues, the researchers developed a bevel
gear quality inspection system based on multi-camera vision technology. The
developed system is capable of simultaneously detecting surface defects and
measuring gear dimensions. Three efficient algorithms were proposed for this
purpose: Neighbourhood Average Difference (NAD), Circle Approximation
Method (CAM), and Fast Rotation-Position (FRP). These algorithms enable the
detection of various types of defects, including knock damage, cracks, scratches,
dents, and repeated cutting of the spline. The system achieves a high level of
precision in defect detection, with a minimum detectable defect size of 0.4 mm ×
0.4 mm. Additionally, the system demonstrates accurate dimension measurement
with a precision of approximately 40–50 µm. The inspection process itself is fast,
taking no more than 1.3 seconds to complete. Both the speed and precision of the
system meet the requirements of real-time online inspection in bevel gear
production. The findings from this study are highly relevant and beneficial for gear
defect detection using image processing. The proposed algorithms and the multi-
camera vision technology serve as valuable references for developing similar
systems that can detect and classify defects in gears. The research contributes to

Pimpri Chinchwad College of Engineering, B.E. Mechanical


3
Gear Defect Detection Using CNN SPPU

improving the efficiency, accuracy, and cost-effectiveness of gear inspection


processes. By adapting and implementing the efficient algorithms proposed in this
study, gear manufacturers can enhance their defect detection capabilities. The
system's ability to detect various types of defects, coupled with its high precision
and real-time inspection capability, can significantly improve the overall quality
control and production efficiency in the gear manufacturing industry.

• Maha Alghawazi et. al had worked on detection of sql injection attack using
machine learning techniques: a systematic literature review. They highlighted the
significance of SQL (Structured Query Language) as a means to interact with
database management systems. While research on detecting and preventing SQL
injection attacks has been ongoing, it remains a relevant and important area of study.
The authors proposed that the application of techniques from various domains can
enhance the detectability of these attacks. Artificial intelligence and machine
learning techniques have shown promise in controlling SQL injection attacks.
While the primary focus of this study is on SQL injection attacks, it may have
potential benefits and usefulness in the context of gear defect detection using image
processing. The techniques and methodologies discussed in the paper can serve as
a reference for exploring machine learning-based approaches to detect and classify
defects in gears. By leveraging the knowledge and insights gained from the study,
researchers in gear defect detection can potentially adapt and apply similar machine
learning techniques to enhance the accuracy and efficiency of their own systems.
Therefore, while the direct applicability of the paper to gear defect detection may
require adaptation and customization, the findings and methodologies presented can
offer valuable insights and serve as a foundation for the development of effective
defect detection systems in the field of gear manufacturing.

• N. S. Abdul Rahman1 et. al had worked on automated real-time vision quality


inspection monitoring system. This paper presents an automated real-time vision
quality inspection monitoring system. It aims to solve the challenges of manual
inspections by reducing time, cost, and effort, particularly in small and medium
enterprise industries (SMEs). The system focuses on inspecting the quality of soft
drinks, specifically color concentration and water level. By employing computer-
network technology and utilizing pre-processing techniques, the system achieves
100% accuracy in both color concentration and water level inspections. While the
study focuses on soft drinks, the methodologies and algorithms can be adapted for
gear defect detection using image processing, improving efficiency and quality
control in the gear manufacturing industry.

Pimpri Chinchwad College of Engineering, B.E. Mechanical


4
Gear Defect Detection Using CNN SPPU

• Deepika S. et. al had worked on gear assembly fault analysis using dual-tree
complex wavelet transform. The paper highlights the diagnosis of gear faults by
employing this specific wavelet transform. The reference signal used for
comparison is the acoustic signal obtained from a healthy gear mesh. The study
analyzes gears with intentionally introduced defects in one or more teeth. The
proposed method achieves accurate measurement of the angles between damaged
teeth, allowing for effective fault analysis. Simulations are conducted to evaluate
the detection effectiveness of the method. Various parameters, including mean,
standard deviation, autocorrelation, and dynamic range, are measured to assess the
severity of the gear defects. By utilizing acoustic signals, the proposed method
enables gear defect identification and estimation of defect severity. This approach
proves useful in preventing gear teeth fractures and ensuring the overall health of
the gears and motors. Although the paper's focus is on gear fault analysis using the
dual-tree complex wavelet transform and acoustic signals, the principles and
techniques presented can be beneficial in gear defect detection using image
processing. Adapting the concepts and methodologies from this study can
potentially enhance gear defect detection systems by incorporating image
processing techniques. By combining image analysis with acoustic signal
processing, researchers can develop comprehensive and accurate gear defect
detection systems. Such systems can help improve gear reliability, prevent failures,
and optimize maintenance efforts in various industries that rely on gears.

• Chuangang Wang et al. had worked on developing an automatic and quantitative


defect status detecting method for external gears, specifically in the railway context.
The paper introduces a two-stage scheme for segmenting the meshing region in the
gear tooth, followed by the combination of adaptive thresholding and shape analysis
to detect surface defects. The proposed method is evaluated using 140 gear tooth
images, and the results indicate a high area overlap (0.87) in the segmented meshing
region. The defect detection method outperforms other related approaches,
demonstrating its effectiveness and superiority. In the context of gear defect
detection using image processing, this paper's methodology is valuable and
beneficial. By leveraging the proposed segmentation scheme and defect detection
techniques, researchers and practitioners in gear defect analysis can enhance their
image processing algorithms for accurate and automated gear defect detection. The
study provides insights and a framework for developing advanced image
processing-based systems that can identify surface defects in gears, particularly in
railway applications. Implementing the techniques and concepts from this research
can contribute to improving gear quality control, preventing failures, and enhancing
the overall reliability and safety of gear systems in the railway industry.

Pimpri Chinchwad College of Engineering, B.E. Mechanical


5
Gear Defect Detection Using CNN SPPU

3. Methodology

3.1 What is Image Classification


Image classification is a fundamental process in detecting defects in gears using
Convolutional Neural Networks (CNN). The objective is to categorize images based on
their distinctive features, such as color, face position, background color, and shirt color,
among others. However, these features often exhibit significant variations, posing a
challenge when attempting to identify patterns within the data. Images are composed
of pixels, which are the smallest indivisible segments, each characterized by its pixel
intensity. In digital images, the RGB color model is commonly used, consisting of three
color channels: Red, Green, and Blue. The choice of RGB is based on the observation
that any color can be produced by combining these three primary colors. For gear defect
detection, the CNN model leverages these RGB values to analyze multiple pixels in an
image, enabling the identification and classification of gear defects with high
accuracy.[8]

3.2 Convolutional neural network


CNN, short for Convolutional Neural Network, is a type of deep learning algorithm
specifically designed for gear defect detection in our project. It serves as a powerful
machine learning tool capable of analyzing input images and assigning significance,
represented by learnable weights and biases, to different aspects or objects within the
images. The primary function of the CNN is to extract relevant features from the gear
images to facilitate defect detection. A CNN architecture for gear defect detection
typically comprises several essential components. Firstly, the input layer receives
grayscale images as input. The output layer generates binary or multi-class labels,
indicating the presence or absence of gear defects. The intermediate layers, known as
hidden layers, play a crucial role in feature extraction. These hidden layers consist of
convolution layers, pooling layers, and a fully connected neural network.By leveraging
the power of CNN, our gear defect detection project can effectively analyze gear
images, identify key features associated with defects, and accurately classify the
presence or absence of defects based on the learned patterns and weights. This enables
us to automate the defect detection process and improve the overall efficiency and
reliability of gear inspection.[6]

Pimpri Chinchwad College of Engineering, B.E. Mechanical


6
Gear Defect Detection Using CNN SPPU

3.3 Model Training


In the context of gear defect detection project, a training model refers to a dataset
specifically created to train the machine learning algorithm. This dataset comprises
pairs of input data, which are influential factors affecting the output, and corresponding
sample output data. The purpose of the training model is to feed the input data into the
algorithm, allowing it to process and correlate the output with the provided sample
output. During the model training phase in gear defect detection, the training model
plays a crucial role. It enables the machine learning algorithm to identify and learn
optimal values for all the attributes involved in the detection process. This involves
analyzing the input data and adjusting the model based on the correlation between the
processed output and the expected output. By continuously refining the model through
this training process, the algorithm becomes more proficient at accurately identifying
gear defects. It's worth noting that there are various types of machine learning models
available, with supervised and unsupervised learning being the most common. In the
context of gear defect detection, these models can be utilized to enhance the accuracy
and effectiveness of the algorithm in different ways, depending on the specific
requirements and characteristics of the project. [4]

Pimpri Chinchwad College of Engineering, B.E. Mechanical


7
Gear Defect Detection Using CNN SPPU

3.4 System Architecture:


User can give input to the system via camera or image stored in the system, the image
will be processed by the trained model, In this stage Image feature will be extracted,
then CNN Algorithm will match the extracted feature with feature of trained image in
dataset, as per the processing the output will be given as defect detected or not.[8]

Fig.3.4.1 System Architecture

3.5 Data Flow Diagram:

In the context of the gear defect detection project, the Data Flow Diagram (DFD) is
used to depict the flow of data within our system. The DFD0 represents the foundational
DFD, where rectangles represent inputs and outputs, while circles represent our system.
Moving to DFD1, we illustrate the actual input and output of the gear defect detection
system. The input can consist of text or images, while the output corresponds to the
detection of gear defects. Similarly, in DFD2, we demonstrate the operations performed
by both users and administrators. The DFD serves as a visual representation of how
data moves through our gear defect detection system. It allows us to understand the
interactions between inputs, system processes, and outputs at different stages. By
following the flow of data in the DFD, we can effectively design and optimize our
system to accurately detect and classify gear defects.

Pimpri Chinchwad College of Engineering, B.E. Mechanical


8
Gear Defect Detection Using CNN SPPU

Fig.3.5.1 Data Flow 1

Fig.3.5.2 Data Flow 2

Fig.3.5.3 Data Flow 3

Pimpri Chinchwad College of Engineering, B.E. Mechanical


9
Gear Defect Detection Using CNN SPPU

3.6 UML Diagrams:

In the context of the gear defect detection project, the UML can be utilized as a powerful
tool for designing and documenting the system. It enables us to create different types
of UML diagrams to represent various aspects of the project. These diagrams can help
visualize the system architecture, specify the interactions and relationships between
different components, and document the artifacts related to gear defect detection.By
employing the UML in our project, we can enhance the clarity and communication
among project stakeholders, facilitate the understanding of the system design, and
ensure that the development process follows an effective and well-defined approach.
The availability of multiple UML diagrams provides flexibility in choosing the
appropriate diagram types that best suit the specific needs and requirements of the gear
defect detection project.

Fig.3.6.1 Class Diagram

Pimpri Chinchwad College of Engineering, B.E. Mechanical


10
Gear Defect Detection Using CNN SPPU

Fig.3.6.2 Use case Diagram.

Fig.3.6.3 Activity Diagram.

Pimpri Chinchwad College of Engineering, B.E. Mechanical


11
Gear Defect Detection Using CNN SPPU

Fig.3.6.4 Sequence Diagram

Fig.3.6.5 Component Diagram

Pimpri Chinchwad College of Engineering, B.E. Mechanical


12
Gear Defect Detection Using CNN SPPU

3.7 Software Development:

In our project, we utilized Anaconda as the platform for building the front end of the
software using Python. The Graphical User Interface (GUI) was developed and
executed on Spyder IDE. We imported various libraries such as tkinter and PIL to
display the Login and Registration buttons on the main page. The software consists of
two modules: Login and Registration, where users need to provide accurate details.

In the context of gear defect detection using image processing, extracting objects from
their background to create a binary image is crucial. This binary image serves as input
for the feature extraction process and plays a significant role in generating distinctive
features for class differentiation in pattern recognition. The paper we refer to proposes
an image processing algorithm that converts an RGB image into a binary image. The
algorithm successfully produces the desired object in the binary image.

The conversion to a binary image is commonly employed to identify Regions of Interest


(ROIs) within an image, which are areas that require further processing or analysis. The
purpose is to determine whether a pixel is of interest or not, categorizing it as either
"Yes, this pixel is of interest" or "No, this pixel is not of interest."[12]

The proposed image processing algorithm and the generation of binary images are
highly relevant and beneficial in the field of gear defect detection. By applying similar
techniques, researchers and practitioners can extract gear components from complex
backgrounds and isolate them into binary images for further analysis. This process
enables the identification and examination of specific regions within the gear images,
aiding in the detection and classification of defects. Thus, the algorithm presented in
the paper provides a valuable foundation for developing image processing methods
specifically tailored for gear defect detection.

Pimpri Chinchwad College of Engineering, B.E. Mechanical


13
Gear Defect Detection Using CNN SPPU

3.8 External Interface Requirement

3.8.1 User Interface

Application Based Gear Defect Detection Using CNN.

3.8.2 Hardware Interfaces:

To effectively run machine learning algorithms and utilize various high-level libraries,
a laptop should meet certain specifications:

1. RAM: The laptop should have a minimum of 8 GB of RAM to support the


computational requirements of machine learning tasks.

2. Hard Disk: A minimum of 40 GB of storage is necessary to accommodate the CT


scan image dataset and ensure efficient data processing.

3. Processor: It is recommended to have an Intel i5 processor to facilitate fast data


loading and smooth execution of machine learning algorithms, particularly when
working with PyCharm IDE.

4. IDE: Spyder is the preferred integrated development environment (IDE) as it offers


code suggestions and autocompletion features, making coding more convenient and
efficient.

5. Coding Language: Python version 3.5 is highly suitable for machine learning due to
the availability of high-performance libraries and frameworks.

Pimpri Chinchwad College of Engineering, B.E. Mechanical


14
Gear Defect Detection Using CNN SPPU

3.8.3 Software Interfaces

Operating System: Windows 11

IDE: Pycharm, Spyder

Programming Language: Python

3.9 Non-Functional Requirement

3.9.1 Performance Requirements

The software must demonstrate efficient performance across all functions and
modules to ensure smooth user experience. The encryption process should be fast and
efficient. The virtual environment provided by the software should also deliver fast
performance. The modular design of the application allows for easy error detection
and resolution, facilitating the installation and integration of new functionalities when
necessary.

3.9.2 Safety Requirement

The software is designed with a modular approach, enabling easy detection and
resolution of errors. This design philosophy ensures seamless installation and updates
of new functionalities as needed.

3.9.3 Software Quality Attributes

The software possesses several quality attributes, including:

Adaptability: The software is designed to be adaptable for all users.

Availability: The software is freely available to all users and can be easily accessed.

Maintainability: After deployment, the software can be easily maintained by the


software developer in case of any errors or issues.

Reliability: The software exhibits high performance, enhancing its overall reliability.

User Friendliness: The software employs a graphical user interface (GUI) that
provides a user-friendly experience.

Pimpri Chinchwad College of Engineering, B.E. Mechanical


15
Gear Defect Detection Using CNN SPPU

Integrity: The software ensures control over unauthorized access to software or data.

Security: The software utilizes multiple security measures, including user


authentication, to ensure reliable security.

Testability: The software undergoes comprehensive testing to address all aspects of its
functionality.

Pimpri Chinchwad College of Engineering, B.E. Mechanical


16
Gear Defect Detection Using CNN SPPU

3.10 Software Information :

Python :

Python is a popular programming language that was created in the early 1990s. It is
known for its easy-to-read syntax and supports various programming styles. Python is
often used for both small and large projects due to its versatility and extensive standard
library.

Python is dynamically typed, which means you don't have to explicitly declare variable
types, and it has a garbage collection system that automatically manages memory. It
offers features for structured, object-oriented, and functional programming.

The language has gone through several versions, with Python 3.0 being a major update
released in 2008. Python 2, the previous version, was officially discontinued in 2020,
with all support and updates ending. Python 3.6 and later versions are currently
supported.

Python can be used on different operating systems, and it has a large community of
developers who contribute to its development. The Python Software Foundation is a
non-profit organization that oversees the management and resources for Python.

Guido van Rossum, the creator of Python, started working on the language in the late
1980s. He initially developed Python as a successor to another programming language
called ABC. Van Rossum led the project for many years and made important decisions.
However, in 2018, he stepped back from his leadership role and formed a steering
council with other core developers to guide the future direction of Python.

In summary, Python is a user-friendly programming language that has gained


popularity for its readability and wide range of applications. It continues to evolve
under the guidance of a dedicated community and leadership team.

Anaconda:

Anaconda is a software distribution that includes the Python and R programming


languages. It is designed for tasks like data science, machine learning, and large-scale
data processing. Anaconda makes it easy to manage and deploy packages needed for
these tasks.

Developed by Anaconda, Inc., Anaconda provides a comprehensive set of packages for


scientific computing. It is available for Windows, Linux, and macOS operating systems.

Pimpri Chinchwad College of Engineering, B.E. Mechanical


17
Gear Defect Detection Using CNN SPPU

The distribution comes with over 250 pre-installed packages, and you can install
thousands of additional packages from PyPI and the conda package manage

One of the key features of Anaconda is its package management system called conda.
Unlike the pip package manager, conda takes care of managing dependencies between
packages. It ensures that installed packages are compatible and avoids conflicts that
may arise when different packages require different versions of the same library.

Anaconda also includes a graphical user interface called Anaconda Navigator, which
provides an alternative to the command line interface for managing packages and
environments.

With Anaconda, you can create custom environments and easily share them with others.
It supports building and uploading packages to Anaconda Cloud, PyPI, or other
repositories.

By using Anaconda, you can simplify the installation and management of packages for
data science and scientific computing projects, ensuring compatibility and avoiding
conflicts between dependencies.

Pimpri Chinchwad College of Engineering, B.E. Mechanical


18
Gear Defect Detection Using CNN SPPU

3.11 Front End Development:

1. Graphics User Interface (GUI) for the defect detection system has been developed.

Libraries Used:

1.Pillow

2.Keras

3.OpenCV

4.TensorFlow

5.Matplotlib

Tool Used

1) Anaconda Navigator

2)Spyder

3)DB Browser for data base

Pimpri Chinchwad College of Engineering, B.E. Mechanical


19
Gear Defect Detection Using CNN SPPU

4. Actual Work Carried Out

4.1 GUI Development :

Python offers various graphical user interface (GUI) frameworks to create


visual interfaces for applications. One of the commonly used frameworks is
Tkinter, which comes bundled with Python. Tkinter provides a collection of
tools and widgets that enable the creation of desktop applications with GUI
elements.

In Tkinter, the fundamental building block is a widget. Widgets are interactive


components like buttons, labels, and text boxes. They are organized within a
parent widget, such as the main window or other container widgets.

To develop a Tkinter GUI, you start by creating a Tk object, representing the


main window. Then, you can add widgets to the window or other containers
using geometry managers like pack, grid, or place.

The pack manager arranges widgets in a column or row, the grid manager
organizes them in a grid-like structure, and the place manager allows precise
widget placement on the screen.

Tkinter also provides event handling mechanisms to respond to user actions,


like button clicks or key presses. You can bind functions to events or define
callback functions for buttons.

Tkinter offers a broad range of widgets, including standard ones like buttons
and labels, as well as advanced options like scrollbars, canvas, and treeview.
Additionally, Tkinter provides pre-built dialogs for displaying messages,
gathering user input, or selecting files and directories.

Tkinter is a versatile and robust GUI framework suitable for developing


applications with graphical interfaces. It is easy to learn and well-suited for
various use cases, from simple tools to complex multimedia applications.

Here's a simplified example of creating a Tkinter GUI:

import tkinter as tk
from tkinter import ttk, LEFT, END
from PIL import Image, ImageTk
from tkinter.filedialog import askopenfilename
from tkinter import messagebox as ms

##############################################+==============
===============================================

Pimpri Chinchwad College of Engineering, B.E. Mechanical


20
Gear Defect Detection Using CNN SPPU

root = tk.Tk()
root.configure(background="brown")
# root.geometry("1300x700")

w, h = root.winfo_screenwidth(), root.winfo_screenheight()
root.geometry("%dx%d+0+0" % (w, h))
root.title("Gear Defected System")

# 43

# ++++++++++++++++++++++++++++++++++++++++++++
#####For background Image

image2 = Image.open('ui.jpg')
image2 = image2.resize((1800, 900), Image.ANTIALIAS)

background_image = ImageTk.PhotoImage(image2)

background_label = tk.Label(root, image=background_image)

background_label.image = background_image

background_label.place(x=0, y=0) # , relwidth=1, relheight=1)


#
label_l1 = tk.Label(root, text="Gear Defected System",font=("Times New
Roman", 35, 'bold'),
background="black", fg="white", width=50, height=2)
label_l1.place(x=0, y=0)

#T1.tag_configure("center", justify='center')
#T1.tag_add("center", 1.0, "end")

################################$%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%
#def clear_img():
# img11 = tk.Label(root, background='bisque2')
# img11.place(x=0, y=0)

#############################################################
####$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%

Pimpri Chinchwad College of Engineering, B.E. Mechanical


21
Gear Defect Detection Using CNN SPPU

################################$%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%

# def cap_video():

# video1.upload()
# #from subprocess import call
# #call(['python','video_second.py'])

def reg():
from subprocess import call
call(["python","registration.py"])

def log():
from subprocess import call
call(["python","login.py"])

def window():
root.destroy()

button1 = tk.Button(root, text="Login", command=log, width=14,


height=1,font=('times', 20, ' bold '), bg="white", fg="black")
button1.place(x=100, y=250)

button2 = tk.Button(root, text="Register",command=reg,width=14,


height=1,font=('times', 20, ' bold '), bg="white", fg="black")
button2.place(x=100, y=350)

button3 = tk.Button(root, text="Exit",command=window,width=14,


height=1,font=('times', 20, ' bold '), bg="white", fg="black")
button3.place(x=100, y=500)

root.mainloop()In this, we create a `Tk` object, which is the main window of


the application. We then create a `Label` widget and a `Button` widget, and pack
them into the window using the `pack` method.
When the "Quit" button is clicked, the `command` option is set to `self.quit`,
which is a method of the `Tk` object that terminates the mainloop and destroys
the window.
This is a very simple example, but Tkinter provides a wide range of widgets and
options for customizing their appearance and behavior. You can refer to the
Tkinter documentation for more information and examples.

Pimpri Chinchwad College of Engineering, B.E. Mechanical


22
Gear Defect Detection Using CNN SPPU

4.2 Model Training:


4.2.1. Import the necessary libraries:
import tensorflow as tf
from tensorflow import keras

4.2.2. Load the CIFAR-10 dataset:


(x_train, y_train), (x_test, y_test) = keras.datasets.cifar10.load_data()
This loads the CIFAR-10 dataset, which is a collection of 60,000 32x32 color
images in 10 classes, with 50,000 training images and 10,000 test images.

4.2.3. Normalize the pixel values:


x_train = x_train / 255.0
x_test = x_test / 255.0
This normalizes the pixel values of the images to be between 0 and 1, which is a
common pre-processing step in deep learning.

4.2.4. Define the model architecture:


model = keras.Sequential([
keras.layers.Conv2D(32, (3, 3), activation='relu', input_shape=(32, 32, 3)),
keras.layers.MaxPooling2D((2, 2)),
keras.layers.Conv2D(64, (3, 3), activation='relu'),
keras.layers.MaxPooling2D((2, 2)),
keras.layers.Conv2D(64, (3, 3), activation='relu'),
keras.layers.Flatten(),
keras.layers.Dense(64, activation='relu'),
keras.layers.Dense(10, activation='softmax')

Pimpri Chinchwad College of Engineering, B.E. Mechanical


23
Gear Defect Detection Using CNN SPPU

This defines a sequential model with three convolutional layers, each followed by
a max pooling layer, and two fully connected layers. The input shape of the first
layer is (32, 32, 3), which corresponds to the shape of the input images.

4.2.5. Compile the model:


model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
This compiles the model with the adam optimizer, the
sparse_categorical_crossentropy loss function, and the accuracy metric.

4.2.6. Train Model


history = model.fit(x_train, y_train, epochs=10,
validation_data=(x_test, y_test))
This trains the model on the training data for 10 epochs, using the validation data
to evaluate the model's performance after each epoch. The training history is stored
in the history object.

Code:
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation, Flatten
from keras.layers.convolutional import Convolution2D, MaxPooling2D
#from keras.optimizers import SGD,RMSprop,Adam
from keras.utils import np_utils

import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import os
#import theano
from PIL import Image
from numpy import *
# SKLEARN
from sklearn.utils import shuffle
from sklearn.model_selection import train_test_split
#from Alexnet import AlexNet

# input image dimensions


img_rows, img_cols = 64, 64

# number of channels
img_channels = 3

Pimpri Chinchwad College of Engineering, B.E. Mechanical


24
Gear Defect Detection Using CNN SPPU

Pimpri Chinchwad College of Engineering, B.E. Mechanical


25
Gear Defect Detection Using CNN SPPU

Pimpri Chinchwad College of Engineering, B.E. Mechanical


26
Gear Defect Detection Using CNN SPPU

Pimpri Chinchwad College of Engineering, B.E. Mechanical


27
Gear Defect Detection Using CNN SPPU

Pimpri Chinchwad College of Engineering, B.E. Mechanical


28
Gear Defect Detection Using CNN SPPU

4.3. Model testing:


Code:

Pimpri Chinchwad College of Engineering, B.E. Mechanical


29
Gear Defect Detection Using CNN SPPU

Pimpri Chinchwad College of Engineering, B.E. Mechanical


30
Gear Defect Detection Using CNN SPPU

1. Load the model:


import joblib
model = joblib.load('path/to/your/model.pkl')

This loads the saved model from the specified file path.

2. Load the new dataset:


import pandas as pd
new_data = pd.read_csv('path/to/your/new/dataset.csv')
This loads the new dataset from the specified file path as a Pandas DataFrame.

3. Pre-process the data:


X_new = preprocess(new_data)
This applies the same pre-processing steps used during training to the new data. The
`pre-process` function should be defined to match the pre-processing steps used during
training.

4. Make predictions:
y_pred = model.predict(X_new)

This uses the `predict` method of the model to make predictions on the new data.

5. Evaluate the predictions:


y_true = new_data['target_column'].values
accuracy = accuracy_score(y_true, y_pred)
This compares the predicted labels to the true labels of the new data and calculates the
accuracy of the model. The `accuracy score` function can be used to calculate the
accuracy. Overall, testing a machine learning model involves loading the trained model,
loading the new data, pre-processing the data, making predictions on the new data, and
evaluating the performance of the model.

Pimpri Chinchwad College of Engineering, B.E. Mechanical


31
Gear Defect Detection Using CNN SPPU

5. Result and Discussion


The result of a trained CNN model depends on the task it was designed to solve.
For example, if the CNN model was trained for image classification, the output of
the model will be the predicted class label for the input image.
1. Load the image:
from PIL import Image
image = Image.open('path/to/your/image.jpg')
This loads the image from the specified file path using the PIL library.

2. Preprocess the image:


from tensorflow.keras.preprocessing import image
img = image.load_img('path/to/your/image.jpg', target_size=(224, 224))
img = image.img_to_array(img)
img = img / 255.0
img = np.expand_dims(img, axis=0)
This resizes the image to the required input size of the CNN model, converts it to
a NumPy array, normalizes the pixel values to be between 0 and 1, and adds a
batch dimension.

3. Make predictions:
y_pred = model.predict(img)
This uses the `predict` method of the model to make predictions on the input
image.
4. Get the predicted class label:
class_idx = np.argmax(y_pred)
class_label = class_names[class_idx]
This gets the index of the predicted class with the highest probability and looks up
the corresponding class label in a list of class names. The output of the above code
will be the predicted class label for the input image.

Pimpri Chinchwad College of Engineering, B.E. Mechanical


32
Gear Defect Detection Using CNN SPPU

5. Results of GUI Development

Photograph 5.1 Main Page

Photograph 5.2 Login Page

Pimpri Chinchwad College of Engineering, B.E. Mechanical


33
Gear Defect Detection Using CNN SPPU

• Results on image processing:

Photograph 5.3 Software Prediction 1

Photograph 5.4 Software Prediction 2

Pimpri Chinchwad College of Engineering, B.E. Mechanical


34
Gear Defect Detection Using CNN SPPU

Photograph 5.5 Image Prediction 1

Photograph 5.6 Image Prediction 2

Pimpri Chinchwad College of Engineering, B.E. Mechanical


35
Gear Defect Detection Using CNN SPPU

6. Costing:

Sr. No Component Cost (Rs)

1. Gears (5 Gears) 625

2. Camera (Mi, 720p, 30fps) 1199

3. Cable (1.5m, USB 2.0 Type A to USB Type B) 199

4. Wooden Board 200

5. Stand (Brolaviya, 29 Inch arm, 3.5 Inch wide, Material: Iron) 1300

Total 3523

Pimpri Chinchwad College of Engineering, B.E. Mechanical


36
Gear Defect Detection Using CNN SPPU

7. Future Scope:
Dimensional Analysis: Enhance the image processing algorithm to accurately
analyze and measure the dimensions of the gear, such as diameter, width, tooth
thickness, and pitch.

Automatic Defect Detection: Extend the image processing capabilities to not only
detect defects but also analyze their impact on gear dimensions. This could help
identify if defects are causing any dimensional deviations.

Statistical Analysis: Incorporate statistical analysis techniques to analyze the


distribution and variations in gear dimensions across a batch or production run.
This could provide insights into process control and quality improvement.

Advanced Visualization: Enhance the graphical user interface (GUI) to visualize


the gear dimensions, their variations, and any deviations in an intuitive and user-
friendly manner.

Machine Learning and Artificial Intelligence: Explore the use of machine learning
and AI techniques to train models that can predict gear dimensions based on input
parameters or analyse complex gear geometries that are difficult to measure
directly.

Pimpri Chinchwad College of Engineering, B.E. Mechanical


37
Gear Defect Detection Using CNN SPPU

8. Conclusion:
In conclusion, Convolutional Neural Networks (CNNs) have become a popular
approach for image classification due to their ability to learn and extract features
from images. By stacking convolutional layers, pooling layers, and fully
connected layers, CNNs can learn complex patterns and structures from raw image
data.
1. Developing a defect-detecting machine to accurately identify gear defects,
automating the inspection process and ensuring consistent quality in gear
manufacturing.
2. Reducing inspection time through the implementation of automated systems and
image processing techniques, resulting in increased productivity and cost savings.
3. Enhancing the accuracy of defect detection by leveraging advanced algorithms
and machine learning, leading to higher-quality gears and improved customer
satisfaction.
4. Designing a user-friendly GUI to simplify operation, allowing for easy interaction,
parameter input, visualization of gear images, and access to inspection results.
This improves user experience and maximizes the efficiency of the defect-
detecting machine.

Pimpri Chinchwad College of Engineering, B.E. Mechanical


38
Gear Defect Detection Using CNN SPPU

REFERENCES
1. das, A. (n.d.). A comprehensive guide towards working with CNN in Python.

2. Farhadi, J. R. (2017). YOLO9000: Better, Faster, Stronger. IEEE Conference


on Computer Vision Pattern Recognition.

3. G. Gianini, M. L. (2016). A population-based approach t o point sampling


spatial color algorithms,”. Journal of the Optical S ociety of America A Optics
Image Science Vision, vol. 33, 239.

4. Gary Y. Gao, ”. (2019). A semi-supervised convolutional neural network-


based method for steel surface defect recognition,”. Robotics and Computer
Integrated Manufacturing, vol. 61.

5. J. Redmon, S. D. (2015). You Only Loo k Once: SKNCOE. Department of


Computer Engineering 2020-2021 42 Unified, Real-Time Object Detection.

6. J.Redmon and A. Farhadi. (2018). An Incremental Improvement,. YOLOv3.

7. L. Qiu, X. W. (2019). A High-efficiency Fully Convolutional Networks for


Pixel-wise Surface Defect Detection. IEEE.

8. L. Yu, Z. W. (2019). Detecting Gear Surface Defects Using Background


Weakening Method and Convolutional Neural Network,. Journal of Sensors,
vol. 2019., 1-13.

9. M. Lecca, A. R. (2017). GRASS: a gradient-based random sampling scheme


for Milano Retinex. IEEE Transactions on Image Processing, vol. 26, 2767-
2780.

10. technologies, i. G. (n.d.).

11. University, 1. R. (n.d.). an Image Processing Method to Convert RGB Image


into Bin.

12. X. Cao, W. X. (2020). Defect detection meth od for rail surface based on line-
structured light,” Measurement, vo l. 159. 107771.

13. X. Lv, F. D. (2020). Deep Metallic Surface Defect Detection. The New
Benchmark and Detection Network,” Sensors, vol. 20.

Pimpri Chinchwad College of Engineering, B.E. Mechanical


39

You might also like