0% found this document useful (0 votes)
35 views3 pages

Object Detection

The document outlines two methods for object detection on static images: using the YOLOv5s model for real-time detection and the Mask R-CNN model for instance segmentation. Both methods operate on CPU-only machines and involve steps such as image loading, model setup, prediction, and displaying results. YOLOv5s is noted for its speed and efficiency, while Mask R-CNN provides accurate segmentation but is slower.

Uploaded by

arasupadhmasini
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)
35 views3 pages

Object Detection

The document outlines two methods for object detection on static images: using the YOLOv5s model for real-time detection and the Mask R-CNN model for instance segmentation. Both methods operate on CPU-only machines and involve steps such as image loading, model setup, prediction, and displaying results. YOLOv5s is noted for its speed and efficiency, while Mask R-CNN provides accurate segmentation but is slower.

Uploaded by

arasupadhmasini
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

OBJECT DETECTION

EX : 7
DATE : 20/7/25

REAL-TIME OBJECT DETECTION USING YOLOV5 ON STATIC IMAGES

AIM:
To detect and localize multiple objects in a static image using the YOLOv5s model
running on a CPU-only machine using PyTorch and OpenCV.

ALGORITHM STEPS:
1. Input Preparation:
o Read an image using OpenCV and convert it from BGR to RGB.

2. Model Loading:
o Load the pretrained YOLOv5s model using PyTorch Hub in evaluation
mode.
3. Prediction:
o Run the model on the input image to get bounding boxes, class
labels, and confidence scores.
4. Rendering:
o Render detections on the image using YOLO’s built-in .render()
method.
5. Display:
o Show the result using matplotlib or OpenCV.

INFERENCE:
 Input: A test image with one or more detectable objects.
 Output: The same image annotated with bounding boxes and class labels.
 Device: Intel i3 CPU using Python 3.12.4, PyTorch (CPU-only), no GPU
required.
 Result: Fast and efficient detection using the lightweight YOLOv5s model
with accurate localization.
MASK R-CNN OBJECT DETECTION
INSTANCE SEGMENTATION USING MASK R-CNN WITH PRETRAINED
PYTORCH MODEL

AIM:
To perform instance-level object detection and segmentation on static images
using the pretrained Mask R-CNN model from the PyTorch torchvision library,
without GPU support.

ALGORITHM STEPS:
1. Image Loading:
o Read the image using Pillow and convert it to RGB.

2. Model Setup:
o Load the maskrcnn_resnet50_fpn model pretrained on COCO
dataset in eval mode.
3. Image Transformation:
o Convert the image to a tensor and add batch dimension.

4. Prediction:
o Pass the image through the model to obtain bounding boxes,
segmentation masks, and class scores.
5. Post-processing:
o Filter results based on a confidence threshold.

o Draw bounding boxes and apply masks on the original image.

6. Display:
o Show the final image with instance masks using matplotlib.

INFERENCE:
 Input: A test image with objects (e.g., person, dog, car).
 Output: The image overlaid with colored masks and bounding boxes for
each detected instance.
 Device: CPU-only (Intel i3), using Python 3.12.4 with torchvision.
 Result: Accurate instance segmentation using a heavyweight model,
slower than YOLO but includes masks.
OUTPUT:

You might also like