Computer Vision with YOLOv11 - Vehicle DetectionΒΆ

Author: Guillaume EGU

Project OverviewΒΆ

This project implements a vehicle detection system using YOLOv11 (You Only Look Once version 11), one of the most powerful object detection models. The objective is to automatically detect and classify different types of vehicles in real-time images.

The dataset contains annotated images of 5 vehicle classes: Ambulance, Bus, Car, Motorcycle, and Truck. This project demonstrates the effectiveness of modern deep learning architectures for object detection in computer vision.

Data Source: Vehicle detection dataset with annotations: https://universe.roboflow.com/vaishak-shetty-sri7e/vehicle-detection-byizq

Project ObjectivesΒΆ

  1. Data Exploration: Analyze the distribution and characteristics of vehicle images
  2. Data Preparation: Configure the dataset in YOLO format with appropriate paths and classes
  3. Model Training: Fine-tune YOLOv11 on our specific vehicle dataset
  4. Performance Evaluation: Analyze detection metrics and model accuracy
  5. Testing and Validation: Test the trained model on new images

Practical ValueΒΆ

  • Traffic Monitoring: Automatically count and classify vehicles
  • Road Safety: Detect emergency vehicles (ambulances)
  • Urban Analysis: Understand traffic flows
  • Real-Time Applications: Fast video image processing

ContentΒΆ

  • Library Imports
  • Data Configuration
  • Data Exploration and Visualization
  • YOLOv11 Model Training
  • Performance Evaluation
  • Testing on New Images
  • Results Analysis

Import LibrariesΒΆ

Installation and importation of key libraries


InΒ [2]:
!pip install pandas
!pip install matplotlib
!pip install seaborn
!pip install scikit-learn
!pip install numpy
!pip install imblearn
!pip install xgboost
!pip install ultralytics
Requirement already satisfied: pandas in c:\users\guill\anaconda3\lib\site-packages (2.2.2)
Requirement already satisfied: numpy>=1.26.0 in c:\users\guill\anaconda3\lib\site-packages (from pandas) (1.26.4)
Requirement already satisfied: python-dateutil>=2.8.2 in c:\users\guill\anaconda3\lib\site-packages (from pandas) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in c:\users\guill\anaconda3\lib\site-packages (from pandas) (2024.1)
Requirement already satisfied: tzdata>=2022.7 in c:\users\guill\anaconda3\lib\site-packages (from pandas) (2023.3)
Requirement already satisfied: six>=1.5 in c:\users\guill\anaconda3\lib\site-packages (from python-dateutil>=2.8.2->pandas) (1.16.0)
Requirement already satisfied: matplotlib in c:\users\guill\anaconda3\lib\site-packages (3.8.4)
Requirement already satisfied: contourpy>=1.0.1 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib) (1.2.0)
Requirement already satisfied: cycler>=0.10 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib) (0.11.0)
Requirement already satisfied: fonttools>=4.22.0 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib) (4.51.0)
Requirement already satisfied: kiwisolver>=1.3.1 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib) (1.4.4)
Requirement already satisfied: numpy>=1.21 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib) (1.26.4)
Requirement already satisfied: packaging>=20.0 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib) (23.2)
Requirement already satisfied: pillow>=8 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib) (10.3.0)
Requirement already satisfied: pyparsing>=2.3.1 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib) (3.0.9)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib) (2.9.0.post0)
Requirement already satisfied: six>=1.5 in c:\users\guill\anaconda3\lib\site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)
Requirement already satisfied: seaborn in c:\users\guill\anaconda3\lib\site-packages (0.13.2)
Requirement already satisfied: numpy!=1.24.0,>=1.20 in c:\users\guill\anaconda3\lib\site-packages (from seaborn) (1.26.4)
Requirement already satisfied: pandas>=1.2 in c:\users\guill\anaconda3\lib\site-packages (from seaborn) (2.2.2)
Requirement already satisfied: matplotlib!=3.6.1,>=3.4 in c:\users\guill\anaconda3\lib\site-packages (from seaborn) (3.8.4)
Requirement already satisfied: contourpy>=1.0.1 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (1.2.0)
Requirement already satisfied: cycler>=0.10 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (0.11.0)
Requirement already satisfied: fonttools>=4.22.0 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (4.51.0)
Requirement already satisfied: kiwisolver>=1.3.1 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (1.4.4)
Requirement already satisfied: packaging>=20.0 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (23.2)
Requirement already satisfied: pillow>=8 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (10.3.0)
Requirement already satisfied: pyparsing>=2.3.1 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (3.0.9)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in c:\users\guill\anaconda3\lib\site-packages (from pandas>=1.2->seaborn) (2024.1)
Requirement already satisfied: tzdata>=2022.7 in c:\users\guill\anaconda3\lib\site-packages (from pandas>=1.2->seaborn) (2023.3)
Requirement already satisfied: six>=1.5 in c:\users\guill\anaconda3\lib\site-packages (from python-dateutil>=2.7->matplotlib!=3.6.1,>=3.4->seaborn) (1.16.0)
Requirement already satisfied: scikit-learn in c:\users\guill\anaconda3\lib\site-packages (1.4.2)
Requirement already satisfied: numpy>=1.19.5 in c:\users\guill\anaconda3\lib\site-packages (from scikit-learn) (1.26.4)
Requirement already satisfied: scipy>=1.6.0 in c:\users\guill\anaconda3\lib\site-packages (from scikit-learn) (1.13.1)
Requirement already satisfied: joblib>=1.2.0 in c:\users\guill\anaconda3\lib\site-packages (from scikit-learn) (1.4.2)
Requirement already satisfied: threadpoolctl>=2.0.0 in c:\users\guill\anaconda3\lib\site-packages (from scikit-learn) (2.2.0)
Requirement already satisfied: numpy in c:\users\guill\anaconda3\lib\site-packages (1.26.4)
Requirement already satisfied: imblearn in c:\users\guill\anaconda3\lib\site-packages (0.0)
Requirement already satisfied: imbalanced-learn in c:\users\guill\anaconda3\lib\site-packages (from imblearn) (0.12.3)
Requirement already satisfied: numpy>=1.17.3 in c:\users\guill\anaconda3\lib\site-packages (from imbalanced-learn->imblearn) (1.26.4)
Requirement already satisfied: scipy>=1.5.0 in c:\users\guill\anaconda3\lib\site-packages (from imbalanced-learn->imblearn) (1.13.1)
Requirement already satisfied: scikit-learn>=1.0.2 in c:\users\guill\anaconda3\lib\site-packages (from imbalanced-learn->imblearn) (1.4.2)
Requirement already satisfied: joblib>=1.1.1 in c:\users\guill\anaconda3\lib\site-packages (from imbalanced-learn->imblearn) (1.4.2)
Requirement already satisfied: threadpoolctl>=2.0.0 in c:\users\guill\anaconda3\lib\site-packages (from imbalanced-learn->imblearn) (2.2.0)
Requirement already satisfied: xgboost in c:\users\guill\anaconda3\lib\site-packages (3.0.5)
Requirement already satisfied: numpy in c:\users\guill\anaconda3\lib\site-packages (from xgboost) (1.26.4)
Requirement already satisfied: scipy in c:\users\guill\anaconda3\lib\site-packages (from xgboost) (1.13.1)
Requirement already satisfied: ultralytics in c:\users\guill\anaconda3\lib\site-packages (8.3.220)
Requirement already satisfied: numpy>=1.23.0 in c:\users\guill\anaconda3\lib\site-packages (from ultralytics) (1.26.4)
Requirement already satisfied: matplotlib>=3.3.0 in c:\users\guill\anaconda3\lib\site-packages (from ultralytics) (3.8.4)
Requirement already satisfied: opencv-python>=4.6.0 in c:\users\guill\anaconda3\lib\site-packages (from ultralytics) (4.10.0.84)
Requirement already satisfied: pillow>=7.1.2 in c:\users\guill\anaconda3\lib\site-packages (from ultralytics) (10.3.0)
Requirement already satisfied: pyyaml>=5.3.1 in c:\users\guill\anaconda3\lib\site-packages (from ultralytics) (6.0.1)
Requirement already satisfied: requests>=2.23.0 in c:\users\guill\anaconda3\lib\site-packages (from ultralytics) (2.32.2)
Requirement already satisfied: scipy>=1.4.1 in c:\users\guill\anaconda3\lib\site-packages (from ultralytics) (1.13.1)
Requirement already satisfied: torch>=1.8.0 in c:\users\guill\anaconda3\lib\site-packages (from ultralytics) (2.9.0)
Requirement already satisfied: torchvision>=0.9.0 in c:\users\guill\anaconda3\lib\site-packages (from ultralytics) (0.24.0)
Requirement already satisfied: psutil in c:\users\guill\anaconda3\lib\site-packages (from ultralytics) (5.9.0)
Requirement already satisfied: polars in c:\users\guill\anaconda3\lib\site-packages (from ultralytics) (1.34.0)
Requirement already satisfied: ultralytics-thop>=2.0.0 in c:\users\guill\anaconda3\lib\site-packages (from ultralytics) (2.0.17)
Requirement already satisfied: contourpy>=1.0.1 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib>=3.3.0->ultralytics) (1.2.0)
Requirement already satisfied: cycler>=0.10 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib>=3.3.0->ultralytics) (0.11.0)
Requirement already satisfied: fonttools>=4.22.0 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib>=3.3.0->ultralytics) (4.51.0)
Requirement already satisfied: kiwisolver>=1.3.1 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib>=3.3.0->ultralytics) (1.4.4)
Requirement already satisfied: packaging>=20.0 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib>=3.3.0->ultralytics) (23.2)
Requirement already satisfied: pyparsing>=2.3.1 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib>=3.3.0->ultralytics) (3.0.9)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\guill\anaconda3\lib\site-packages (from matplotlib>=3.3.0->ultralytics) (2.9.0.post0)
Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\guill\anaconda3\lib\site-packages (from requests>=2.23.0->ultralytics) (2.0.4)
Requirement already satisfied: idna<4,>=2.5 in c:\users\guill\anaconda3\lib\site-packages (from requests>=2.23.0->ultralytics) (3.7)
Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\guill\anaconda3\lib\site-packages (from requests>=2.23.0->ultralytics) (2.2.2)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\guill\anaconda3\lib\site-packages (from requests>=2.23.0->ultralytics) (2025.10.5)
Requirement already satisfied: filelock in c:\users\guill\anaconda3\lib\site-packages (from torch>=1.8.0->ultralytics) (3.13.1)
Requirement already satisfied: typing-extensions>=4.10.0 in c:\users\guill\anaconda3\lib\site-packages (from torch>=1.8.0->ultralytics) (4.11.0)
Requirement already satisfied: sympy>=1.13.3 in c:\users\guill\anaconda3\lib\site-packages (from torch>=1.8.0->ultralytics) (1.14.0)
Requirement already satisfied: networkx>=2.5.1 in c:\users\guill\anaconda3\lib\site-packages (from torch>=1.8.0->ultralytics) (3.2.1)
Requirement already satisfied: jinja2 in c:\users\guill\anaconda3\lib\site-packages (from torch>=1.8.0->ultralytics) (3.1.4)
Requirement already satisfied: fsspec>=0.8.5 in c:\users\guill\anaconda3\lib\site-packages (from torch>=1.8.0->ultralytics) (2024.3.1)
Requirement already satisfied: setuptools in c:\users\guill\anaconda3\lib\site-packages (from torch>=1.8.0->ultralytics) (69.5.1)
Requirement already satisfied: polars-runtime-32==1.34.0 in c:\users\guill\anaconda3\lib\site-packages (from polars->ultralytics) (1.34.0)
Requirement already satisfied: six>=1.5 in c:\users\guill\anaconda3\lib\site-packages (from python-dateutil>=2.7->matplotlib>=3.3.0->ultralytics) (1.16.0)
Requirement already satisfied: mpmath<1.4,>=1.1.0 in c:\users\guill\anaconda3\lib\site-packages (from sympy>=1.13.3->torch>=1.8.0->ultralytics) (1.3.0)
Requirement already satisfied: MarkupSafe>=2.0 in c:\users\guill\anaconda3\lib\site-packages (from jinja2->torch>=1.8.0->ultralytics) (2.1.3)
InΒ [3]:
# Handle the data
import os
import random 
import pandas as pd
import numpy as np
import cv2
import torch
from IPython.display import Image as IPythonImage, display
from PIL import Image as PILImage

