Pedestrian motorcycle detection method and system based on yolov8 and storage medium
By using the YOLOv8 model for pedestrian and motorcycle detection, the problems of high computational resource and data requirements in existing technologies are solved, achieving high detection accuracy and low complexity, and simplifying the model debugging process.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- JINLING INST OF TECH
- Filing Date
- 2023-07-06
- Publication Date
- 2026-05-19
AI Technical Summary
Existing pedestrian and motorcycle detection technologies suffer from problems such as high computational resource requirements, large data requirements, high model complexity, complex preprocessing operations, and difficulty in debugging. In particular, detection schemes based on deep learning methods suffer from reduced detection accuracy when the quality and quantity of the dataset are insufficient.
The YOLOv8 model is used for pedestrian and motorcycle detection. Through dataset preparation, model building, image preprocessing, training and deployment, combined with TensorFlow or PyTorch framework, CSPlayer_2Conv structure, Anchor-Free label allocation and Distribution Focal Loss are used for image enhancement and data augmentation, reducing preprocessing operations and simplifying the model structure and debugging process.
It achieves high detection accuracy under conditions of low computing resources and datasets, reduces model complexity and data requirements, simplifies the debugging process, and improves the convenience and accuracy of detection.
Smart Images

Figure CN117612113B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a pedestrian and motorcycle detection method, system, and storage medium based on YOLOv8. Background Technology
[0002] Currently, computer vision technology has been widely applied in various fields, among which pedestrian and motorcycle detection is an important research direction. With the continuous increase in the number of motorcycles and pedestrians, how to accurately detect pedestrians and motorcycles has become a crucial issue.
[0003] Existing pedestrian and motorcycle detection technologies mainly fall into two categories: those based on traditional image processing methods and those based on deep learning methods. Traditional image processing-based methods typically utilize fundamental computer vision knowledge, such as image processing, feature extraction, and classification, to detect pedestrians and motorcycles. The main advantage of this method is its simplicity and ease of use, requiring minimal computational resources and datasets. However, it is relatively slow and has relatively low accuracy. Deep learning-based methods, on the other hand, use deep learning models, such as convolutional neural networks (CNNs), to detect pedestrians and motorcycles. The main advantages of this method are its fast detection speed and high accuracy. However, it requires substantial data and computational resources, and different datasets can affect the detection results.
[0004] Currently, to improve detection accuracy, most pedestrian and motorcycle detection solutions employ deep learning-based methods, such as YOLOv5 or Faster R-CNN. YOLOv5 is a deep learning model based on region extraction and matching, suitable for object detection tasks. Faster R-CNN, on the other hand, is a deep learning model based on region extraction and classification, also suitable for object detection tasks. When using these models for pedestrian and motorcycle detection, training and optimization are necessary to improve accuracy and speed. Preprocessing of the input images, such as enhancing image contrast and resizing, is also required to improve detection performance. However, these solutions still have some problems and drawbacks, mainly including the following:
[0005] 1. Requires a large amount of data and computing resources: Deep learning models require a large amount of data and computing resources to train and optimize them; otherwise, the accuracy and robustness of the model will be reduced.
[0006] 2. Impact of dataset quality and quantity: The performance of deep learning models largely depends on the quality, quantity, and diversity of the training data. Insufficient or low-quality datasets can lead to reduced detection accuracy.
[0007] 3. Requires extensive preprocessing: Deep learning models typically require preprocessing operations such as image enhancement, cropping, and resizing to improve detection performance. However, these preprocessing operations also increase the algorithm's complexity and computational resource requirements.
[0008] 4. High model complexity: Deep learning models typically contain multiple layers of convolutional neural networks, resulting in very complex model structures and parameters, requiring a large amount of computing resources and time for training.
[0009] 5. Requires professional training and debugging: Deep learning models require professional training and debugging; otherwise, the model's detection performance will be unsatisfactory. Furthermore, the debugging process for deep learning models is quite complex and requires a significant investment of time and effort.
[0010] Therefore, this application proposes a solution to these existing problems. Summary of the Invention
[0011] Purpose of the invention: The purpose of this invention is to provide a pedestrian and motorcycle detection method, system, and storage medium based on YOLOv8, which has the advantages of high detection accuracy, low computational resource and data requirements, fewer preprocessing operations, lower model complexity, and convenient debugging and training.
[0012] Technical solution: The pedestrian and motorcycle detection method based on YOLOv8 described in this invention includes the following steps:
[0013] S1: Dataset preparation, the dataset contains images of pedestrians and motorcycles from different angles, under different lighting conditions and in different poses;
[0014] S2: Build a YOLOv8 model. When building a YOLOv8 model, use a deep learning framework such as TensorFlow or PyTorch, and select appropriate model hyperparameters according to the size of the dataset and hardware configuration.
[0015] S3: Image preprocessing, which includes image enhancement, cropping and resizing. Image enhancement includes random horizontal flipping, random color enhancement, random perspective transformation and motion blur enhancement. Cropping and resizing are random cropping and scaling.
[0016] S4: Train the YOLOv8 model. When training the YOLOv8 model, split the dataset into a training set and a validation set to avoid model overfitting.
[0017] S5: Use the test set to test the detection accuracy of the YOLOv8 model. By inputting the images in the test set into the YOLOv8 model, calculate the detection accuracy, recall, and F1 score of the YOLOv8 model detection results.
[0018] S6: Deploy the trained YOLOv8 model to a real-world application. During deployment, upload the model file to the server or local computer, configure the model's hyperparameters, and then upload the image to be detected to the server or local computer. The trained YOLOv8 model can then be used for pedestrian and motorcycle detection.
[0019] Preferably, in the YOLOv8 model:
[0020] The backbone replaces the C3 structure of YOLOv5 with the CSPlayer_2Conv structure, which has a richer gradient flow. Different channel numbers are adjusted for models of different scales. At the same time, models with different scaling factors N / S / M / L / X no longer share a set of model parameters. For large M / L / X models, the number of output channels in the last stage is reduced, further reducing the number of parameters and computation.
[0021] The Neck part replaces the C3 module and RepBlock with CSPlayer_2Conv, removes the 1×1 convolution before upsampling, and directly feeds the features output from different stages of the Backbone into the upsampling operation.
[0022] The Head section decouples the head module, which is coupled together with the localization module in YOLOv5, and separates the classification branch and the localization branch.
[0023] The label assignment and loss functions were changed from Anchor-Based to Anchor-Free, and TaskAlignment Learning was used for dynamic matching. The loss function was introduced by combining Distribution Focal Loss with CIoU Loss as the regression branch.
[0024] The Train section introduces the operation of disabling Mosiac augmentation in the last 10 epochs of YOLOX during the data augmentation part of training.
[0025] Preferably, the random horizontal flip in S3 is to horizontally flip the given image with probability p, that is, to flip the image left and right, which increases the diversity of training data and prevents the model from overfitting. Specifically, PyTorch provides an API interface: transforms.RandomHorizontalFlip(p=0.5).
[0026] Preferably, the random color enhancement in S3 is implemented by using the API: transform.ColorJitter() to randomly change the brightness, contrast, saturation and hue of the image, and by using the API: transforms.RandomPosterize() to randomly reduce the color depth of the image.
[0027] Preferably, in the API `transform.ColorJitter()`, `ColorJitter()` is part of the `transforms` object creation process and includes the following parameters:
[0028] brightness: A parameter used to randomly adjust the brightness. The default value is 0, which means that the brightness is not randomly adjusted. If set to 0.1, the brightness will vary randomly within the range of [1-0.1, 1+0.1].
[0029] contrast: A parameter used to randomly adjust the contrast. The default value is 0, which means that the contrast is not randomly adjusted. If set to 0.1, the contrast will vary randomly within the range of [1-0.1, 1+0.1].
[0030] saturation: A parameter used to randomly adjust saturation. The default value is 0, which means that saturation is not randomly adjusted. If set to 0.1, the saturation will vary randomly within the range of [1-0.1, 1+0.1].
[0031] hue: A parameter used to randomly adjust the hue. The default value is 0, which means that the hue is not randomly adjusted. If set to 0.1, the hue will change randomly in the range of [-0.1, 0.1].
[0032] Preferably, the API `transforms.RandomPosterize()` performs the following operation: randomly selects a bit depth between 0 and 8, and reduces the bit depth of all color channels to that value. The formula for this operation is:
[0033] Out = Quantize(Posterize(ln))
[0034] Where ln represents the input image, Posterize represents the Posterize operation, and Quantize is a function that maps real values to integer values, expressed by the formula:
[0035] Quantize(x) = □Δx□□Δ
[0036] Where Δ is a scale value, representing the discrete interval of continuous real values. In transforms.RandomPosterize(), the formula for calculating Δ is:
[0037] Δ = 2^bits / 255
[0038] Where bits is a randomly selected number of bits.
[0039] Preferably, the random perspective transformation in S3 is implemented through the API: RandomPerspective(), which includes the following parameters:
[0040] distortion_scale: A factor that controls the degree of distortion. The default value is 0.5, which means the degree of distortion is between 0 and 0.5.
[0041] p: The probability of applying this operation, with a default value of 0.5;
[0042] Specifically, the following steps are included:
[0043] S3.11: Randomly select 4 control points;
[0044] S3.12: Randomly adjust the positions of 4 control points to increase image distortion and warping;
[0045] S3.13: Calculate the perspective transformation matrix, including geometric transformations such as rotation, scaling, and shearing;
[0046] S3.14: Perform a perspective transformation on the image and scale it back to its original size.
[0047] Preferably, the motion blur enhancement in S3 is implemented using the motion_blur function, which includes three parameters and a probability p. The three parameters are: the original image (image), the blur degree (degree), and the motion direction (angle). Specifically, it includes the following steps:
[0048] S3.21: Use the getRotationMatrix2D() function in the OpenCV library to generate a rotation matrix that rotates a matrix with a diagonal of 1 by a specified angle;
[0049] S3.22: Then, the warpAffine function is used to perform an affine transformation on the matrix with 1s on the diagonal to obtain a kernel matrix at an arbitrary angle, which is the motion blur matrix. The larger the degree, the more obvious the blur.
[0050] S3.23: Divide the resulting kernel matrix by the degree to ensure that the value of each element in the matrix is between [0,1].
[0051] S3.24: Use the filter2D() function to perform motion blur on the input image, and then normalize the blurred image so that the pixel values are in the range of [0,255].
[0052] Beneficial effects:
[0053] (1) This invention uses the YOLOv8 model for pedestrian and motorcycle detection. Compared with other deep learning models, this model has lower computational resources and data requirements, and can achieve higher detection accuracy with lower hardware configuration and smaller dataset.
[0054] (2) This invention uses the YOLOv8 model for pedestrian and motorcycle detection. This model can adaptively learn features at different scales through hierarchical feature extraction and self-attention mechanism. It is not affected by the quality and quantity of the dataset and can achieve high detection accuracy.
[0055] (3) This invention uses the YOLOv8 model for pedestrian and motorcycle detection. This model does not require complex image enhancement, cropping, resizing and other preprocessing operations, which can reduce the complexity of the algorithm and the demand for computing resources.
[0056] (4) This invention uses the YOLOv8 model for pedestrian and motorcycle detection. Compared with other deep learning models, this model has lower model complexity and can achieve higher detection accuracy with smaller computing resources and datasets.
[0057] (5) This invention uses the YOLOv8 model for pedestrian and motorcycle detection. This model can achieve high detection accuracy through simple debugging and training. At the same time, this invention also provides some convenient debugging tools and training strategies to facilitate model debugging and training. Attached Figure Description
[0058] Figure 1 This is a flowchart of the method in this application;
[0059] Figure 2 This is a diagram of the thematic network structure in this application;
[0060] Figure 3 This is a structural diagram of the ConvModule in this application;
[0061] Figure 4 This is the structure diagram of CSPrayer_2Conv in this application. Detailed Implementation
[0062] The present application will be further described below with reference to specific embodiments.
[0063] This application includes the following steps:
[0064] S1: Dataset preparation. The dataset contains images of pedestrians and motorcycles at different angles, under different lighting conditions, and in different poses.
[0065] S2: Build a YOLOv8 model. When building a YOLOv8 model, use a deep learning framework such as TensorFlow or PyTorch, and select appropriate model hyperparameters based on the size of the dataset and hardware configuration.
[0066] In the YOLOv8 model:
[0067] The backbone replaces the C3 structure of YOLOv5 with the CSPrayer_2Conv structure, which has richer gradient flow. This allows YOLOv8 to obtain richer gradient flow information while maintaining lightweight design. More skip connections and additional split operations can better capture low-level features, mitigating the feature loss problem to some extent. Furthermore, different channel numbers are adjusted for models of different scales. Models with different scaling factors N / S / M / L / X no longer share a set of model parameters. For large M / L / X models, the number of output channels in the last stage is reduced, further reducing the number of parameters and computation.
[0068] The Neck section replaces the C3 module and RepBlock with CSPlayer_2Conv, removes the 1×1 convolution before upsampling, and directly feeds the features output from different stages of the Backbone into the upsampling operation.
[0069] The Head section decouples the head module that is coupled together with classification and localization in YOLOv5, separating the classification branch and the localization branch. This alleviates the inherent conflict between classification and regression tasks and brings a significant improvement in both accuracy and convergence speed.
[0070] The label assignment and loss functions were changed from Anchor-Based to Anchor-Free, and TaskAlignment Learning was used for dynamic matching. The Distribution Focal Loss combined with CIoU Loss was introduced as the loss function for the regression branch, which resulted in high consistency between the classification and regression tasks.
[0071] The Train section introduces the operation of disabling Mosiac augmentation in the last 10 epochs of YOLOX during the data augmentation part of training.
[0072] S3: Image preprocessing, which includes image enhancement, cropping and resizing. Image enhancement includes random horizontal flipping, random color enhancement, random perspective transformation and motion blur enhancement. Cropping and resizing are random cropping and scaling.
[0073] Random horizontal flipping refers to flipping a given image horizontally with probability p, which increases the diversity of training data and prevents model overfitting. Specifically, PyTorch provides an API interface: transforms.RandomHorizontalFlip(p=0.5).
[0074] Random color enhancement is implemented through the API: transform.ColorJitter(), which randomly changes the brightness, contrast, saturation, and hue of an image. In the API: transform.ColorJitter(), ColorJitter() is part of the transformations object and includes the following parameters:
[0075] brightness: A parameter used to randomly adjust the brightness. The default value is 0, which means that the brightness is not randomly adjusted. If set to 0.1, the brightness will vary randomly within the range of [1-0.1, 1+0.1].
[0076] contrast: A parameter used to randomly adjust the contrast. The default value is 0, which means that the contrast is not randomly adjusted. If set to 0.1, the contrast will vary randomly within the range of [1-0.1, 1+0.1].
[0077] saturation: A parameter used to randomly adjust saturation. The default value is 0, which means that saturation is not randomly adjusted. If set to 0.1, the saturation will vary randomly within the range of [1-0.1, 1+0.1].
[0078] hue: A parameter used to randomly adjust the hue. The default value is 0, which means that the hue is not randomly adjusted. If set to 0.1, the hue will change randomly in the range of [-0.1, 0.1].
[0079] Random color enhancement, achieved through the API `transforms.RandomPosterize()`, randomly reduces the color depth of an image. Color depth refers to the number of bits used to represent the color of each pixel. More bits result in a wider color range and richer color detail. Reducing the color depth to a lower level limits the representation of each pixel's color, thus reducing color detail. Specifically, `transforms.RandomPosterize()` randomly selects a bit between 0 and 8 and reduces the number of bits in all color channels to that value. The formula for this operation is:
[0080] Out = Quantize(Posterize(ln))
[0081] Where ln represents the input image, Posterize represents the Posterize operation, and Quantize is a function that maps real values to integer values, expressed by the formula:
[0082] Quantize(x) = □Δx□□Δ
[0083] Where Δ is a scale value, representing the discrete interval of continuous real values. In transforms.RandomPosterize(), the formula for calculating Δ is:
[0084] Δ = 2^bits / 255
[0085] Here, `bits` represents the randomly selected number of bits. This formula means dividing the color space into 2^`bits equally spaced sub-intervals, each sub-interval being 1 / 255 in size. This operation can enhance the robustness of the model to some extent because it reduces color detail, allowing the model to focus more on the structural information of the image. However, excessively reducing color depth may lead to image distortion; therefore, an appropriate number of bits needs to be selected based on the specific task.
[0086] In random perspective transformation, a quadrilateral shape on a plane is transformed into another quadrilateral shape through perspective projection. Perspective transformation requires defining a 3x3 transformation matrix, also known as the perspective matrix or projection matrix. Specifically, for a planar image, any affine transformation can be represented as a matrix product as follows:
[0087]
[0088] Where x and y represent the pixel coordinates in the image, x′ and y′ represent the transformed pixel coordinates, and t x and t y a represents the offset of the translation transformation. 11 a 12 a 21 and a 22 These represent the coefficients for geometric transformations such as rotation, scaling, and shearing. Random perspective transformation is achieved by randomly adjusting the coefficients in this affine transformation matrix, specifically through the following steps:
[0089] S3.11: Randomly select 4 control points;
[0090] S3.12: Randomly adjust the positions of 4 control points to increase image distortion and warping;
[0091] S3.13: Calculate the perspective transformation matrix, including geometric transformations such as rotation, scaling, and shearing;
[0092] S3.14: Perform a perspective transformation on the image and scale it back to its original size.
[0093] In this embodiment, the random perspective transformation is implemented through the API: RandomPerspective(), which includes the following parameters:
[0094] distortion_scale: A factor that controls the degree of distortion. The default value is 0.5, which means the degree of distortion is between 0 and 0.5.
[0095] p: The probability of applying this operation, with a default value of 0.5.
[0096] Motion blur enhancement is achieved using the `motion_blur` function, which includes three parameters and a probability `p`: the original image (`image`), the blur degree (`degree`), and the motion direction (`angle`). The specific steps include:
[0097] S3.21: Use the getRotationMatrix2D() function in the OpenCV library to generate a rotation matrix that rotates a matrix with a diagonal of 1 by a specified angle;
[0098] S3.22: Then, the warpAffine function is used to perform an affine transformation on the matrix with 1s on the diagonal to obtain a kernel matrix with arbitrary angles, which is the motion blur matrix. The larger the degree, the more obvious the blur.
[0099] S3.23: Divide the resulting kernel matrix by the degree to ensure that the value of each element in the matrix is between [0,1].
[0100] S3.24: Use the filter2D() function to perform motion blur on the input image, and then normalize the blurred image so that the pixel values are in the range of [0,255].
[0101] S4: Train the YOLOv8 model. When training the YOLOv8 model, split the dataset into training and validation sets to avoid overfitting.
[0102] S5: Use the test set to test the detection accuracy of the YOLOv8 model. By inputting the images in the test set into the YOLOv8 model, calculate the detection accuracy, recall, and F1 score of the YOLOv8 model.
[0103] S6: Deploy the trained YOLOv8 model to a real-world application. During deployment, upload the model file to the server or local computer, configure the model's hyperparameters, and then upload the image to be detected to the server or local computer. The trained YOLOv8 model can then be used for pedestrian and motorcycle detection.
[0104] This embodiment also provides a pedestrian and motorcycle detection method system based on YOLOv8, including a network interface, a memory, and a processor. The network interface is used to receive and send signals during the process of sending and receiving information with other external network elements. The memory is used to store computer program instructions that can be run on the processor. The processor is used to execute the steps of the pedestrian and motorcycle detection method based on YOLOv8 when running the computer program instructions.
[0105] This embodiment also provides a computer storage medium storing a computer program that, when executed by a processor, implements the methods described above. The computer-readable medium can be considered tangible and non-transitory. Non-limiting examples of non-transitory tangible computer-readable media include non-volatile memory circuitry (e.g., flash memory circuitry, erasable programmable read-only memory circuitry, or masked read-only memory circuitry), volatile memory circuitry (e.g., static random access memory circuitry or dynamic random access memory circuitry), magnetic storage media (e.g., analog or digital magnetic tape or hard disk drive), and optical storage media (e.g., CD, DVD, or Blu-ray disc). The computer program includes processor-executable instructions stored on at least one non-transitory tangible computer-readable medium. The computer program may also include or depend on stored data. The computer program may include a basic input / output system (BIOS) for interacting with the hardware of a dedicated computer, device drivers for interacting with specific devices of the dedicated computer, one or more operating systems, user applications, background services, background applications, etc.
[0106] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0107] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
Claims
1. A pedestrian and motorcycle detection method based on YOLOv8, characterized in that: It includes the following steps: S1: Dataset preparation, the dataset contains images of pedestrians and motorcycles from different angles, under different lighting conditions and in different poses; S2: Build a YOLOv8 model. When building a YOLOv8 model, use a deep learning framework such as TensorFlow or PyTorch, and select appropriate model hyperparameters according to the size of the dataset and hardware configuration. In the YOLOv8 model: The backbone replaces the C3 structure of YOLOv5 with the CSPlayer_2Conv structure, which has richer gradient flow. Different channel numbers are adjusted for models of different scales. At the same time, models with different scaling factors N / S / M / L / X no longer share a set of model parameters. For large M / L / X models, the number of output channels in the last stage is reduced, further reducing the number of parameters and computation. The Neck section replaces the C3 module and RepBlock with CSPlayer_2Conv, removes the 1×1 convolution before upsampling, and directly feeds the features output from different stages of the Backbone into the upsampling operation. The Head section decouples the head module that is coupled together with classification and localization in YOLOv5, separating the classification branch and the localization branch. The label assignment and loss functions were changed from Anchor-Based to Anchor-Free, and Task Alignment Learning dynamic matching was adopted. The loss function that combines Distribution Focal Loss with CIoU Loss as the regression branch was introduced. The Train section incorporates the operation of disabling Mosiac augmentation in the last 10 epochs of YOLOX during the data augmentation phase of training. S3: Image preprocessing, which includes image enhancement, cropping and resizing. Image enhancement includes random horizontal flipping, random color enhancement, random perspective transformation and motion blur enhancement. Cropping and resizing are random cropping and scaling. S4: Train the YOLOv8 model. When training the YOLOv8 model, split the dataset into a training set and a validation set to avoid overfitting. S5: Use the test set to test the detection accuracy of the YOLOv8 model. By inputting the images in the test set into the YOLOv8 model, calculate the detection accuracy, recall, and F1 score of the YOLOv8 model detection results. S6: Deploy the trained YOLOv8 model to a real-world application. During deployment, upload the model file to the server or local computer, configure the model's hyperparameters, and then upload the image to be detected to the server or local computer. The trained YOLOv8 model can then be used for pedestrian and motorcycle detection.
2. The pedestrian and motorcycle detection method based on YOLOv8 according to claim 1, characterized in that: In S3, random horizontal flipping refers to horizontally flipping the given image with probability ρ, which means flipping the image left and right to increase the diversity of training data and prevent model overfitting. Specifically, PyTorch provides an API interface: transforms.RandomHorizontalFlip(p=0.5).
3. The pedestrian and motorcycle detection method based on YOLOv8 according to claim 1, characterized in that: The random color enhancement in S3 is implemented through the API: transform.ColorJitter(), which randomly changes the brightness, contrast, saturation, and hue of the image, and through the API: transforms.RandomPosterize(), which randomly reduces the color depth of the image.
4. The pedestrian and motorcycle detection method based on YOLOv8 according to claim 3, characterized in that: In the API `transform.ColorJitter()`, `ColorJitter()` is part of the `transforms` object creation process and includes the following parameters: brightness: A parameter used to randomly adjust the brightness. The default value is 0, which means that the brightness is not randomly adjusted. If set to 0.1, the brightness will vary randomly within the range of [1-0.1, 1+0.1]. contrast: A parameter used to randomly adjust the contrast. The default value is 0, which means that the contrast is not randomly adjusted. If set to 0.1, the contrast will vary randomly within the range of [1-0.1, 1+0.1]. saturation: A parameter used to randomly adjust saturation. The default value is 0, which means that saturation is not randomly adjusted. If set to 0.1, the saturation will vary randomly within the range of [1-0.1, 1+0.1]. hue: A parameter used to randomly adjust the hue. The default value is 0, which means that the hue is not randomly adjusted. If set to 0.1, the hue will change randomly in the range of [-0.1, 0.1].
5. The pedestrian and motorcycle detection method based on YOLOv8 according to claim 3, characterized in that: The API `transforms.RandomPosterize()` performs the following operation: it randomly selects a bit depth between 0 and 8 and reduces the bit depth of all color channels to that value. The formula for this operation is: in Indicates the input image. express operate, It is a function that maps real values to integer values, expressed by the formula: in It is a scale value that represents the discrete interval of continuous real values, in transforms.RandomPosterize(). The calculation formula is: Where bits is a randomly selected number of bits.
6. The pedestrian and motorcycle detection method based on YOLOv8 according to claim 1, characterized in that: The random perspective transformation in S3 is implemented through the API: RandomPerspective(), which includes the following parameters: distortion_scale: A factor that controls the degree of distortion. The default value is 0.5, indicating that the degree of distortion is between 0 and 0.
5. p: The probability of applying the random perspective transformation operation, with a default value of 0.5; Specifically, the following steps are included: S3.11: Randomly select 4 control points; S3.12: Randomly adjust the positions of 4 control points to increase image distortion and warping; S3.13: Calculate the perspective transformation matrix, including geometric transformations such as rotation, scaling, and shearing; S3.14: Perform a perspective transformation on the image and scale it back to its original size.
7. The pedestrian and motorcycle detection method based on YOLOv8 according to claim 1, characterized in that: The motion blur enhancement in S3 is achieved through the motion_blur function, which includes three parameters and a probability p. The three parameters are: the original image (image), the blur degree (degree), and the motion direction (angle). Specifically, it includes the following steps: S3.21: Use the getRotationMatrix2D() function in the OpenCV library to generate a rotation matrix that rotates a matrix with a diagonal of 1 by a specified angle; S3.22: Then, the warpAffine function is used to perform an affine transformation on the matrix with 1s on the diagonal to obtain a kernel matrix at an arbitrary angle, which is the motion blur matrix. The larger the degree, the more obvious the blur. S3.23: Divide the resulting kernel matrix by the degree to ensure that the value of each element in the matrix is between [0,1]. S3.24: Use the filter2D() function to perform motion blur on the input image, and then normalize the blurred image so that the pixel values are in the range of [0,255].
8. A pedestrian and motorcycle detection system based on YOLOv8, characterized in that: The system includes a network interface, memory, and a processor, wherein: The network interface is used to receive and send signals during the process of sending and receiving information with other external network elements; The memory is used to store computer program instructions that can run on the processor; The processor is configured to execute the steps of the pedestrian and motorcycle detection method based on YOLOv8 as described in any one of claims 1-7 when running the computer program instructions.
9. A computer storage medium, characterized in that: The computer storage medium stores a pedestrian and motorcycle detection method based on YOLOv8, which, when executed by at least one processor, implements the steps of the pedestrian and motorcycle detection method based on YOLOv8 as described in any one of claims 1-7.