This report provides an overview and analysis of a Python script that utilizes the Ultralytics library to work with a YOLOv8 object detection model. The script performs two primary tasks: training the YOLOv8 model on a custom dataset and conducting inference on a sample image. The script's functionality, including model loading, training, and inference, is examined in detail.
The Python script leverages the Ultralytics library to work with a YOLOv8 model. YOLO (You Only Look Once) is a popular object detection algorithm known for its speed and accuracy.
names: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'circle', 'cross', 'g', 'hexagon', 'pentagon', 'plus', 'rectangle', 'star', 'trapezium', 'triangle']
The script starts by loading a pre-trained YOLOv8 model using the following code:
The 'yolov8n.pt' file contains pre-trained weights for the YOLOv8 model. This pre-trained model serves as the starting point for further training or inference.
The next part of the script is dedicated to training the YOLOv8 model on a custom dataset. The training process is initiated with the following code:
Here is a link to the dataset used in this code : https://universe.roboflow.com/vidhi6khosla-gmail-com/suas-final
Following model training, the script proceeds to perform inference on a sample image using the trained YOLOv8 model. The inference code is as follows:
The inference code performs the following actions:
- image_path = 'shape.jpg': Specifies the path to the input image ('shape.jpg') on which object detection will be performed.
- model.predict(...): Initiates the inference process, where the model processes the input image and detects objects. The detected objects are annotated with bounding boxes, and the annotated image can be saved and displayed.
- The resulting image after feeding the input image 'shape.jpg' into the model