# Visualization
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import seaborn as sns
from matplotlib.colors import ListedColormap

# Models
from PIL import Image
import yaml
from ultralytics import YOLO
from sklearn.metrics import precision_score, recall_score

FunctionsΒΆ

These helper functions implement the core NLP preprocessing pipeline. Each function serves a specific purpose in transforming raw text into a format suitable for machine learning algorithms.


InΒ [Β ]:
 

Data LoadΒΆ

Cell for loading the data in a single dataframe.


Creating the YAML configuration file required by YOLOv11 to define data paths and vehicle classes

InΒ [4]:
path_train = "./datasets/VehiclesDetectionDataset/train/images/"
path_val = "./datasets/VehiclesDetectionDataset/val/images/"
path_test = "./datasets/VehiclesDetectionDataset/test/images/"


yaml_content = f"""
test: {path_test}
train: {path_train}
val: {path_val}

nc: 5 
names: ['Ambulance', 'Bus', 'Car', 'Motorcycle', 'Truck']
"""
output_path= 'data.yaml'
with open(output_path, "w") as file:
    file.write(yaml_content)
print(f"YAML file has been saved to {output_path}")
YAML file has been saved to data.yaml

Reading and displaying vehicle classes defined in the configuration file

InΒ [5]:
with open(output_path, 'r') as file:
    data = yaml.safe_load(file)
class_names = data['names']
print("Class names:", class_names )
Class names: ['Ambulance', 'Bus', 'Car', 'Motorcycle', 'Truck']

Exploratory Data Analysis (EDA) and Dataset UnderstandingΒΆ

In this crucial step, we explore the vehicle detection dataset to understand:

  • Dataset Structure: How many images are in train/validation/test splits?
  • Vehicle Classes Distribution: Are all 5 vehicle types (Ambulance, Bus, Car, Motorcycle, Truck) equally represented?
  • Image Characteristics: What are the typical dimensions, quality, and visual properties?
  • Annotation Quality: How well are the bounding boxes and labels defined?
  • Data Diversity: Do we have sufficient variety in lighting, angles, and backgrounds?

Exploring technical characteristics of a random image (dimensions, color mode, number of channels)

InΒ [6]:
images_folder = './datasets/VehiclesDetectionDataset/train/images'
image_files = [f for f in os.listdir(images_folder) if f.endswith(('.jpg', '.png', '.jpeg'))]
random_image = random.choice(image_files)
random_image_path = os.path.join(images_folder, random_image)
image = PILImage.open(random_image_path)
image_size = image.size
image_mode = image.mode
num_channels = image.layers if hasattr(image, 'layers') else len(image.getbands())
print(f"Random Image: {random_image}")
print(f"Image Size: {image_size}")
print(f"Image Mode (Channels): {image_mode}")
print(f"Number of Channels: {num_channels}")
Random Image: 3ded02412ac12d4b_jpg.rf.pGfJCgNuD514KHsWDFNc.jpg
Image Size: (416, 416)
Image Mode (Channels): RGB
Number of Channels: 3

Displaying a 4x4 grid of random images from the training dataset to explore data diversity

InΒ [7]:
image_files = [f for f in os.listdir(path_train) if f.endswith('.jpg')]
selected_images = random.sample(image_files, 16)
fig, axes = plt.subplots(4, 4, figsize=(10, 10))
for i, ax in enumerate(axes.flat):
    img_path = os.path.join(path_train, selected_images[i])
    img = mpimg.imread(img_path)
    ax.imshow(img)
    ax.axis('off')
plt.tight_layout()
plt.show()
No description has been provided for this image

Evaluating detection capabilities of the YOLOv11 nano model on our dataset images before fine-tuning

InΒ [8]:
images_folder = './datasets/VehiclesDetectionDataset/train/images'
images_files = [f for f in os.listdir(images_folder) if f.endswith(('.jpg', '.png', '.jpeg'))]
random_images = random.sample(images_files, 20)

