0% found this document useful (0 votes)
54 views31 pages

Internship-Report 32429

The internship involved working on two projects - Aksha for video surveillance and AQuality for quality control. Key tasks included implementing anomaly detection models, image preprocessing, data augmentation, and model training and deployment using tools like YOLO, OpenCV and TensorFlow. Data was collected, annotated and augmented for the different use cases.

Uploaded by

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

Internship-Report 32429

The internship involved working on two projects - Aksha for video surveillance and AQuality for quality control. Key tasks included implementing anomaly detection models, image preprocessing, data augmentation, and model training and deployment using tools like YOLO, OpenCV and TensorFlow. Data was collected, annotated and augmented for the different use cases.

Uploaded by

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

SCTR’s Pune Institute of Computer Technology

(PICT) Pune

AN
INTERNSHIP REPORT
ON

Machine Learning Internship

SUBMITTED BY
Name: Kaushik Aduri
Class: TE 6
Roll no: 32429

Under the guidance of


Dr. Mandar Kakade

DEPARTMENT OF ELECTRONICS AND


TELECOMMUNICATION ENGINEERING
ACADEMIC YEAR 2023-24
DEPARTMENT OF ELECTRONICS AND
TELECOMMUNICATION ENGINEERING
SCTR’s Pune Institute of Computer Technology (PICT), Pune
Maharashtra 411043

CERTIFICATE

This is to certify that the internship report titled


“Machine Learning Internship”
Submitted by
Kaushik Aduri
ExamNo. T190053147

has satisfactorily completed the curriculum-based internship under the guidance of Mandar
Kakade Sir and J Sir towards the partial fulfillment of third year Electronics and
Telecommunication Engineering Semester VI, Academic Year 2023-24 of Savitribai Phule Pune
University.

Dr. Mandar Kakade Mrs. Ankita Patel Dr. M.V.Munot


Internship Mentor Internship Coordinator HOD (E&TE)

Place:
Date:
Acknowledgement

I would like to take this opportunity to express my gratitude to Mr. Aniruddha Pant, CEO of
Algo Analytics, for providing me with the incredible opportunity to complete this internship. His
trust and support have been instrumental in my professional growth and learning.
My heartfelt thanks go to Mrs. Ashwini Nande for her invaluable guidance and unwavering
support throughout my internship. Her mentorship has been essential in shaping my
understanding and skills in this field.
I am also deeply appreciative of my mentors, Dr. Mandar Kakade and Dr. Rupesh Jaiswal, for
their continuous assessment and constant support. Their feedback and encouragement have
helped me immensely during this internship.
Contents

1 Title
2 Introduction
3 Problem Statement
4 Objectives and Scope
5 Methodological Details
6 Modern Engineering tools used
7 Outcome/ results of internship work
8 Conclusion
List of figures

Sr.No. Name of the figure Page No.


1 The model used for regression and
classification
2 ATM data image-1
3 ATM data image-2
4 Quality parts data image-1
5 Quality parts data image-2
6 Opening room scene
7 Scene from Room 2
8 A Scene from underground room.
9 Second Position in IIT Madras

10 People playing our game in event


11 Certificate of Completion
12
13
14
15
16
17
18
19
Machine Learning Internship at Algo Analytics

6
Machine Learning Internship at Algo Analytics

List of tables

Sr.No. Name of the table Page No.


1 Software Requirements-5.1

7
Machine Learning Internship at Algo Analytics

1. Title

Machine Learning Internship at Algo Analytics

2. Introduction

The primary programming language used throughout the project is


Python. The main concepts covered are regression models, image
pre-processing and data augmentation using tools like OpenCV and
LabelImg. It offers functions for tasks such as image pre-processing,
feature extraction, object detection, and image transformations.
YOLO can filter out predictions based on confidence scores, helping
to minimize false positives and improve the accuracy of object
detection. In this internship at Algo Analytics, I have predominantly
worked on anomaly detection using bounding box regression and
classification on different use cases.
As an Intern at Algo Analytics I have worked under 2 projects:
a) Aksha-
 It is an AI powered intelligent video surveillance
solution.

 Transforms basic CCTV setups into smart surveillance


systems

 Utilizes a self-learning computer vision algorithm that is


capable of detecting objects and identifying unusual
events.

 Generates real-time alerts based on identified events

 Its use cases include vehicle detection, preventing


vandalism and theft, detection of suspicious activities.

8
Machine Learning Internship at Algo Analytics

b) AQuality-
 It is a computer vision powered quality control solution.
 Detection of faults in a product with the help of camera
