Internship-Report 32429
Internship-Report 32429
(PICT) Pune
AN
INTERNSHIP REPORT
ON
SUBMITTED BY
Name: Kaushik Aduri
Class: TE 6
Roll no: 32429
CERTIFICATE
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.
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
6
Machine Learning Internship at Algo Analytics
List of tables
7
Machine Learning Internship at Algo Analytics
1. Title
2. Introduction
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
9
Machine Learning Internship at Algo Analytics
5. Methodological details
Figure
2:
ATM
data
image-
1
Figure 3: ATM data image-2
11
Machine Learning Internship at Algo Analytics
Figure 4:
Quality part
data image-1
Figure 5:
Quality part
data image-2
Aksha-
12
Machine Learning Internship at Algo Analytics
AQuality-
13
Machine Learning Internship at Algo Analytics
Code:
import cv2
14
Machine Learning Internship at Algo Analytics
import os
img = cv2.imread(img_path)
if img is None:
continue
15
Machine Learning Internship at Algo Analytics
cv2.imwrite(output_path, augmented_img)
16
Machine Learning Internship at Algo Analytics
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
# 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
# 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)
# 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
# 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')
# Stream results
if view_img:
20
Machine Learning Internship at Algo Analytics
cv2.imshow(str(p), im0)
cv2.waitKey(1) # 1 millisecond
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}")
Here in the image , we can observe that only 12 objects have been
identified by the model which is a very poor performance.
22
Machine Learning Internship at Algo Analytics
Code:
23
Machine Learning Internship at Algo Analytics
a) YOLOv7
24
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
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
28
Machine Learning Internship at Algo Analytics
Figure 19: Auto Alert generated in a CCTV vision at a specific time under Aksha
project
29
Machine Learning Internship at Algo Analytics
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
31