model = YOLO('./models/yolo11n.pt')
for image_file in random_images:
    image_path = os.path.join(images_folder, image_file)
    result_predict = model.predict(source=image_path, imgsz=(416))
    original_image = PILImage.open(image_path)
    display(original_image)
    for result in result_predict:
        plot = result.plot()
        plot = cv2.cvtColor(plot, cv2.COLOR_BGR2RGB)
        display(PILImage.fromarray(plot))
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\a6bae981a16ab9a6_jpg.rf.51773282f8cc4691c58f8f1929949c3b.jpg: 416x416 1 car, 153.3ms
Speed: 3.5ms preprocess, 153.3ms inference, 12.3ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\c52500a14f92ff65_jpg.rf.bac8f96b8928ebabc80a2e39fe5bb650.jpg: 416x416 4 persons, 1 truck, 65.8ms
Speed: 2.3ms preprocess, 65.8ms inference, 5.2ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\27fed64f6e8e0fb1_jpg.rf.365f036b3c5c98218829c2b839a9bbe9.jpg: 416x416 1 person, 4 cars, 71.9ms
Speed: 1.3ms preprocess, 71.9ms inference, 2.3ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\3306489836719c96_jpg.rf.a9ffe2471f824bc00b2ed031a04845cc.jpg: 416x416 4 cars, 1 bus, 59.0ms
Speed: 1.2ms preprocess, 59.0ms inference, 2.1ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\f8c637fc8220a918_jpg.rf.7InkNTlGkJXqHqcTw9ev.jpg: 416x416 6 persons, 1 bus, 1 handbag, 71.3ms
Speed: 0.9ms preprocess, 71.3ms inference, 2.8ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\005980b3a5f93085_jpg.rf.2QZCXGReqcBORWQJKQfO.jpg: 416x416 1 person, 1 bus, 1 truck, 72.8ms
Speed: 2.7ms preprocess, 72.8ms inference, 1.6ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\fedcf2c1a78c1446_jpg.rf.97d463394d7e15988400d1ac9d9ceacb.jpg: 416x416 3 cars, 58.6ms
Speed: 0.9ms preprocess, 58.6ms inference, 1.9ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\ccda9fe055e7fb14_jpg.rf.qpuvhah7Z8cihR1hXZXD.jpg: 416x416 1 bus, 56.6ms
Speed: 1.3ms preprocess, 56.6ms inference, 1.2ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\fedcf2c1a78c1446_jpg.rf.jKHFjts8DglEwHYNbghh.jpg: 416x416 3 cars, 75.1ms
Speed: 1.3ms preprocess, 75.1ms inference, 2.9ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\32af44c2a2cfb296_jpg.rf.3813b66f92c72dd943b24814e9894231.jpg: 416x416 4 persons, 3 cars, 2 trucks, 73.5ms
Speed: 1.2ms preprocess, 73.5ms inference, 3.5ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\8f28dbee29152679_jpg.rf.5t0m9nzoBwio0AecyWRG.jpg: 416x416 3 cars, 106.9ms
Speed: 0.9ms preprocess, 106.9ms inference, 2.4ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\6b08b17e4bd591d8_jpg.rf.13bc2985423afe433b8d9088662b4e71.jpg: 416x416 1 car, 60.3ms
Speed: 1.1ms preprocess, 60.3ms inference, 1.4ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\da386cf96761ef58_jpg.rf.R27NNWvN3ZYHN4n3DiH4.jpg: 416x416 3 persons, 1 car, 2 trucks, 86.5ms
Speed: 1.2ms preprocess, 86.5ms inference, 2.0ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\1781ceeba365928b_jpg.rf.b658668ccefc5b053a17a307e0cd6c11.jpg: 416x416 3 persons, 3 cars, 2 buss, 105.1ms
Speed: 1.6ms preprocess, 105.1ms inference, 5.1ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\ebdb1c5cf58b8a86_jpg.rf.EfI0z3s3CbeZhsXHZGPU.jpg: 416x416 4 persons, 1 bus, 86.9ms
Speed: 0.9ms preprocess, 86.9ms inference, 2.2ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\f1200c263667e455_jpg.rf.fnY9QjRYJ0Ed7j4H24ZC.jpg: 416x416 2 persons, 1 truck, 83.6ms
Speed: 2.0ms preprocess, 83.6ms inference, 2.3ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\3e485b3cb8cb0739_jpg.rf.550ad500da07f3ef54f7d05d9e36f549.jpg: 416x416 9 persons, 4 cars, 3 trucks, 59.7ms
Speed: 1.3ms preprocess, 59.7ms inference, 3.7ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\fa4373131d980682_jpg.rf.fb4066e24ca14b29bcee16051cec2834.jpg: 416x416 4 persons, 1 bus, 1 truck, 102.9ms
Speed: 1.0ms preprocess, 102.9ms inference, 3.1ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\d31c720e294fee1a_jpg.rf.7dae13b793e31e8c1ab96b8b1915f32f.jpg: 416x416 1 car, 1 truck, 112.1ms
Speed: 1.0ms preprocess, 112.1ms inference, 1.7ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\552a0d9a0fc92dac_jpg.rf.c1d215d149e6deb7126925352ac37518.jpg: 416x416 1 car, 2 trucks, 62.3ms
Speed: 0.9ms preprocess, 62.3ms inference, 1.6ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
InΒ [35]:
random_images = random.sample(image_files, 20)
model = YOLO("./models/yolo11n.pt")
for image_file in random_images:
    image_path = os.path.join(images_folder, image_file)
    result_predict = model.predict(source=image_path, imgsz=(416))
    original_image = Image.open(image_path)
    display(original_image)
    for result in result_predict:
        plot = result.plot()
        plot = cv2.cvtColor(plot, cv2.COLOR_BGR2RGB)
        display(Image.fromarray(plot))
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\040d25a99e7b675b_jpg.rf.UIHiGJcPfPY36egSAJft.jpg: 416x416 1 truck, 150.4ms
Speed: 2.2ms preprocess, 150.4ms inference, 1.6ms postprocess per image at shape (1, 3, 416, 416)
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\040d25a99e7b675b_jpg.rf.UIHiGJcPfPY36egSAJft.jpg: 416x416 1 truck, 150.4ms
Speed: 2.2ms preprocess, 150.4ms inference, 1.6ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\6369f9d6c2bfab75_jpg.rf.pFHXUaD0AFmCJepgyor1.jpg: 416x416 1 person, 1 car, 2 boats, 141.4ms
Speed: 1.7ms preprocess, 141.4ms inference, 2.2ms postprocess per image at shape (1, 3, 416, 416)
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\6369f9d6c2bfab75_jpg.rf.pFHXUaD0AFmCJepgyor1.jpg: 416x416 1 person, 1 car, 2 boats, 141.4ms
Speed: 1.7ms preprocess, 141.4ms inference, 2.2ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\d8b725a5e406bf77_jpg.rf.4a1b8136fd8ff4f981e50ed6ecc18645.jpg: 416x416 1 bus, 229.4ms
Speed: 1.5ms preprocess, 229.4ms inference, 4.2ms postprocess per image at shape (1, 3, 416, 416)
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\d8b725a5e406bf77_jpg.rf.4a1b8136fd8ff4f981e50ed6ecc18645.jpg: 416x416 1 bus, 229.4ms
Speed: 1.5ms preprocess, 229.4ms inference, 4.2ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\447c9ff274fab842_jpg.rf.Yzz1UWLTvLeMwXBZTtat.jpg: 416x416 2 buss, 103.8ms
Speed: 2.5ms preprocess, 103.8ms inference, 2.0ms postprocess per image at shape (1, 3, 416, 416)
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\447c9ff274fab842_jpg.rf.Yzz1UWLTvLeMwXBZTtat.jpg: 416x416 2 buss, 103.8ms
Speed: 2.5ms preprocess, 103.8ms inference, 2.0ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\63ee0ce9f69bf8e5_jpg.rf.PnRjGBSWtdTYaYCq1Q6z.jpg: 416x416 1 truck, 202.1ms
Speed: 1.6ms preprocess, 202.1ms inference, 1.7ms postprocess per image at shape (1, 3, 416, 416)
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\63ee0ce9f69bf8e5_jpg.rf.PnRjGBSWtdTYaYCq1Q6z.jpg: 416x416 1 truck, 202.1ms
Speed: 1.6ms preprocess, 202.1ms inference, 1.7ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\91e11943f15e4b3c_jpg.rf.9luwWbGyIEfG0TqiyFj7.jpg: 416x416 1 truck, 63.6ms
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\91e11943f15e4b3c_jpg.rf.9luwWbGyIEfG0TqiyFj7.jpg: 416x416 1 truck, 63.6ms
Speed: 1.1ms preprocess, 63.6ms inference, 1.7ms postprocess per image at shape (1, 3, 416, 416)
Speed: 1.1ms preprocess, 63.6ms inference, 1.7ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\005980b3a5f93085_jpg.rf.2QZCXGReqcBORWQJKQfO.jpg: 416x416 1 person, 1 bus, 1 truck, 132.1ms
Speed: 3.7ms preprocess, 132.1ms inference, 2.1ms postprocess per image at shape (1, 3, 416, 416)
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\005980b3a5f93085_jpg.rf.2QZCXGReqcBORWQJKQfO.jpg: 416x416 1 person, 1 bus, 1 truck, 132.1ms
Speed: 3.7ms preprocess, 132.1ms inference, 2.1ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\aa159f88e636f64c_jpg.rf.ZDjdESkuzWQEgJG2jj7r.jpg: 416x416 1 person, 1 motorcycle, 2 umbrellas, 90.6ms
Speed: 1.4ms preprocess, 90.6ms inference, 1.9ms postprocess per image at shape (1, 3, 416, 416)
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\aa159f88e636f64c_jpg.rf.ZDjdESkuzWQEgJG2jj7r.jpg: 416x416 1 person, 1 motorcycle, 2 umbrellas, 90.6ms
Speed: 1.4ms preprocess, 90.6ms inference, 1.9ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\6361620bf0d610ac_jpg.rf.7b8028befa441533f8a69efc71bfc664.jpg: 416x416 1 person, 2 cars, 79.5ms
Speed: 1.0ms preprocess, 79.5ms inference, 1.8ms postprocess per image at shape (1, 3, 416, 416)
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\6361620bf0d610ac_jpg.rf.7b8028befa441533f8a69efc71bfc664.jpg: 416x416 1 person, 2 cars, 79.5ms
Speed: 1.0ms preprocess, 79.5ms inference, 1.8ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\5be6fbdc2835aa92_jpg.rf.3c40a2205b11743f7a78f1f4570a9c52.jpg: 416x416 1 motorcycle, 158.8ms
Speed: 10.6ms preprocess, 158.8ms inference, 1.4ms postprocess per image at shape (1, 3, 416, 416)
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\5be6fbdc2835aa92_jpg.rf.3c40a2205b11743f7a78f1f4570a9c52.jpg: 416x416 1 motorcycle, 158.8ms
Speed: 10.6ms preprocess, 158.8ms inference, 1.4ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\2d94e4aa09c1c7de_jpg.rf.PqpF5J0wmYBef380GjYT.jpg: 416x416 2 persons, 1 bicycle, 1 truck, 61.8ms
Speed: 0.9ms preprocess, 61.8ms inference, 2.3ms postprocess per image at shape (1, 3, 416, 416)
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\2d94e4aa09c1c7de_jpg.rf.PqpF5J0wmYBef380GjYT.jpg: 416x416 2 persons, 1 bicycle, 1 truck, 61.8ms
Speed: 0.9ms preprocess, 61.8ms inference, 2.3ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\f971dfb20ee52e9b_jpg.rf.24f2b59b01e256b4bb2671fe87bb12a0.jpg: 416x416 6 persons, 1 bus, 76.4ms
Speed: 1.1ms preprocess, 76.4ms inference, 5.3ms postprocess per image at shape (1, 3, 416, 416)
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\f971dfb20ee52e9b_jpg.rf.24f2b59b01e256b4bb2671fe87bb12a0.jpg: 416x416 6 persons, 1 bus, 76.4ms
Speed: 1.1ms preprocess, 76.4ms inference, 5.3ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\2e29dd7285110315_jpg.rf.22aaf637e168b3dc960eb35532e3ac1a.jpg: 416x416 3 persons, 1 truck, 226.2ms
Speed: 1.4ms preprocess, 226.2ms inference, 2.0ms postprocess per image at shape (1, 3, 416, 416)
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\2e29dd7285110315_jpg.rf.22aaf637e168b3dc960eb35532e3ac1a.jpg: 416x416 3 persons, 1 truck, 226.2ms
Speed: 1.4ms preprocess, 226.2ms inference, 2.0ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\9c5cf4fed30054f2_jpg.rf.4c9KkOPfM8k1SOgmUfY3.jpg: 416x416 1 person, 1 car, 1 truck, 171.4ms
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\9c5cf4fed30054f2_jpg.rf.4c9KkOPfM8k1SOgmUfY3.jpg: 416x416 1 person, 1 car, 1 truck, 171.4ms
Speed: 1.6ms preprocess, 171.4ms inference, 1.9ms postprocess per image at shape (1, 3, 416, 416)
Speed: 1.6ms preprocess, 171.4ms inference, 1.9ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\7f521593dc5e1d37_jpg.rf.92e08b32b0c6a968875ede7473a7300d.jpg: 416x416 1 person, 1 bus, 103.8ms
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\7f521593dc5e1d37_jpg.rf.92e08b32b0c6a968875ede7473a7300d.jpg: 416x416 1 person, 1 bus, 103.8ms
Speed: 1.3ms preprocess, 103.8ms inference, 2.1ms postprocess per image at shape (1, 3, 416, 416)
Speed: 1.3ms preprocess, 103.8ms inference, 2.1ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\d8b725a5e406bf77_jpg.rf.EKunjNrlRMzJi9uRdXQp.jpg: 416x416 1 bus, 225.6ms
Speed: 3.8ms preprocess, 225.6ms inference, 4.5ms postprocess per image at shape (1, 3, 416, 416)
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\d8b725a5e406bf77_jpg.rf.EKunjNrlRMzJi9uRdXQp.jpg: 416x416 1 bus, 225.6ms
Speed: 3.8ms preprocess, 225.6ms inference, 4.5ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\1e668423ae32ce6f_jpg.rf.8fc1bcf11c1a5bb1747a7ec8b3a16746.jpg: 416x416 1 person, 4 cars, 2 trucks, 100.9ms
Speed: 1.0ms preprocess, 100.9ms inference, 2.4ms postprocess per image at shape (1, 3, 416, 416)
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\1e668423ae32ce6f_jpg.rf.8fc1bcf11c1a5bb1747a7ec8b3a16746.jpg: 416x416 1 person, 4 cars, 2 trucks, 100.9ms
Speed: 1.0ms preprocess, 100.9ms inference, 2.4ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\fd063bf2b2c9def1_jpg.rf.985934634819454d657ab33d75edc5eb.jpg: 416x416 4 persons, 2 cars, 2 motorcycles, 96.2ms
Speed: 12.2ms preprocess, 96.2ms inference, 3.7ms postprocess per image at shape (1, 3, 416, 416)
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\fd063bf2b2c9def1_jpg.rf.985934634819454d657ab33d75edc5eb.jpg: 416x416 4 persons, 2 cars, 2 motorcycles, 96.2ms
Speed: 12.2ms preprocess, 96.2ms inference, 3.7ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\53b558dba2201be2_jpg.rf.33749a36ae6eabc4d8b15ec4da8a5be8.jpg: 416x416 2 trucks, 78.7ms
Speed: 1.0ms preprocess, 78.7ms inference, 1.9ms postprocess per image at shape (1, 3, 416, 416)
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\53b558dba2201be2_jpg.rf.33749a36ae6eabc4d8b15ec4da8a5be8.jpg: 416x416 2 trucks, 78.7ms
Speed: 1.0ms preprocess, 78.7ms inference, 1.9ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\dc904e3df7290455_jpg.rf.26009aa427781cc11d166df8aab44e43.jpg: 416x416 1 car, 57.8ms
Speed: 1.0ms preprocess, 57.8ms inference, 1.5ms postprocess per image at shape (1, 3, 416, 416)
image 1/1 c:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\images\dc904e3df7290455_jpg.rf.26009aa427781cc11d166df8aab44e43.jpg: 416x416 1 car, 57.8ms
Speed: 1.0ms preprocess, 57.8ms inference, 1.5ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image