setups.
 Mechanism to separate OK and not OK parts for small
sized, high volume parts inspection for a certain product
at higher accuracy.
 Generating and keeping track of reports for the
quality inspection of all parts.
 Its use cases are Object counting on trolly, i
 nspection of dents/scratches of bearings, various other
products like cars.

3. Problem statement

 Understand ML algorithms regression models using YOLO


model.
 Perform Pre-processing and annotation of images along
with data augmentation.
 Test, train and deploy anomaly detection models using
Python.

4. Objectives and scope

 To implement accurate anomaly detection models.


 To use modern ML tools to understand the concepts of
Data Augmentation and image pre-processing.
 To understand the importance of testing and training
phases for Model Development and Deployment.
 Build various models and projects to implement the ML
architectures learnt.

9
Machine Learning Internship at Algo Analytics

5. Methodological details

5.1 Description of Techniques and Tools used:

Table 5.1 SOFTWARE REQUIREMENTS


Sr no. Software used Applications

1. Jupyter Notebook/Google Collab To code python scripts for


testing,training and
deployment of models along
with augmentation.
2. YOLOv7 For object and anomaly
detection
3. LabelImg tool Used for annotation of images
for classification
4. AnyDesk Remote access to work done by
team members
5. Pandas library For data manipulation and
analysis, particularly useful for
handling structured data.
6. TensorFlow Deep learning frameworks for
building neural networks.
7. Seaborn Provides a high-level interface
for drawing attractive and
informative statistical
graphics.
8. Keras A high-level neural networks
API that provides a user-
friendly interface for building
and training neural networks.
9. Scikit-learn ML library that provides tools
for classification, regression,
clustering, and preprocessing.
10. OpenCV An open-source library that 10
provides tools for image
processing, object detection,
and more.
Machine Learning Internship at Algo Analytics

5.2 Data Collection, Annotation and Data Augmentation:

5.2.1 Collection of data points/images:


 For Aksha project, we implemented the intelligent
computer vision for ATM monitoring and the ATM use
cases images were provided to us already with different
angles and possible variations, also some images and
videos were gathered from Kaggle.

Some sample data images are as below:

Figure
2:
ATM
data
image-
1
Figure 3: ATM data image-2
11
Machine Learning Internship at Algo Analytics

 For AQuality project, the data images of the parts of the


machine were provided to us which were supposed to be
annotated and augmented in order to train the model.
Some sample data images of quality inspection parts as
below:

Figure 4:
Quality part
data image-1
Figure 5:
Quality part
data image-2

5.2.2 Annotation of data :

 Aksha-

Using LabelImg tool, these ATM use case images have


been annotated manually into bounding boxes based on
classification in the requirements.txt as stated below:

1) Person- Bounding boxes around any person that can be


detected in an ATM surveillance without face being
covered is detected as a person.

12
Machine Learning Internship at Algo Analytics

2) Person with face covered- Bounding boxes around a


person within the ATM surveillance whose face appears
covered either with a hat/cap or any other means.
Annotated images are as below:

Figure 6: Crowd annotation Figure 7: Person in an ATM


annotated

 AQuality-

There are 3 defined classes in the requirements.txt file


namely:
1) Nut_present- bounding boxes that consist of only nuts
that are present on the part.
2) Nut_missing-bounding boxes on the holes in the parts
where there are no nuts or bolts present.
3) Entire labelling of the part given in the image.

13
Machine Learning Internship at Algo Analytics

Annotated images of the parts are as follows:

Figure 8: Part annotation-1


Figure 9: Part annotation-2

4) Every annotated image generates a .txt file which


consists of the annotation coordinates made in the
image according to the classification labels.
1- Nut_present 0- nut_missing 3-entire part

Figure 10: Annotations txt file

5.2.3 Data Augmentation:


 Data augmentation is a method to expand a dataset by
applying transformations like flipping, rotating, or adding
noise to existing data samples, enhancing model
performance and generalization.

 Code:

import cv2
14
Machine Learning Internship at Algo Analytics

import os

# Define the directory containing your original images and where


augmented images will be saved
input_dir = "C:\Users\Kaushik A\Desktop\New_part_images\0103plate-
images"
output_dir = "augmented_images/"

# Create the output directory if it doesn't exist


if not os.path.exists(output_dir):
os.makedirs(output_dir)

# List of rotation angles in degrees


rotation_angles = [45, 90, 135, 180, 225, 270, 315]

# List of blurring kernel sizes


blur_kernels = [(5, 5)]

# Function to apply rotation and blurring to an image


