0% found this document useful (0 votes)
14 views4 pages

Abstract For My Project

This is my project please don't copy it
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views4 pages

Abstract For My Project

This is my project please don't copy it
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 4

AI/ML MODEL FOR AUTOMATIC DETECTION OF WHEEL

FLAT
1. System Overview
This code snippet outlines a practical approach for detecting flat tires using a
deep learning model, specifically MobileNetV2, through TensorFlow. The system
is designed to classify images of tires to determine if they are flat or not. The
process begins with setting up the environment, including installing TensorFlow
and creating directories for storing images.
Images of tires are downloaded and saved in known and Unknown directories.

2. System Architecture

A. Data Acquisition

1. Image Sources:
a. Known Images: Images of flat tires stored in a known/
directory for reference or model training.
b. Unknown Images: Images of wheels that require
classification, stored in an
Unknown/ directory.
2. Image Downloads:
a. Images are sourced from URLs and saved locally for
processing.

B. Core Components

1. Dependencies:
a. TensorFlow: Utilised for loading and running the
MobileNetV2 model.
b. OpenCV: Employed for image processing and visualisation
tasks.
c. NumPy: Used for numerical operations on image data.
2. Model Loading:
a. The MobileNetV2 model is loaded with pre-trained ImageNet
weights, which provides a foundation for feature extraction and
classification.
3. Image Processing Workflow:
a. read_img(path) Function: Responsible for loading, resizing,
and normalising images to the input size required by
MobileNetV2 (224x224 pixels).
b. predict_flat_tire(model, image_path) Function: Executes
model prediction to classify the tire condition based on the
processed image.
4. Result Visualisation:
a. Annotation: The image is annotated with labels indicating "Flat" or
"Not Flat" based on the prediction outcome.
b. Display: Processed images are displayed with annotations using
OpenCV.
3. Detailed Process Flow

A. Image Acquisition and Storage

1. Download Images:
a. Utilise wget to download images and store them in designated
directories (known/ and Unknown/).
2. Image Preparation:
a. Read images from storage using OpenCV.
b. Resize and normalise images to match the MobileNetV2 input
specifications.

B. Model Inference

1. Loading the Model:


a. Initialise the MobileNetV2 model with pre-trained weights from
ImageNet.
2. Predicting Tire Condition:
a. Process each image through the predict_flat_tire function to
obtain classification results.
b. Evaluate the prediction to determine if the tire is flat based on a
predefined threshold.

C. Visualization and Output

1. Annotate Images:
a. Draw labels on images indicating whether the tire is flat or not.
Use colour coding (red for flat, green for not flat) to enhance
visibility.
2. Display Results:
a. Utilise cv2_imshow to display annotated images for review.

4. Code Implementation

import tensorflow

as tf import cv2

import numpy as

np import os

from
google.colab.patc
hes import
cv2_imshow

from tensorflow.keras.applications import

MobileNetV2 # Load the pre-trained

MobileNetV2 model

model =
if img is None:

raise ValueError(f"Unable to load image at path:

{path}") img = cv2.resize(img, target_size)

img = img / 255.0 # Normalise the image

img = np.expand_dims(img, axis=0) # Add batch

dimension return img

def predict_flat_tire(model,

image_path): image =

read_img(image_path) prediction

= model.predict(image)

print(prediction)

# Assuming a binary classification with output probability for the

"flat" class is_flat = prediction[0][0] > 15.54991457e-05

return is_flat

# Directory paths

unknown_dir =

'Unknown'

for file in
os.listdir(unknown_dir)
:

file_path = os.path.join(unknown_dir,

file) print("Processing", file)

img =

cv2.imread(file_path) if

img is None:

# Display result
print(f"Unable toon image
load image at path:

{file_path}")
label continue
= "Flat" if is_flat else "Not
Flat"
is_flat = predict_flat_tire(model, file_path)
color = (0, 0, 255) if is_flat else (0, 255, 0) # Red for flat, Green for
not flat

# Draw label on the image

cv2.putText(img, label, (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1,

color, 2) cv2_imshow(img)

5.Output

You might also like