Fine-tuning the YOLOv11 model on our specific vehicle dataset with optimized hyperparameters

InΒ [42]:
finalmodel = YOLO('yolo11n.yaml').load('.models/yolo11n.pt')  
Result_finalmodel = finalmodel.train(
    data="./datasets/VehiclesDetectionDataset/dataset.yaml",
    epochs=20, 
    imgsz=416, 
    batch=8, 
    lr0=0.001, 
    dropout=0.1, 
    device='cpu'
)
Transferred 499/499 items from pretrained weights
Ultralytics 8.3.220  Python-3.12.3 torch-2.9.0+cpu CPU (AMD Ryzen 7 5700U with Radeon Graphics)
Ultralytics 8.3.220  Python-3.12.3 torch-2.9.0+cpu CPU (AMD Ryzen 7 5700U with Radeon Graphics)
engine\trainer: agnostic_nms=False, amp=True, augment=False, auto_augment=randaugment, batch=8, bgr=0.0, box=7.5, cache=False, cfg=None, classes=None, close_mosaic=10, cls=0.5, compile=False, conf=None, copy_paste=0.0, copy_paste_mode=flip, cos_lr=False, cutmix=0.0, data=./datasets/VehiclesDetectionDataset/dataset.yaml, degrees=0.0, deterministic=True, device=cpu, dfl=1.5, dnn=False, dropout=0.1, dynamic=False, embed=None, epochs=20, erasing=0.4, exist_ok=False, fliplr=0.5, flipud=0.0, format=torchscript, fraction=1.0, freeze=None, half=False, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, imgsz=416, int8=False, iou=0.7, keras=False, kobj=1.0, line_width=None, lr0=0.001, lrf=0.01, mask_ratio=4, max_det=300, mixup=0.0, mode=train, model=yolo11n.yaml, momentum=0.937, mosaic=1.0, multi_scale=False, name=train2, nbs=64, nms=False, opset=None, optimize=False, optimizer=auto, overlap_mask=True, patience=100, perspective=0.0, plots=True, pose=12.0, pretrained=.models/yolo11n.pt, profile=False, project=None, rect=False, resume=False, retina_masks=False, save=True, save_conf=False, save_crop=False, save_dir=C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\runs\detect\train2, save_frames=False, save_json=False, save_period=-1, save_txt=False, scale=0.5, seed=0, shear=0.0, show=False, show_boxes=True, show_conf=True, show_labels=True, simplify=True, single_cls=False, source=None, split=val, stream_buffer=False, task=detect, time=None, tracker=botsort.yaml, translate=0.1, val=True, verbose=True, vid_stride=1, visualize=False, warmup_bias_lr=0.1, warmup_epochs=3.0, warmup_momentum=0.8, weight_decay=0.0005, workers=8, workspace=None
engine\trainer: agnostic_nms=False, amp=True, augment=False, auto_augment=randaugment, batch=8, bgr=0.0, box=7.5, cache=False, cfg=None, classes=None, close_mosaic=10, cls=0.5, compile=False, conf=None, copy_paste=0.0, copy_paste_mode=flip, cos_lr=False, cutmix=0.0, data=./datasets/VehiclesDetectionDataset/dataset.yaml, degrees=0.0, deterministic=True, device=cpu, dfl=1.5, dnn=False, dropout=0.1, dynamic=False, embed=None, epochs=20, erasing=0.4, exist_ok=False, fliplr=0.5, flipud=0.0, format=torchscript, fraction=1.0, freeze=None, half=False, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, imgsz=416, int8=False, iou=0.7, keras=False, kobj=1.0, line_width=None, lr0=0.001, lrf=0.01, mask_ratio=4, max_det=300, mixup=0.0, mode=train, model=yolo11n.yaml, momentum=0.937, mosaic=1.0, multi_scale=False, name=train2, nbs=64, nms=False, opset=None, optimize=False, optimizer=auto, overlap_mask=True, patience=100, perspective=0.0, plots=True, pose=12.0, pretrained=.models/yolo11n.pt, profile=False, project=None, rect=False, resume=False, retina_masks=False, save=True, save_conf=False, save_crop=False, save_dir=C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\runs\detect\train2, save_frames=False, save_json=False, save_period=-1, save_txt=False, scale=0.5, seed=0, shear=0.0, show=False, show_boxes=True, show_conf=True, show_labels=True, simplify=True, single_cls=False, source=None, split=val, stream_buffer=False, task=detect, time=None, tracker=botsort.yaml, translate=0.1, val=True, verbose=True, vid_stride=1, visualize=False, warmup_bias_lr=0.1, warmup_epochs=3.0, warmup_momentum=0.8, weight_decay=0.0005, workers=8, workspace=None
Overriding model.yaml nc=80 with nc=5

                   from  n    params  module                                       arguments                     
  0                  -1  1       464  ultralytics.nn.modules.conv.Conv             [3, 16, 3, 2]                 
  1                  -1  1      4672  ultralytics.nn.modules.conv.Conv             [16, 32, 3, 2]                
  2                  -1  1      6640  ultralytics.nn.modules.block.C3k2            [32, 64, 1, False, 0.25]      