def augment_image(image, rotation_angle, blur_kernel):
rotated_image = cv2.rotate(image, cv2.ROTATE_90_CLOCKWISE *
(rotation_angle // 45))
blurred_image = cv2.GaussianBlur(rotated_image, blur_kernel, 0)
return blurred_image

# Function to apply augmentations to images


def augment_images(input_dir, output_dir, rotation_angles,
blur_kernels):
for filename in os.listdir(input_dir):
img_path = os.path.join(input_dir, filename)
if not os.path.isfile(img_path):
continue

img = cv2.imread(img_path)

if img is None:
continue

for rotation_angle in rotation_angles:


for blur_kernel in blur_kernels:
augmented_img = augment_image(img, rotation_angle,
blur_kernel)
output_filename =
f"augmented_{rotation_angle}_{blur_kernel[0]}x{blur_kernel[1]}_{filenam
e}"
output_path = os.path.join(output_dir, output_filename)

15
Machine Learning Internship at Algo Analytics

cv2.imwrite(output_path, augmented_img)

# Apply augmentations to images


augment_images(input_dir, output_dir, rotation_angles, blur_kernels)

 Results after augmentation of images:

16
Machine Learning Internship at Algo Analytics

Figure 10: Rotated image Figure 11:Noise added image

5.3 Training, Testing and Deployment of ML models:

5.3.1 Training using available datasets:

The augmented and original images together form a huge


amount of data in order to increase the accuracy of
training the model.

Code:
from models.experimental import attempt_load
from utils.datasets import LoadStreams, LoadImages
from utils.general import check_img_size, check_requirements,
check_imshow, non_max_suppression, apply_classifier, \
scale_coords, xyxy2xywh, strip_optimizer, set_logging,
increment_path
from utils.plots import plot_one_box
from utils.torch_utils import select_device, load_classifier,
time_synchronized, TracedModel

source, weights, view_img, save_txt, imgsz, trace = opt.source,


opt.weights, opt.view_img, opt.save_txt, opt.img_size, not
opt.no_trace
save_img = not opt.nosave and not source.endswith('.txt') #
save inference images
webcam = source.isnumeric() or source.endswith('.txt') or
source.lower().startswith(
('rtsp://', 'rtmp://', 'http://', 'https://'))

# Directories
save_dir = Path(increment_path(Path(opt.project) / opt.name,
exist_ok=opt.exist_ok)) # increment run
(save_dir / 'labels' if save_txt else
save_dir).mkdir(parents=True, exist_ok=True) # make dir

# Initialize
set_logging()
device = select_device(opt.device)

17
Machine Learning Internship at Algo Analytics

half = device.type != 'cpu' # half precision only supported


on CUDA

# Load model
model = attempt_load(weights, map_location=device) # load
FP32 model
stride = int(model.stride.max()) # model stride
imgsz = check_img_size(imgsz, s=stride) # check img_size

if trace:
model = TracedModel(model, device, opt.img_size)

if half:
model.half() # to FP16

# Second-stage classifier
classify = False
if classify:
modelc = load_classifier(name='resnet101', n=2) #
initialize
modelc.load_state_dict(torch.load('weights/resnet101.pt',
map_location=device)['model']).to(device).eval()

# Set Dataloader
vid_path, vid_writer = None, None
if webcam:
view_img = check_imshow()
cudnn.benchmark = True # set True to speed up constant
image size inference
dataset = LoadStreams(source, img_size=imgsz,
stride=stride)
else:
dataset = LoadImages(source, img_size=imgsz,
stride=stride)

# Get names and colors


names = model.module.names if hasattr(model, 'module') else
model.names
colors = [[random.randint(0, 255) for _ in range(3)] for _ in
names]

# Run inference
if device.type != 'cpu':
model(torch.zeros(1, 3, imgsz,
imgsz).to(device).type_as(next(model.parameters()))) # run once
old_img_w = old_img_h = imgsz

18
Machine Learning Internship at Algo Analytics

old_img_b = 1

t0 = time.time()
for path, img, im0s, vid_cap in dataset:
img = torch.from_numpy(img).to(device)
img = img.half() if half else img.float() # uint8 to
fp16/32
img /= 255.0 # 0 - 255 to 0.0 - 1.0
if img.ndimension() == 3:
img = img.unsqueeze(0)

# Warmup
if device.type != 'cpu' and (old_img_b != img.shape[0] or
old_img_h != img.shape[2] or old_img_w != img.shape[3]):
old_img_b = img.shape[0]
old_img_h = img.shape[2]
old_img_w = img.shape[3]
for i in range(3):
model(img, augment=opt.augment)[0]

# Inference
t1 = time_synchronized()
with torch.no_grad(): # Calculating gradients would
cause a GPU memory leak
pred = model(img, augment=opt.augment)[0]
t2 = time_synchronized()

# Apply NMS
pred = non_max_suppression(pred, opt.conf_thres,
opt.iou_thres, classes=opt.classes, agnostic=opt.agnostic_nms)
t3 = time_synchronized()

# Apply Classifier
if classify:
pred = apply_classifier(pred, modelc, img, im0s)

# Process detections
for i, det in enumerate(pred): # detections per image
if webcam: # batch_size >= 1
p, s, im0, frame = path[i], '%g: ' % i,
im0s[i].copy(), dataset.count
else:
p, s, im0, frame = path, '', im0s,
getattr(dataset, 'frame', 0)

p = Path(p) # to Path

19
Machine Learning Internship at Algo Analytics

save_path = str(save_dir / p.name) # img.jpg


txt_path = str(save_dir / 'labels' / p.stem) + ('' if
dataset.mode == 'image' else f'_{frame}') # img.txt
gn = torch.tensor(im0.shape)[[1, 0, 1, 0]] #
normalization gain whwh
if len(det):
# Rescale boxes from img_size to im0 size
det[:, :4] = scale_coords(img.shape[2:],
det[:, :4], im0.shape).round()
# found_classes={} #creating dict to store
detected items
# Print results
for c in det[:, -1].unique():
n = (det[:, -1] == c).sum()
# class_index=int(c) # detections per class
# count_of_obj=int(n)
# found_classes[names[class_index]]=int(n)
s += f"{n} {names[int(c)]}{'s' * (n > 1)}, "
# add to string

# Write results
for *xyxy, conf, cls in reversed(det):
if save_txt: # Write to file
xywh =
(xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist()
# normalized xywh
line = (cls, *xywh, conf) if
opt.save_conf else (cls, *xywh) # label format
with open(txt_path + '.txt', 'a') as f:
f.write(('%g ' * len(line)).rstrip()
% line + '\n')

if save_img or view_img: # Add bbox to image


label = f'{names[int(cls)]} {conf:.2f}'
plot_one_box(xyxy, im0, label=label,
color=colors[int(cls)], line_thickness=1)
cv2.putText(im0,f"Total Objects: {len(det)}",
(0,105),cv2.FONT_HERSHEY_TRIPLEX,1,(0,0,0),1)
#cv2.putText(im0,f"{s}",
(0,105),cv2.FONT_HERSHEY_TRIPLEX,1,(255,200,100),1)
# Print time (inference + NMS)
print(f'{s}Done. ({(1E3 * (t2 - t1)):.1f}ms)
Inference, ({(1E3 * (t3 - t2)):.1f}ms) NMS')

# Stream results
if view_img:

20
Machine Learning Internship at Algo Analytics

cv2.imshow(str(p), im0)
cv2.waitKey(1) # 1 millisecond

# Save results (image with detections)


if save_img:
if dataset.mode == 'image':
cv2.imwrite(save_path, im0)
print(f" The image with the result is saved
in: {save_path}")
else: # 'video' or 'stream'
if vid_path != save_path: # new video
vid_path = save_path
if isinstance(vid_writer,
cv2.VideoWriter):
vid_writer.release() # release
previous video writer
if vid_cap: # video
fps = vid_cap.get(cv2.CAP_PROP_FPS)
w =
int(vid_cap.get(cv2.CAP_PROP_FRAME_WIDTH))
h =
int(vid_cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
else: # stream
fps, w, h = 30, im0.shape[1],
im0.shape[0]
save_path += '.mp4'
vid_writer = cv2.VideoWriter(save_path,
cv2.VideoWriter_fourcc(*'mp4v'), fps, (w, h))
vid_writer.write(im0)

if save_txt or save_img:
s = f"\n{len(list(save_dir.glob('labels/*.txt')))} labels
saved to {save_dir / 'labels'}" if save_txt else ''
#print(f"Results saved to {save_dir}{s}")

print(f'Done. ({time.time() - t0:.3f}s)')

5.3.2 Testing of the model in order to find the accuracy

After training phase of the model by feeding the data,the


model was able to detect crowd and certain objects to an
accuracy of about 40% which was quite low. This is
how it looked like:
21
Machine Learning Internship at Algo Analytics

Figure 12: Less accurate crowd detection model

Here in the image , we can observe that only 12 objects have been
identified by the model which is a very poor performance.

In order to increase the efficiency and accuracy of the model,


certain configuration parameters of yolo and its components were changed
and adjusted. Also few more sets of data were fed to data in order to identify
even half shown people within the view of the image.
After the corrections, the accuracy increased to around 80% and this is the
tested image:

22
Machine Learning Internship at Algo Analytics

Figure 13: Higher accuracy crowd detection

Here in the image , we can observe that around 300 objects


including half body person has also been classified as an entity h by the
model which is a pretty good and decent performance.

5.3.3 Deployment of the ML model:

Deployment of machine learning (ML) models refers to


the process of making trained ML models available for use in
production environments, where they can generate predictions or insights in
real-time on new, unseen data.

Code:

# Import necessary libraries

23
Machine Learning Internship at Algo Analytics

from flask import Flask, request, jsonify, render_template


import pickle

# Initialize Flask app with a name


app = Flask("MachineLearningApp")

# Load the trained machine learning model


with open('model.pkl', 'rb') as file:
model = pickle.load(file)

# Define route for the home page


@app.route('/')
def home():
return render_template('index.html')

# Define route for model prediction


@app.route('/predict', methods=['POST'])
def predict():
# Get input data from the request
data = request.form['data']

# Perform prediction using the loaded model


prediction = model.predict([data])[0]

# Return the prediction as a JSON response


return jsonify({'prediction': prediction})

# Run the Flask app


if __name__ == '__main__':
app.run(debug=True)

6. Usage of Modern engineering tools :

a) YOLOv7

24
Machine Learning Internship at Algo Analytics

Figure 14 : The model used for regression and classification

Currently state-of-the-art real-time object detectors are mainly based


on YOLO and FCOS .Being able to become a state-of-the-art real-time
object detector usually requires the following characteristics:
(1) a faster and stronger network architecture
(2) a more effective feature integration method
(3) a more accurate detection method
(4) a more robust loss function

The algorithm works based on the following four approaches:


 Residual blocks-This first step starts by dividing the original image (A)
into NxN grid cells of equal shape. Each cell in the grid is responsible
for localizing and predicting the class of the object that it covers, along
with the probability/confidence value.
 Bounding box regression-The next step is to determine the bounding
boxes which correspond to rectangles highlighting all the objects in the
image. YOLO determines the attributes of these bounding boxes using
a single regression module.

 Intersection Over Unions or IOU-Most of the time, a single object in


an image can have multiple grid box candidates for prediction, even
though not all of them are relevant. Then YOLO computes the IOU of
each grid cell which is the Intersection area divided by the Union Area.
Finally, it ignores the prediction of the grid cells having an IOU ≤
threshold and considers those with an IOU > threshold.
 Non-Maximum Suppression-Setting a threshold for the IOU is not
always enough because an object can have multiple boxes with IOU
beyond the threshold, and leaving all those boxes might include noise.
25
Machine Learning Internship at Algo Analytics

Here is where we can use NMS to keep only the boxes with the highest
probability score of detection.

b) Python

Figure 15 : Python

Python is a high-level, general-purpose programming language.


Python’s extensive library ecosystem, robust visualization
capabilities, low barrier to entry, strong community support,
flexibility, readability, and platform independence make it an ideal
choice for machine learning purposes. As a result, Python has seen a
surge in usage in AI and ML applications, including image and
speech recognition, predictive analytics.

7. Outcome/ results of internship work (screenshots of work done)

26
Machine Learning Internship at Algo Analytics

Figure 16: Alert Details of AQuality project for the quality check of the products

27
Machine Learning Internship at Algo Analytics

Figure 17: Schedule Alerts for quality control- AQuality project

28
Machine Learning Internship at Algo Analytics

Figure 18: Crowd detection model setup in a railway station

Figure 19: Auto Alert generated in a CCTV vision at a specific time under Aksha
project

29
Machine Learning Internship at Algo Analytics

Figure 19: Alerts Dashboard – Aksha project

This figure depicts the dashboard of alerts that have taken place due to
anomalies that were detected by the CCTV surveillance along with the
camera setup, Date, time and the statistical display of the most alerts in the
form of a pie chart.

30
Machine Learning Internship at Algo Analytics

Conclusion

I got to learn a lot of things from this internship, specially


how love2d and blender complements each other and I got to
implement various shaders for giving effects like Blur and
Vignette. Also I submitted this project under the IIT Madras
hackathon, so I got to learn a lot from there as well as how to
manage my time as the time for the hackathon was limited.

31

You might also like