Overriding model.yaml nc=80 with nc=5

                   from  n    params  module                                       arguments                     
  0                  -1  1       464  ultralytics.nn.modules.conv.Conv             [3, 16, 3, 2]                 
  1                  -1  1      4672  ultralytics.nn.modules.conv.Conv             [16, 32, 3, 2]                
  2                  -1  1      6640  ultralytics.nn.modules.block.C3k2            [32, 64, 1, False, 0.25]      
  3                  -1  1     36992  ultralytics.nn.modules.conv.Conv             [64, 64, 3, 2]                
  4                  -1  1     26080  ultralytics.nn.modules.block.C3k2            [64, 128, 1, False, 0.25]     
  5                  -1  1    147712  ultralytics.nn.modules.conv.Conv             [128, 128, 3, 2]              
  3                  -1  1     36992  ultralytics.nn.modules.conv.Conv             [64, 64, 3, 2]                
  4                  -1  1     26080  ultralytics.nn.modules.block.C3k2            [64, 128, 1, False, 0.25]     
  5                  -1  1    147712  ultralytics.nn.modules.conv.Conv             [128, 128, 3, 2]              
  6                  -1  1     87040  ultralytics.nn.modules.block.C3k2            [128, 128, 1, True]           
  7                  -1  1    295424  ultralytics.nn.modules.conv.Conv             [128, 256, 3, 2]              
  6                  -1  1     87040  ultralytics.nn.modules.block.C3k2            [128, 128, 1, True]           
  7                  -1  1    295424  ultralytics.nn.modules.conv.Conv             [128, 256, 3, 2]              
  8                  -1  1    346112  ultralytics.nn.modules.block.C3k2            [256, 256, 1, True]           
  9                  -1  1    164608  ultralytics.nn.modules.block.SPPF            [256, 256, 5]                 
 10                  -1  1    249728  ultralytics.nn.modules.block.C2PSA           [256, 256, 1]                 
 11                  -1  1         0  torch.nn.modules.upsampling.Upsample         [None, 2, 'nearest']          
 12             [-1, 6]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
  8                  -1  1    346112  ultralytics.nn.modules.block.C3k2            [256, 256, 1, True]           
  9                  -1  1    164608  ultralytics.nn.modules.block.SPPF            [256, 256, 5]                 
 10                  -1  1    249728  ultralytics.nn.modules.block.C2PSA           [256, 256, 1]                 
 11                  -1  1         0  torch.nn.modules.upsampling.Upsample         [None, 2, 'nearest']          
 12             [-1, 6]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 13                  -1  1    111296  ultralytics.nn.modules.block.C3k2            [384, 128, 1, False]          
 14                  -1  1         0  torch.nn.modules.upsampling.Upsample         [None, 2, 'nearest']          
 15             [-1, 4]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 16                  -1  1     32096  ultralytics.nn.modules.block.C3k2            [256, 64, 1, False]           
 17                  -1  1     36992  ultralytics.nn.modules.conv.Conv             [64, 64, 3, 2]                
 13                  -1  1    111296  ultralytics.nn.modules.block.C3k2            [384, 128, 1, False]          
 14                  -1  1         0  torch.nn.modules.upsampling.Upsample         [None, 2, 'nearest']          
 15             [-1, 4]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 16                  -1  1     32096  ultralytics.nn.modules.block.C3k2            [256, 64, 1, False]           
 17                  -1  1     36992  ultralytics.nn.modules.conv.Conv             [64, 64, 3, 2]                
 18            [-1, 13]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 19                  -1  1     86720  ultralytics.nn.modules.block.C3k2            [192, 128, 1, False]          
 20                  -1  1    147712  ultralytics.nn.modules.conv.Conv             [128, 128, 3, 2]              
 18            [-1, 13]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 19                  -1  1     86720  ultralytics.nn.modules.block.C3k2            [192, 128, 1, False]          
 20                  -1  1    147712  ultralytics.nn.modules.conv.Conv             [128, 128, 3, 2]              
 21            [-1, 10]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 21            [-1, 10]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 22                  -1  1    378880  ultralytics.nn.modules.block.C3k2            [384, 256, 1, True]           
 22                  -1  1    378880  ultralytics.nn.modules.block.C3k2            [384, 256, 1, True]           
 23        [16, 19, 22]  1    431647  ultralytics.nn.modules.head.Detect           [5, [64, 128, 256]]           
 23        [16, 19, 22]  1    431647  ultralytics.nn.modules.head.Detect           [5, [64, 128, 256]]           
YOLO11n summary: 181 layers, 2,590,815 parameters, 2,590,799 gradients, 6.4 GFLOPs

YOLO11n summary: 181 layers, 2,590,815 parameters, 2,590,799 gradients, 6.4 GFLOPs

Transferred 448/499 items from pretrained weights
Freezing layer 'model.23.dfl.conv.weight'
Transferred 448/499 items from pretrained weights
Freezing layer 'model.23.dfl.conv.weight'
train: Fast image access  (ping: 0.10.0 ms, read: 176.276.0 MB/s, size: 29.7 KB)
train: Fast image access  (ping: 0.10.0 ms, read: 176.276.0 MB/s, size: 29.7 KB)
train: Scanning C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\labels.cache... 878 images, 0 backgrounds, 0 corrupt: 100% ━━━━━━━━━━━━ 878/878 856.2Kit/s 0.0s
train: Scanning C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\train\labels.cache... 878 images, 0 backgrounds, 0 corrupt: 100% ━━━━━━━━━━━━ 878/878 856.2Kit/s 0.0s
val: Fast image access  (ping: 0.10.0 ms, read: 163.476.6 MB/s, size: 33.0 KB)
val: Fast image access  (ping: 0.10.0 ms, read: 163.476.6 MB/s, size: 33.0 KB)
val: Scanning C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\valid\labels.cache... 250 images, 0 backgrounds, 0 corrupt: 100% ━━━━━━━━━━━━ 250/250  0.0s
val: Scanning C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\valid\labels.cache... 250 images, 0 backgrounds, 0 corrupt: 100% ━━━━━━━━━━━━ 250/250  0.0s
Plotting labels to C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\runs\detect\train2\labels.jpg... 
Plotting labels to C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\runs\detect\train2\labels.jpg... 
optimizer: 'optimizer=auto' found, ignoring 'lr0=0.001' and 'momentum=0.937' and determining best 'optimizer', 'lr0' and 'momentum' automatically... 
optimizer: AdamW(lr=0.001111, momentum=0.9) with parameter groups 81 weight(decay=0.0), 88 weight(decay=0.0005), 87 bias(decay=0.0)
Image sizes 416 train, 416 val
Using 0 dataloader workers
Logging results to C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\runs\detect\train2
Starting training for 20 epochs...
optimizer: 'optimizer=auto' found, ignoring 'lr0=0.001' and 'momentum=0.937' and determining best 'optimizer', 'lr0' and 'momentum' automatically... 
optimizer: AdamW(lr=0.001111, momentum=0.9) with parameter groups 81 weight(decay=0.0), 88 weight(decay=0.0005), 87 bias(decay=0.0)
Image sizes 416 train, 416 val
Using 0 dataloader workers
Logging results to C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\runs\detect\train2
Starting training for 20 epochs...

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
       1/20         0G       1.12      3.065      1.307         30        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:341.4ss
       1/20         0G       1.12      3.065      1.307         30        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:341.4s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.3s1.0s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.3s
                   all        250        454      0.346      0.264      0.289      0.216
                   all        250        454      0.346      0.264      0.289      0.216

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
       2/20         0G      1.277      2.494      1.397         25        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:331.2ss
       2/20         0G      1.277      2.494      1.397         25        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:331.2s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.7s1.1s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.7s
                   all        250        454      0.722      0.264      0.326      0.197
                   all        250        454      0.722      0.264      0.326      0.197

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
       3/20         0G      1.292      2.247      1.422         26        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:291.2ss
       3/20         0G      1.292      2.247      1.422         26        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:291.2s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.2s1.0s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.2s
                   all        250        454      0.426      0.449      0.401      0.269
                   all        250        454      0.426      0.449      0.401      0.269

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
       4/20         0G       1.26      2.102      1.387         19        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:291.2ss
       4/20         0G       1.26      2.102      1.387         19        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:291.2s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.7s1.0s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.7s
                   all        250        454      0.365      0.439      0.346      0.202
                   all        250        454      0.365      0.439      0.346      0.202

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
       5/20         0G       1.24      2.017      1.374         26        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:291.2ss
       5/20         0G       1.24      2.017      1.374         26        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:291.2s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.3s1.1s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.3s
                   all        250        454      0.367      0.478      0.428       0.29
                   all        250        454      0.367      0.478      0.428       0.29

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
       6/20         0G      1.204      1.918      1.353         27        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:311.3ss
       6/20         0G      1.204      1.918      1.353         27        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:311.3s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.3s1.0s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.3s
                   all        250        454      0.442      0.495      0.485      0.347
                   all        250        454      0.442      0.495      0.485      0.347

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
       7/20         0G      1.166      1.853      1.354         18        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:331.5ss
       7/20         0G      1.166      1.853      1.354         18        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:331.5s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.7s1.1s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.7s
                   all        250        454      0.644      0.386      0.432      0.282
                   all        250        454      0.644      0.386      0.432      0.282

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
       8/20         0G      1.167      1.772       1.32         10        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:291.3ss
       8/20         0G      1.167      1.772       1.32         10        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:291.3s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.6s1.1s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.6s
                   all        250        454      0.579      0.441      0.467      0.327
                   all        250        454      0.579      0.441      0.467      0.327

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
       9/20         0G       1.14      1.715       1.31         26        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:321.3ss
       9/20         0G       1.14      1.715       1.31         26        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:321.3s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.1s1.0s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.1s
                   all        250        454       0.42      0.554      0.492      0.339
                   all        250        454       0.42      0.554      0.492      0.339

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      10/20         0G      1.101      1.651      1.289         12        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:301.2ss
      10/20         0G      1.101      1.651      1.289         12        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:301.2s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.4s1.0s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.4s
                   all        250        454      0.577      0.468      0.489      0.354
                   all        250        454      0.577      0.468      0.489      0.354
Closing dataloader mosaic

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
Closing dataloader mosaic

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      11/20         0G      1.024      1.644      1.254          7        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:291.2ss
      11/20         0G      1.024      1.644      1.254          7        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:291.2s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.1s1.0s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.1s
                   all        250        454       0.61      0.504      0.526      0.377
                   all        250        454       0.61      0.504      0.526      0.377

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      12/20         0G     0.9721      1.462       1.22         10        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:281.2ss
      12/20         0G     0.9721      1.462       1.22         10        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:281.2s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 15.9s1.0s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 15.9s
                   all        250        454      0.613      0.519       0.55      0.419
                   all        250        454      0.613      0.519       0.55      0.419

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      13/20         0G     0.9647      1.367      1.196         11        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:271.2ss
      13/20         0G     0.9647      1.367      1.196         11        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:271.2s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.0s1.0s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.0s
                   all        250        454      0.598      0.506      0.562      0.408
                   all        250        454      0.598      0.506      0.562      0.408

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      14/20         0G     0.9181      1.319      1.164         14        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:271.2ss
      14/20         0G     0.9181      1.319      1.164         14        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:271.2s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.6s1.1s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.6s
                   all        250        454      0.569      0.541      0.548      0.404
                   all        250        454      0.569      0.541      0.548      0.404

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      15/20         0G     0.9091      1.199      1.148         14        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:271.2ss
      15/20         0G     0.9091      1.199      1.148         14        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:271.2s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.2s1.0s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.2s
                   all        250        454      0.724      0.556      0.605      0.449
                   all        250        454      0.724      0.556      0.605      0.449

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      16/20         0G     0.8825      1.155      1.146          6        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:271.2ss
      16/20         0G     0.8825      1.155      1.146          6        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:271.2s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.4s1.1s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.4s
                   all        250        454      0.657      0.539      0.606      0.446
                   all        250        454      0.657      0.539      0.606      0.446

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      17/20         0G     0.8109      1.035      1.113          7        416: 100% ━━━━━━━━━━━━ 110/110 0.8it/s 2:261.2ss
      17/20         0G     0.8109      1.035      1.113          7        416: 100% ━━━━━━━━━━━━ 110/110 0.8it/s 2:261.2s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.5s1.1s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.5s
                   all        250        454      0.616      0.602      0.591      0.436
                   all        250        454      0.616      0.602      0.591      0.436

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      18/20         0G     0.8038      1.003      1.094         17        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:281.3ss
      18/20         0G     0.8038      1.003      1.094         17        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:281.3s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.1s1.1s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.1s
                   all        250        454       0.68      0.537      0.628      0.477
                   all        250        454       0.68      0.537      0.628      0.477

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      19/20         0G     0.7861     0.9469      1.088          8        416: 100% ━━━━━━━━━━━━ 110/110 0.8it/s 2:271.2ss
      19/20         0G     0.7861     0.9469      1.088          8        416: 100% ━━━━━━━━━━━━ 110/110 0.8it/s 2:271.2s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.7s1.1s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.7s
                   all        250        454       0.62      0.584      0.615      0.457
                   all        250        454       0.62      0.584      0.615      0.457

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      20/20         0G     0.7711     0.9211      1.076         14        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:281.3ss
      20/20         0G     0.7711     0.9211      1.076         14        416: 100% ━━━━━━━━━━━━ 110/110 0.7it/s 2:281.3s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.3s1.0s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.0it/s 16.3s
                   all        250        454      0.702      0.534      0.611      0.461
                   all        250        454      0.702      0.534      0.611      0.461

20 epochs completed in 0.921 hours.

20 epochs completed in 0.921 hours.
Optimizer stripped from C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\runs\detect\train2\weights\last.pt, 5.4MB
Optimizer stripped from C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\runs\detect\train2\weights\last.pt, 5.4MB
Optimizer stripped from C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\runs\detect\train2\weights\best.pt, 5.4MB

Validating C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\runs\detect\train2\weights\best.pt...
Ultralytics 8.3.220  Python-3.12.3 torch-2.9.0+cpu CPU (AMD Ryzen 7 5700U with Radeon Graphics)
Optimizer stripped from C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\runs\detect\train2\weights\best.pt, 5.4MB

Validating C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\runs\detect\train2\weights\best.pt...
Ultralytics 8.3.220  Python-3.12.3 torch-2.9.0+cpu CPU (AMD Ryzen 7 5700U with Radeon Graphics)
YOLO11n summary (fused): 100 layers, 2,583,127 parameters, 0 gradients, 6.3 GFLOPs
YOLO11n summary (fused): 100 layers, 2,583,127 parameters, 0 gradients, 6.3 GFLOPs
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.1it/s 13.9s0.8s
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 16/16 1.1it/s 13.9s
                   all        250        454      0.684      0.537      0.628      0.477
             Ambulance         50         64      0.745      0.656      0.826      0.711
                   Bus         30         46      0.677      0.739       0.76      0.611
                   Car         90        238      0.708       0.49      0.548      0.378
            Motorcycle         42         46      0.667      0.565      0.577       0.37
                 Truck         38         60      0.625      0.233      0.427      0.316
Speed: 1.1ms preprocess, 45.7ms inference, 0.0ms loss, 1.4ms postprocess per image
Results saved to C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\runs\detect\train2
                   all        250        454      0.684      0.537      0.628      0.477
             Ambulance         50         64      0.745      0.656      0.826      0.711
                   Bus         30         46      0.677      0.739       0.76      0.611
                   Car         90        238      0.708       0.49      0.548      0.378
            Motorcycle         42         46      0.667      0.565      0.577       0.37
                 Truck         38         60      0.625      0.233      0.427      0.316
Speed: 1.1ms preprocess, 45.7ms inference, 0.0ms loss, 1.4ms postprocess per image
Results saved to C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\runs\detect\train2

Displaying the normalized confusion matrix to evaluate classification performance by class

InΒ [47]:
image_path = './runs/detect/train2/confusion_matrix_normalized.png'
display(IPythonImage(filename=image_path))
No description has been provided for this image

Analysis:

  • The normalized confusion matrix shows classification performance by class
  • Values on the diagonal indicate correct predictions (true positives)
  • Off-diagonal values reveal confusions between classes
  • Key points to look for:
    • Well-detected classes: high values on diagonal
    • Frequent confusions: high off-diagonal values
    • Problematic classes: low diagonal values

Visualizing the F1-Score curve to analyze the balance between precision and recall of the model

InΒ [50]:
image_path = './runs/detect/train2/BoxF1_curve.png'
display(IPythonImage(filename=image_path))
No description has been provided for this image
  • F1-Score combines precision and recall into a single metric
  • Curve showing F1-Score evolution as a function of confidence threshold
  • Interpretation:
    • Curve peak = optimal confidence threshold
    • High F1-Score (>0.8) = good precision/recall balance
    • Plateau = model robustness to threshold variations

Displaying loss and accuracy curves during training to analyze model convergence

InΒ [52]:
image_path = './runs/detect/train2/results.png'
display(IPythonImage(filename=image_path))
No description has been provided for this image
  • Graphs of losses and metrics during training
  • Important metrics:
    • Box Loss: loss for bounding box localization
    • Class Loss: loss for object classification
    • mAP@0.5: mean average precision at IoU=0.5
    • mAP@0.5:0.95: mean average precision across different IoU thresholds

Positive signals:

  • Decreasing and stable losses
  • Increasing mAP
  • No overfitting (similar train/val curves)

Validating performance of the best trained model on the test dataset

InΒ [53]:
best_model = YOLO('./runs/detect/train2/weights/best.pt')
metrics = best_model.val(split = 'test')
Ultralytics 8.3.220  Python-3.12.3 torch-2.9.0+cpu CPU (AMD Ryzen 7 5700U with Radeon Graphics)
YOLO11n summary (fused): 100 layers, 2,583,127 parameters, 0 gradients, 6.3 GFLOPs
YOLO11n summary (fused): 100 layers, 2,583,127 parameters, 0 gradients, 6.3 GFLOPs
val: Fast image access  (ping: 0.30.1 ms, read: 2.10.8 MB/s, size: 27.4 KB)
val: Fast image access  (ping: 0.30.1 ms, read: 2.10.8 MB/s, size: 27.4 KB)
val: Scanning C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\test\labels... 126 images, 0 backgrounds, 0 corrupt: 100% ━━━━━━━━━━━━ 126/126 222.3it/s 0.6s0.0s
val: New cache created: C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\test\labels.cache
val: Scanning C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\test\labels... 126 images, 0 backgrounds, 0 corrupt: 100% ━━━━━━━━━━━━ 126/126 222.3it/s 0.6s
val: New cache created: C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\datasets\VehiclesDetectionDataset\test\labels.cache
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 8/8 1.1it/s 7.1s0.9ss
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100% ━━━━━━━━━━━━ 8/8 1.1it/s 7.1s
                   all        126        258      0.665      0.668      0.681      0.522
             Ambulance         18         18      0.873          1      0.951      0.894
                   Bus         22         38      0.826      0.789      0.834      0.596
                   Car         60        150      0.706      0.613      0.664      0.447
            Motorcycle         12         32      0.388      0.438       0.44      0.263
                 Truck         14         20      0.534        0.5      0.517      0.411
Speed: 0.8ms preprocess, 46.0ms inference, 0.0ms loss, 1.2ms postprocess per image
Results saved to C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\runs\detect\val
                   all        126        258      0.665      0.668      0.681      0.522
             Ambulance         18         18      0.873          1      0.951      0.894
                   Bus         22         38      0.826      0.789      0.834      0.596
                   Car         60        150      0.706      0.613      0.664      0.447
            Motorcycle         12         32      0.388      0.438       0.44      0.263
                 Truck         14         20      0.534        0.5      0.517      0.411
Speed: 0.8ms preprocess, 46.0ms inference, 0.0ms loss, 1.2ms postprocess per image
Results saved to C:\Users\guill\OneDrive\Bureau\VSCode Project\Computer_vision\runs\detect\val
  • Final evaluation on data unseen during training
  • Key returned metrics:
    • Precision: proportion of correct detections
    • Recall: proportion of actual objects detected
    • mAP50: mean average precision at IoU=0.5
    • mAP50-95: mean average precision across all IoU thresholds

Typical benchmarks:

  • mAP50 > 0.7 = acceptable performance
  • mAP50 > 0.8 = good performance
  • mAP50 > 0.9 = excellent performance

Applying the trained model to test images for practical validation with detection visualization

InΒ [54]:
image_dir = './datasets/VehiclesDetectionDataset/test/images'
image_files = [os.path.join(image_dir, file) for file in os.listdir(image_dir) if file.endswith('.jpg')]
random_images = random.sample(image_files, k=10)
save_dir = './working/yolo_results'
os.makedirs(save_dir, exist_ok=True)
for image_path in random_images:
    image = PILImage.open(image_path).convert('RGB')
    image_np = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR)
    results = best_model.predict([image_np], save_dir=save_dir, imgsz=416, conf=0.5, iou=0.7)
    display(image)
    plot = results[0].plot()
    plot = cv2.cvtColor(plot, cv2.COLOR_BGR2RGB)
    display(PILImage.fromarray(plot))
0: 416x416 1 Ambulance, 152.1ms
Speed: 1.9ms preprocess, 152.1ms inference, 2.9ms postprocess per image at shape (1, 3, 416, 416)
0: 416x416 1 Ambulance, 152.1ms
Speed: 1.9ms preprocess, 152.1ms inference, 2.9ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
0: 416x416 1 Bus, 84.3ms
Speed: 2.1ms preprocess, 84.3ms inference, 4.1ms postprocess per image at shape (1, 3, 416, 416)
0: 416x416 1 Bus, 84.3ms
Speed: 2.1ms preprocess, 84.3ms inference, 4.1ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
0: 416x416 1 Motorcycle, 115.1ms
Speed: 1.5ms preprocess, 115.1ms inference, 0.9ms postprocess per image at shape (1, 3, 416, 416)
0: 416x416 1 Motorcycle, 115.1ms
Speed: 1.5ms preprocess, 115.1ms inference, 0.9ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
0: 416x416 1 Bus, 87.1ms
Speed: 1.6ms preprocess, 87.1ms inference, 1.4ms postprocess per image at shape (1, 3, 416, 416)
0: 416x416 1 Bus, 87.1ms
Speed: 1.6ms preprocess, 87.1ms inference, 1.4ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
0: 416x416 1 Car, 63.7ms
Speed: 2.8ms preprocess, 63.7ms inference, 1.0ms postprocess per image at shape (1, 3, 416, 416)
0: 416x416 1 Car, 63.7ms
Speed: 2.8ms preprocess, 63.7ms inference, 1.0ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
0: 416x416 2 Cars, 246.2ms
Speed: 2.1ms preprocess, 246.2ms inference, 5.6ms postprocess per image at shape (1, 3, 416, 416)
0: 416x416 2 Cars, 246.2ms
Speed: 2.1ms preprocess, 246.2ms inference, 5.6ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
0: 416x416 1 Bus, 1 Car, 125.0ms
Speed: 3.0ms preprocess, 125.0ms inference, 1.4ms postprocess per image at shape (1, 3, 416, 416)
0: 416x416 1 Bus, 1 Car, 125.0ms
Speed: 3.0ms preprocess, 125.0ms inference, 1.4ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
0: 416x416 1 Ambulance, 133.1ms
Speed: 10.8ms preprocess, 133.1ms inference, 2.5ms postprocess per image at shape (1, 3, 416, 416)
0: 416x416 1 Ambulance, 133.1ms
Speed: 10.8ms preprocess, 133.1ms inference, 2.5ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
0: 416x416 1 Bus, 198.4ms
Speed: 3.0ms preprocess, 198.4ms inference, 1.2ms postprocess per image at shape (1, 3, 416, 416)
0: 416x416 1 Bus, 198.4ms
Speed: 3.0ms preprocess, 198.4ms inference, 1.2ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image
0: 416x416 2 Cars, 94.9ms
Speed: 4.9ms preprocess, 94.9ms inference, 2.4ms postprocess per image at shape (1, 3, 416, 416)
0: 416x416 2 Cars, 94.9ms
Speed: 4.9ms preprocess, 94.9ms inference, 2.4ms postprocess per image at shape (1, 3, 416, 416)
No description has been provided for this image
No description has been provided for this image

ConclusionΒΆ

This project successfully demonstrates the implementation of a vehicle detection system using YOLOv11, one of the most advanced object detection architectures available. Through systematic data preparation, model training, and evaluation, we have achieved significant results in automated vehicle classification.

Key Achievements

  1. Dataset Preparation and Configuration
  • Successfully configured a YAML dataset structure for YOLOv11 training
  • Established proper data paths for 5 vehicle classes: Ambulance, Bus, Car, Motorcycle, and Truck
  • Verified dataset integrity and image characteristics
  1. Model Training and Optimization
  • Fine-tuned YOLOv11 nano model on vehicle-specific dataset
  • Implemented optimized hyperparameters (20 epochs, 416x416 image size, batch size 8)
  • Achieved stable training convergence with controlled overfitting
  1. Performance Evaluation
  • Analyzed model performance through multiple metrics (mAP@0.5, mAP@0.5:0.95, precision, recall)
  • Visualized classification accuracy via normalized confusion matrix
  • Demonstrated F1-Score optimization and threshold analysis
  1. Practical Validation
  • Successfully tested the trained model on unseen test images
  • Achieved real-time detection capabilities with confidence threshold of 0.5
  • Demonstrated robust vehicle detection across various lighting and angle conditions

Technical Insights

  • Model Architecture: YOLOv11 nano provides an excellent balance between speed and accuracy for vehicle detection
  • Training Efficiency: 20 epochs proved sufficient for convergence on this specific dataset
  • Hyperparameter Tuning: Learning rate of 0.001 and dropout of 0.1 prevented overfitting effectively
  • Image Processing: 416x416 resolution offers optimal performance for vehicle detection tasks

Real-World Applications

This trained model demonstrates practical value for:

  • Traffic Monitoring Systems: Automated vehicle counting and classification
  • Smart City Infrastructure: Real-time traffic flow analysis
  • Emergency Response: Priority detection for ambulances and emergency vehicles
  • Urban Planning: Data-driven insights for transportation optimization

Future Improvements

  1. Dataset Enhancement: Incorporate more diverse weather conditions and geographical locations
  2. Model Scaling: Experiment with larger YOLOv11 variants (small, medium, large) for higher accuracy
  3. Real-time Integration: Deploy model for live video stream processing
  4. Multi-modal Detection: Extend to detect pedestrians, cyclists, and traffic signs

Final Remarks

The project successfully demonstrates the power of modern deep learning architectures in computer vision applications. YOLOv11's efficiency in vehicle detection opens possibilities for numerous real-world implementations in smart transportation systems, making our roads safer and traffic management more intelligent.

The systematic approach from data preparation to model evaluation provides a solid foundation for future computer vision projects and demonstrates the practical applicability of state-of-the-art object detection technologies.