Electric vehicle detection method and device based on improved YOLOv8 model

By improving the YOLOv8 model, combining the occlusion loss function and edge detection, the network is used to counter-generate the network, the problem of low recognition accuracy of blocked electric vehicles is solved, the accuracy and adaptability of electric vehicle detection are improved, and the electric vehicle entry detection is ensured. reliability.

CN119068411APending Publication Date: 2024-12-03GUANGXI UNIV FOR NATITIES
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411060247.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-05
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

The existing electric vehicle access detection method has low recognition accuracy when identifying blocked electric vehicles, which cannot effectively reduce potential casualties caused by electric vehicle fires.

Method used

Using the improved YOLOv8 model, the accuracy and adaptability of electric vehicle detection are improved by obtaining the image set of occluded and unoccluded electric vehicle, the model is trained and the occlusion loss function is added. The combination of edge detection and adversarial generation network is combined to improve the accuracy and adaptability of electric vehicle detection.

Benefits of technology

It improves the identification accuracy and classification accuracy of electric vehicles in complex environments, reduces misjudgment, enhances the ability to distinguish between electric vehicles and non-electric vehicles, and ensures the reliability and accuracy of electric vehicle inspection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119068411A_ABST
    Figure CN119068411A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image detection, in particular to an electric vehicle detection method and device based on an improved YOLOv8 model. The method comprises the following steps: establishing an electric vehicle feature set by acquiring a shielded electric vehicle image set and an unshielded electric vehicle image set; using the electric vehicle feature set to train a YOLOv8 model and outputting the YOLOv8 model as an electric vehicle detection model; an electric vehicle detection model is used for detecting an image returned by the elevator room and outputting a first judgment result; if the first judgment result is a first detection result, inputting the first detection result into an electric vehicle image restoration model to output a restored image; detecting the repaired image by using the electric vehicle detection model and outputting a second judgment result; and detecting an elevator room image in each time period, outputting electric vehicle characteristics, outputting all judgment results according to the electric vehicle characteristics, and if the number of the second detection results exceeds a preset threshold value, outputting a final result as the second detection result. The electric vehicle detection method provided by the invention can effectively identify the shielded electric vehicle in the elevator room.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image detection technology, and in particular to an electric vehicle detection method and device based on an improved YOLOv8 model. Background Art

[0002] In recent years, fire accidents caused by electric vehicles have occurred frequently in the community, and this trend has shown an increasing trend year by year. The root cause of the fire is mainly electrical failure. Many residents use elevators to carry electric vehicles to residential buildings. Many electric vehicles are parked and charged indoors, and some electric vehicles are even parked in public areas such as corridors and stairwells, which increases the risk of fire.

[0003] Therefore, the problem of electric vehicles entering elevators urgently needs to be solved to reduce potential casualties caused by electric vehicle fires. For the prior art, there are the following electric vehicle entry detection methods, such as a monitoring and early warning method for electric vehicles entering an elevator disclosed in Chinese patent application number 202211553163.3, which proposes a YOLOX_Tiny detection model and a Darknet_Tiny classification model for detecting whether there are electric vehicles in the elevator; a method for detecting electric vehicles and electric vehicle batteries based on TensorRT accelerated reasoning disclosed in Chinese patent application number 202210262792.4 uses TensorRT accelerated reasoning to detect and identify electric bicycles, electric motorcycles or electric vehicle batteries entering the elevator; a method and device for identifying electric vehicle entry behavior based on YOLO-MobileNet disclosed in Chinese patent application number 202310683387.4 proposes using MobileNetv3 instead of CPSDarknet as the backbone network, and using a lighter-weight ULSAM attention module to replace the original SE attention module to generate a YOLO-MobileNet network; however, the above methods have the problem of low recognition accuracy when identifying electric vehicles obscured in the elevator.

[0004] To this end, an electric vehicle detection method and device based on an improved YOLOv8 model is proposed. Summary of the invention

[0005] The object of the present invention is to provide an electric vehicle detection method and device based on an improved YOLOv8 model.

[0006] To achieve the above object, the present invention provides the following technical solutions:

[0007] According to a first aspect of the present disclosure, a method for detecting an electric vehicle based on an improved YOLOv8 model is provided, comprising:

[0008] Acquire an obstructed electric vehicle image set in an elevator room and an unobstructed electric vehicle image set corresponding to the obstructed electric vehicle image set; establish an electric vehicle feature set according to the unobstructed electric vehicle image set;

[0009] Using the electric vehicle feature set to train the improved YOLOv8 model and outputting it as a trained electric vehicle detection model;

[0010] Furthermore, the specific steps of using the electric vehicle feature set to train the improved YOLOv8 model and outputting the trained electric vehicle detection model are as follows:

[0011] According to the electric vehicle feature set, each feature in the unobstructed electric vehicle image set is labeled to obtain a feature-labeled image; each feature is an electric vehicle feature in the electric vehicle feature set;

[0012] The feature-marked image is cropped to obtain a feature image set; the feature image set includes each feature image; wherein each feature image includes only one feature of the electric vehicle;

[0013] Using an edge detection model to detect the edges of the electric vehicle features in the feature image to obtain an edge feature image set;

[0014] The improved YOLOv8 model is trained using the edge feature image set and output as a trained electric vehicle detection model.

[0015] Furthermore, the loss function of the improved YOLOv8 model is as follows:

[0016] F = L1 + L2 + L3;

[0017] Among them, F is the occlusion loss function of the improved YOLOv8 model, L1 is the box loss function, L2 is the classification loss function, and L3 is the electric vehicle occlusion loss function;

[0018] The formula of the electric vehicle occlusion degree loss function is as follows:

[0019] L3 = αR1(1-R2);

[0020]

[0021] Among them, α is the occlusion coefficient whose value range is between 0 and 1, R1 is the target importance function, A is the area occupied by the occluder in the detection frame, B is the area occupied by the detection target in the detection frame, and R2 is the occlusion degree function.

[0022] Using the trained electric vehicle detection model to detect the image returned by the elevator camera in real time and output the detected electric vehicle features; wherein the image returned by the elevator camera in real time is an image returned once every 5 frames by the elevator monitoring video; judging whether there is an electric vehicle in the image returned by the elevator camera in real time according to the electric vehicle features and outputting a first judgment result;

[0023] The specific steps of judging whether there is an electric vehicle in the image returned by the elevator camera in real time according to the electric vehicle feature and outputting a first judgment result are as follows:

[0024] Classifying the obstructed electric vehicle images in the obstructed electric vehicle image set into three categories, namely, a first detection result, a second detection result, and a third detection result;

[0025] Collecting electric vehicle image sets and non-electric vehicle image sets commonly seen in elevators; the non-electric vehicle image sets include baby carriage image sets, bicycle image sets, and scooter image sets;

[0026] The electric vehicle feature set is divided into a first electric vehicle feature set and a second electric vehicle feature set; the first electric vehicle feature set includes features that distinguish electric vehicles from non-electric vehicles; the second electric vehicle feature set includes features that are common to electric vehicles and non-electric vehicles; wherein the second detection result contains the electric vehicle features in the first electric vehicle feature set and the second electric vehicle feature set; the first detection result only contains the electric vehicle features in the second electric vehicle feature set;

[0027] Annotating the electric vehicle features in the electric vehicle image set and the non-electric vehicle image set according to the first electric vehicle feature set and the second electric vehicle feature set to obtain an electric vehicle feature training set;

[0028] The electric vehicle feature set is used to train a random forest model and output a trained electric vehicle discrimination model; wherein the training step includes reducing different electric vehicle features to train the random forest model; the reducing different electric vehicle features are used to simulate the features of some electric vehicles that are blocked in the elevator room;

[0029] The electric vehicle features in the image returned in real time by the elevator camera are input into the trained electric vehicle discrimination model and a first judgment result is output; the first judgment result includes the first detection result, the second detection result and the third detection result.

[0030] If the first judgment result is the first detection result, the first detection result is input into the trained electric vehicle image restoration model and the restoration image is output; the restoration image is detected by using the trained electric vehicle detection model and the restored electric vehicle features are output; according to the restored electric vehicle features, it is determined whether there is an electric vehicle in the image returned by the elevator camera in real time and a second judgment result is output; the second judgment result includes the second detection result and the third detection result;

[0031] If the first judgment result is the first detection result, inputting the first detection result into the trained electric vehicle image restoration model and outputting the restoration image includes:

[0032] The occluded electric vehicle image set in the elevator room and the unoccluded electric vehicle image set corresponding to the occluded electric vehicle image set are used to train the adversarial generation network; wherein the occluded electric vehicle image set is obtained by occluding the features of electric vehicles at different parts of the unoccluded electric vehicle image set; the specific training steps are as follows:

[0033] Acquire a non-electric vehicle image set; the non-electric vehicle image set includes a baby carriage image set, a bicycle image set and a scooter image set; wherein the non-electric vehicle includes a baby carriage, a bicycle and a scooter;

[0034] Blocking different parts of non-electric vehicle features in the non-electric vehicle image set to obtain an occluded non-electric vehicle image set; detecting the edge of the occluder in the occluded non-electric vehicle image set, cropping and removing the occluder according to the edge to obtain the incomplete part of the non-electric vehicle that needs to be repaired and outputting it as a first repair image training set;

[0035] Detecting the edge of the occluded object in the occluded electric vehicle image set, cropping and removing the occluded object according to the edge to obtain the incomplete part of the electric vehicle that needs to be repaired and outputting it as a second repair image training set;

[0036] Inputting the first repaired image training set and the second repaired image training set into a generator and outputting a first repaired image set and a second repaired image set;

[0037] The first inpainted image set and the non-electric vehicle image set are input into the discriminator for discrimination and a first discrimination result is output; the second inpainted image set and the unobstructed electric vehicle image set are input into the discriminator for discrimination and a second discrimination result is output; if both the first discrimination result and the second discrimination result meet the preset conditions, the trained generative adversarial network is output as the electric vehicle image inpainting model;

[0038] The occluded part of the first detection result is cropped to obtain a defective part; the defective part is input into the electric vehicle image restoration model and output as a restored image.

[0039] The electric vehicle detection model is used to detect the elevator room image in each of n time periods and output the electric vehicle features, and all judgment results are output according to the electric vehicle features. If the number of the second detection results in all the judgment results exceeds a preset threshold, the final result is output as the second detection result and an early warning is issued; all the judgment results include the first judgment result and the second judgment result.

[0040] According to a second aspect of the present disclosure, an electric vehicle detection device based on an improved YOLOv8 model is provided, comprising:

[0041] Acquisition device: used for acquiring an obstructed electric vehicle image set in an elevator room and an unobstructed electric vehicle image set corresponding to the obstructed electric vehicle image set; establishing an electric vehicle feature set according to the unobstructed electric vehicle image set;

[0042] Training device: used to train the improved YOLOv8 model using the electric vehicle feature set and output a trained electric vehicle detection model;

[0043] The first detection device is used to use the trained electric vehicle detection model to detect the image returned by the elevator camera in real time and output the detected electric vehicle features; wherein the image returned by the elevator camera in real time is an image returned every 5 frames by the elevator monitoring video; according to the electric vehicle features, it is judged whether there is an electric vehicle in the image returned by the elevator camera in real time and a first judgment result is output;

[0044] The second detection device is used for inputting the first detection result into the trained electric vehicle image restoration model and outputting the restoration image if the first judgment result is the first detection result; using the trained electric vehicle detection model to detect the restoration image and output the restored electric vehicle features; judging whether there is an electric vehicle in the image returned by the elevator camera in real time according to the restored electric vehicle features and outputting the second judgment result; the second judgment result includes the second detection result and the third detection result;

[0045] Output device: used to use the electric vehicle detection model to detect the elevator room image in each of the n time periods and output the electric vehicle characteristics, output all the judgment results according to the electric vehicle characteristics, if the number of the second detection results in all the judgment results exceeds a preset threshold, then output the final result as the second detection result and issue an early warning; all the judgment results include the first judgment result and the second judgment result.

[0046] Compared with the prior art, the present invention has the following beneficial effects:

[0047] 1. An improved YOLOv8 model is provided. An occlusion loss function is added to the loss function of the model, so that the model can better handle the obscured electric vehicle features and non-electric vehicle features, improve the positioning accuracy of electric vehicles, enhance the adaptability to complex environments, and improve the accuracy of electric vehicle and non-electric vehicle classification, thereby improving the accuracy of electric vehicle detection and making the model perform better in actual scenarios.

[0048] 2. Use the features of different electric vehicles and non-electric vehicles to train the random forest model to obtain an electric vehicle discrimination model, so that the trained model can determine whether there is an electric vehicle in the image returned by the camera in the elevator through the electric vehicle features output by the electric vehicle detection model. By classifying the objects in the image through the features of electric vehicles and non-electric vehicles, it can avoid issuing false warnings due to incorrect detection of non-electric vehicles.

[0049] 3. Using occluded electric vehicle images and occluded non-electric vehicle images to train the GAN can enable the GAN model to better understand and adapt to the situation where electric vehicles or non-electric vehicles are occluded in the elevator, infer the true appearance of the occluded electric vehicle, and better repair the occluded electric vehicle images and non-electric vehicle images, so that the electric vehicle detection model can better identify the repaired electric vehicle images and non-electric vehicle images. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 A schematic diagram of a flow chart of an electric vehicle detection method based on an improved YOLOv8 model provided by the present invention;

[0051] Figure 2 The electric vehicle feature marking image provided by the present invention;

[0052] Figure 3 A schematic diagram of the structure of an electric vehicle detection device based on an improved YOLOv8 model provided by the present invention. DETAILED DESCRIPTION

[0053] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0054] See also Figures 1 to 3The present invention provides an electric vehicle detection method based on an improved YOLOv8 model, and the technical solution is as follows:

[0055] Figure 1 A flow chart of an electric vehicle detection method based on an improved YOLOv8 model provided in an embodiment of the present disclosure:

[0056] like Figure 1 As shown, an electric vehicle detection method based on an improved YOLOv8 model includes:

[0057] Acquire an obstructed electric vehicle image set in an elevator room and an unobstructed electric vehicle image set corresponding to the obstructed electric vehicle image set; establish an electric vehicle feature set according to the unobstructed electric vehicle image set;

[0058] Specifically, the obstructed electric vehicle image set in the elevator room is an image set composed of electric vehicle images with different parts of electric vehicle features obstructed in the elevator room; for example, the obstructed electric vehicle feature in one obstructed electric vehicle image is the rearview mirror, and the obstructed electric vehicle feature in another obstructed electric vehicle image is the handlebar. The unobstructed electric vehicle image set is an unobstructed electric vehicle image set in the elevator room corresponding to the obstructed electric vehicle image set. The electric vehicle feature set includes: rearview mirrors, handlebars, wheels, brakes, dashboards, seats, turn signals, and lights.

[0059] Using the electric vehicle feature set to train the improved YOLOv8 model and outputting it as a trained electric vehicle detection model;

[0060] Specifically, the specific steps of using the electric vehicle feature set to train the improved YOLOv8 model and outputting the trained electric vehicle detection model are as follows:

[0061] First, each feature in the unobstructed electric vehicle image set is labeled according to the electric vehicle feature set to obtain a feature-labeled image; each feature is an electric vehicle feature in the electric vehicle feature set; Figure 2 As shown, the feature-marked image is obtained by annotation.

[0062] The feature-marked image is cropped to obtain a feature image set; the feature image set includes each feature image; wherein each feature image includes only one feature of the electric vehicle;

[0063] Specifically, cropping the feature-marked image to obtain the feature image set is cropping the marked electric vehicle features according to the feature-marked image, that is, cropping each feature of the electric vehicle in the feature-marked image to obtain a feature image set consisting of all electric vehicle features;

[0064] Using an edge detection model to detect the edges of the electric vehicle features in the feature image to obtain an edge feature image set;

[0065] Specifically, the edge detection model is a Roberts operator, a Sobel operator or a Prewitt operator model; wherein, the edge detection model is used to detect the edges of the electric vehicle features of the feature image in the feature image set, and the edge feature image set obtained can eliminate the influence of the limited space and specific lighting conditions of the elevator room on the training of the YOLOv8 model to the greatest extent, thereby improving the efficiency, accuracy and adaptability of the model, so as to better meet the needs of electric vehicle detection in the elevator room.

[0066] The improved YOLOv8 model is trained using the edge feature image set and output as a trained electric vehicle detection model.

[0067] Specifically, the loss function of the improved YOLOv8 model is as follows:

[0068] F = L1 + L2 + L3;

[0069] Among them, F is the occlusion loss function of the improved YOLOv8 model, L1 is the box loss function, L2 is the classification loss function, and L3 is the electric vehicle occlusion loss function;

[0070] The specific loss function should be set according to the specific application scenario. In the embodiment of the present disclosure, the formula of the L1 box loss function is the VFL LOSS function, and the formula of the L2 classification loss function is the cross entropy loss function;

[0071] The formula of the electric vehicle occlusion degree loss function is as follows:

[0072] L3=αR1(1-R2)

[0073]

[0074] Among them, α is the occlusion coefficient, which ranges from 0 to 1, R1 is the target importance function, A is the area occupied by the occluder in the detection frame, B is the area occupied by the detection target in the detection frame, and R2 is the occlusion degree function.

[0075] In the disclosed embodiment, adding an electric vehicle occlusion degree loss function to the loss function of the improved YOLOv8 model can improve the model detection accuracy, enable the model to more accurately identify partially obscured electric vehicles, and help improve the generalization ability of the model, so that it can better adapt to different types and degrees of occlusion of electric vehicles, thereby improving the accuracy and reliability of the judgment results.

[0076] Using the trained electric vehicle detection model to detect the image returned by the elevator camera in real time and output the detected electric vehicle features; wherein the image returned by the elevator camera in real time is an image returned once every 5 frames by the elevator monitoring video; judging whether there is an electric vehicle in the image returned by the elevator camera in real time according to the electric vehicle features and outputting a first judgment result;

[0077] Specifically, the specific steps of judging whether there is an electric vehicle in the image returned in real time by the elevator camera according to the electric vehicle feature and outputting the first judgment result are as follows:

[0078] Classifying the obstructed electric vehicle images in the obstructed electric vehicle image set into three categories, namely, a first detection result, a second detection result, and a third detection result;

[0079] It should be specifically noted that the first detection result is that there may be electric vehicles in the image returned by the elevator camera in real time, the second detection result is that the image returned by the elevator camera in real time contains electric vehicles, and the third detection result is that there are no electric vehicles in the image returned by the elevator camera in real time.

[0080] Collecting electric vehicle image sets and non-electric vehicle image sets commonly seen in elevators; the non-electric vehicle image sets include baby carriage image sets, bicycle image sets, and scooter image sets;

[0081] The electric vehicle feature set is divided into a first electric vehicle feature set and a second electric vehicle feature set; the first electric vehicle feature set includes features that distinguish electric vehicles from non-electric vehicles; the second electric vehicle feature set includes features that are common to electric vehicles and non-electric vehicles; wherein the second detection result contains the electric vehicle features in the first electric vehicle feature set and the second electric vehicle feature set; the first detection result only contains the electric vehicle features in the second electric vehicle feature set;

[0082] Specifically, in the disclosed embodiment, the first electric vehicle feature set includes rearview mirrors, instrument panels, seats, turn signals, and lights; the second electric vehicle feature set includes handlebars, wheels, and brakes.

[0083] Annotating the electric vehicle features in the electric vehicle image set and the non-electric vehicle image set according to the first electric vehicle feature set and the second electric vehicle feature set to obtain an electric vehicle feature training set;

[0084] Specifically, the electric vehicle features in the electric vehicle image set and the non-electric vehicle image set are labeled according to the first electric vehicle feature set and the second electric vehicle feature set to obtain an electric vehicle feature training set, which is to label the electric vehicle features in the electric vehicle image set and the non-electric vehicle image set, namely, handlebars, wheels, brakes, rearview mirrors, dashboards, seats, turn signals and lights.

[0085] The electric vehicle feature set is used to train a random forest model and output a trained electric vehicle discrimination model; wherein the training step includes reducing different electric vehicle features to train the random forest model; the reducing different electric vehicle features are used to simulate the features of some electric vehicles that are blocked in the elevator room;

[0086] Specifically, the specific steps of using the electric vehicle feature set to train the random forest model and outputting the trained electric vehicle discrimination model include:

[0087] (1) obtaining a feature set of electric vehicles as a feature factor of input;

[0088] (ii) preprocessing the characteristic factors;

[0089] (iii) Select the number, number of nodes, and maximum depth of decision trees;

[0090] (iv) Using recall as a model evaluation function;

[0091] Specifically, the recall formula is as follows:

[0092]

[0093] Among them, λ1 indicates that the positive class is judged as the positive class, and λ2 indicates that the positive class is judged as the negative class; for example, the elevator image contains an electric car, but the random forest model judges the elevator image as the second detection result and the first detection result, then λ1 is judged as the positive class, and if it is judged as the third detection result, then λ2 is judged as the negative class, that is, there is no electric car in the elevator.

[0094] (5) outputting a result, wherein the outputted result is a first judgment result;

[0095] The electric vehicle features in the image returned in real time by the elevator camera are input into the trained electric vehicle discrimination model and a first judgment result is output; the first judgment result includes the first detection result, the second detection result and the third detection result.

[0096] In the disclosed embodiment, reducing different electric vehicle features to train the random forest model can simulate the obstructed electric vehicle images and non-electric vehicle images returned by the elevator, and dividing the electric vehicle features into a first electric vehicle feature set and a second electric vehicle feature set can distinguish the features of electric vehicles and non-electric vehicles, thereby better training the random forest model and making the model training speed and discrimination speed faster.

[0097] If the first judgment result is the first detection result, the first detection result is input into the trained electric vehicle image restoration model and the restoration image is output; the restoration image is detected by using the trained electric vehicle detection model and the restored electric vehicle features are output; the second judgment result is output according to the restored electric vehicle features; the second judgment result includes the second detection result and the third detection result;

[0098] Specifically, if the first judgment result is the first detection result, inputting the first detection result into the trained electric vehicle image restoration model to output the restoration image includes:

[0099] The occluded electric vehicle image set in the elevator room and the unoccluded electric vehicle image set corresponding to the occluded electric vehicle image set are used to train the adversarial generation network; wherein the occluded electric vehicle image set is obtained by occluding the features of electric vehicles at different parts of the unoccluded electric vehicle image set; the specific training steps are as follows:

[0100] Acquire a non-electric vehicle image set; the non-electric vehicle image set includes a baby carriage image set, a bicycle image set and a scooter image set; wherein the non-electric vehicle includes a baby carriage, a bicycle and a scooter;

[0101] Blocking different parts of non-electric vehicle features in the non-electric vehicle image set to obtain an occluded non-electric vehicle image set; detecting the edge of the occluder in the occluded non-electric vehicle image set, cropping and removing the occluder according to the edge to obtain the incomplete part of the non-electric vehicle that needs to be repaired and outputting it as a first repair image training set;

[0102] Specifically, the obstructions include people, pets, and cartons. The edge detection model is used to detect the edges of the obstructions in the obstructed non-electric vehicle image set. Specifically, the incomplete part of the non-electric vehicle is the part of the image that only contains the non-electric vehicle and does not include other parts. The incomplete part of the electric vehicle is the part of the image that only contains the electric vehicle and does not include other parts.

[0103] Detecting the edge of the occluded object in the occluded electric vehicle image set, cropping and removing the occluded object according to the edge to obtain the incomplete part of the electric vehicle that needs to be repaired and outputting it as a second repair image training set;

[0104] Inputting the first repaired image training set and the second repaired image training set into a generator and outputting a first repaired image set and a second repaired image set;

[0105] Specifically, the generative adversarial network includes a generator and a discriminator, the generator is used to restore the input incomplete image to obtain a repaired image, wherein, in the embodiment of the present disclosure, the incomplete image is a first repaired image training set and a second repaired image training set, and the discriminator is used to distinguish the repaired image from the unoccluded image.

[0106] The first inpainted image set and the non-electric vehicle image set are input into the discriminator for discrimination and a first discrimination result is output; the second inpainted image set and the unobstructed electric vehicle image set are input into the discriminator for discrimination and a second discrimination result is output; if both the first discrimination result and the second discrimination result meet the preset conditions, the trained generative adversarial network is output as the electric vehicle image inpainting model;

[0107] Specifically, in the embodiment of the present disclosure, the generator and the discriminator use L G Loss Function and L D The loss function is as follows:

[0108]

[0109]

[0110] Among them, x represents the real data sample, Represents the samples generated by the generator, z is the random noise vector, G is the generator function, and D is the discriminator function.

[0111] The occluded part of the first detection result is cropped to obtain a defective part; the defective part is input into the electric vehicle image restoration model and output as a restored image.

[0112] In the disclosed embodiment, using occluded electric vehicle images and occluded non-electric vehicle images to train the generative adversarial network can enable the generative adversarial network model to better understand and adapt to the situation where electric vehicles or non-electric vehicles are occluded in the elevator, thereby inferring the true appearance of the occluded electric vehicle by learning the mapping from the occluded electric vehicle image to the unobstructed electric vehicle image and from the occluded non-electric vehicle image to the unobstructed non-electric vehicle image, and better repairing the occluded electric vehicle image and non-electric vehicle image, so that the electric vehicle detection model can better identify the repaired electric vehicle image and non-electric vehicle image.

[0113] The electric vehicle detection model is used to detect the elevator room image in each of the n time periods and output the electric vehicle features. All judgment results are output according to the electric vehicle features. If the number of the second detection results in all the judgment results exceeds a preset threshold, the final result is output as the second detection result and an early warning is issued.

[0114] Specifically, each time period is one of n time periods, and the length of each time period is 5 frames; the n time periods are n time periods after the electric vehicle detection model detects for the first time and determines the second detection result; the preset threshold needs to be set according to the actual situation. For example, in the embodiment of the present disclosure, the preset threshold is set to 7, and the n time periods are 10 time periods.

[0115] In the disclosed embodiment, firstly, a set of obstructed electric vehicle images in the elevator room and a set of unobstructed electric vehicle images corresponding to the obstructed electric vehicle images are obtained; an electric vehicle feature set is established based on the unobstructed electric vehicle image set; obtaining the obstructed electric vehicle image set and the unobstructed electric vehicle image set can carry out targeted training on the YOLOv8 model and the random forest model, improve the training speed and accuracy of the model, and establish an electric vehicle feature set that can distinguish the features from non-electric vehicles, so that the discrimination effect of the random forest model is better. The improved YOLOv8 model is trained using the electric vehicle feature set and output as a trained electric vehicle detection model; the edge detection model is used to detect the edges of the electric vehicle features of the feature images in the feature image set, and the edge feature image set obtained can eliminate the influence of the limited space and specific lighting conditions of the elevator room on the training YOLOv8 model to the greatest extent, thereby improving the efficiency, accuracy and adaptability of the model, so as to better meet the needs of electric vehicle detection in the elevator room. The trained electric vehicle detection model is used to detect the image returned by the elevator camera in real time and output the detected electric vehicle features; wherein the image returned by the elevator camera in real time is an image returned every 5 frames by the elevator monitoring video; based on the electric vehicle features, it is judged whether there is an electric vehicle in the image returned by the elevator camera in real time and a first judgment result is output; reducing different electric vehicle features to train the random forest model can simulate the obscured electric vehicle images and non-electric vehicle images returned by the elevator, and dividing the electric vehicle features into a first electric vehicle feature set and a second electric vehicle feature set can distinguish the features of electric vehicles and non-electric vehicles, so that the random forest model can be better trained, making the model training speed and discrimination speed faster. If the first judgment result is the first detection result, the first detection result is input into the trained electric vehicle image restoration model and the restoration image is output; the trained electric vehicle detection model is used to detect the restoration image and output the restoration electric vehicle features; the second judgment result is output according to the restoration electric vehicle features; the second judgment result includes the second detection result and the third detection result; using the occluded electric vehicle image and the occluded non-electric vehicle image to train the generative adversarial network can enable the generative adversarial network model to better understand and adapt to the situation where the electric vehicle or non-electric vehicle is occluded in the elevator, thereby inferring the true appearance of the occluded electric vehicle by learning the mapping from the occluded electric vehicle image to the unobstructed electric vehicle image, and from the occluded non-electric vehicle image to the unobstructed non-electric vehicle image, so as to better restore the occluded electric vehicle image and the non-electric vehicle image, so that the electric vehicle detection model can better identify the restored electric vehicle image and the non-electric vehicle image.The electric vehicle detection model is used to detect the image returned by the elevator camera in real time in each of the n time periods and output the electric vehicle features, and all judgment results are output according to the electric vehicle features. If the number of the second detection results in all the judgment results exceeds the preset threshold, the final result is output as the second detection result and an early warning is issued. The setting of the predetermined time period, the predetermined number and the preset threshold can better adapt to the actual situation of different elevators and avoid misjudgment.

[0116] Figure 3 A schematic diagram of the structure of an electric vehicle detection device based on an improved YOLOv8 model provided in an embodiment of the present disclosure:

[0117] like Figure 3 As shown, an electric vehicle detection device based on an improved YOLOv8 model includes:

[0118] Acquisition device: used for acquiring an obstructed electric vehicle image set in an elevator room and an unobstructed electric vehicle image set corresponding to the obstructed electric vehicle image set; establishing an electric vehicle feature set according to the unobstructed electric vehicle image set;

[0119] Training device: used to train the improved YOLOv8 model using the electric vehicle feature set and output a trained electric vehicle detection model;

[0120] Specifically, the training device is used for:

[0121] According to the electric vehicle feature set, each feature in the unobstructed electric vehicle image set is labeled to obtain a feature-labeled image; each feature is an electric vehicle feature in the electric vehicle feature set;

[0122] The feature-marked image is cropped to obtain a feature image set; the feature image set includes each feature image; wherein each feature image includes only one feature of the electric vehicle;

[0123] Using an edge detection model to detect the edges of the electric vehicle features in the feature image to obtain an edge feature image set;

[0124] The improved YOLOv8 model is trained using the edge feature image set and output as a trained electric vehicle detection model.

[0125] In the disclosed embodiment, the training device uses an edge detection model to detect the edges of the electric vehicle features of the feature images in the feature image set, and the edge feature image set obtained can eliminate the impact of the limited space and specific lighting conditions in the elevator room on the training YOLOv8 model to the greatest extent, thereby improving the efficiency, accuracy and adaptability of the model, thereby better meeting the needs of electric vehicle detection in the elevator room.

[0126] Specifically, the loss function of the improved YOLOv8 model in the training device is as follows:

[0127] F=L1+L2+L3

[0128] Among them, F is the occlusion loss function of the improved YOLOv8 model, L1 is the box loss function, L2 is the classification loss function, and L3 is the electric vehicle occlusion loss function;

[0129] The formula of the electric vehicle occlusion degree loss function is as follows:

[0130] L3=αR1(1-R2)

[0131]

[0132] Among them, α is the occlusion coefficient, which ranges from 0 to 1, R1 is the target importance function, A is the area occupied by the occluder in the detection frame, B is the area occupied by the detection target in the detection frame, and R2 is the occlusion degree function.

[0133] In the disclosed embodiment, the training device adds an electric vehicle occlusion degree loss function to the loss function of the improved YOLOv8 model to improve the model detection accuracy, enable the model to more accurately identify partially obscured electric vehicles, and help improve the generalization ability of the model, so that it can better adapt to different types and degrees of occlusion of electric vehicles, thereby improving the accuracy and reliability of the judgment results.

[0134] The first detection device is used to use the trained electric vehicle detection model to detect the image returned by the elevator camera in real time and output the detected electric vehicle features; wherein the image returned by the elevator camera in real time is an image returned every 5 frames by the elevator monitoring video; according to the electric vehicle features, it is judged whether there is an electric vehicle in the image returned by the elevator camera in real time and a first judgment result is output;

[0135] Specifically, the first detection device is specifically used for:

[0136] Classifying the obstructed electric vehicle images in the obstructed electric vehicle image set into three categories, namely, a first detection result, a second detection result, and a third detection result;

[0137] Collecting electric vehicle image sets and non-electric vehicle image sets commonly seen in elevators; the non-electric vehicle image sets include baby carriage image sets, bicycle image sets, and scooter image sets;

[0138] The electric vehicle feature set is divided into a first electric vehicle feature set and a second electric vehicle feature set; the first electric vehicle feature set includes features that distinguish electric vehicles from non-electric vehicles; the second electric vehicle feature set includes features that are common to electric vehicles and non-electric vehicles; wherein the second detection result contains the electric vehicle features in the first electric vehicle feature set and the second electric vehicle feature set; the first detection result only contains the electric vehicle features in the second electric vehicle feature set;

[0139] Annotating the electric vehicle features in the electric vehicle image set and the non-electric vehicle image set according to the first electric vehicle feature set and the second electric vehicle feature set to obtain an electric vehicle feature training set;

[0140] The electric vehicle feature set is used to train a random forest model and output a trained electric vehicle discrimination model; wherein the training step includes reducing different electric vehicle features to train the random forest model; the reducing different electric vehicle features are used to simulate the features of some electric vehicles that are blocked in the elevator room;

[0141] The electric vehicle features in the image returned in real time by the elevator camera are input into the trained electric vehicle discrimination model and a first judgment result is output; the first judgment result includes the first detection result, the second detection result and the third detection result.

[0142] In the disclosed embodiment, the first detection device can simulate the obscured electric vehicle images and non-electric vehicle images returned by the elevator by reducing different electric vehicle features to train the random forest model. The electric vehicle features are divided into a first electric vehicle feature set and a second electric vehicle feature set to distinguish the features of electric vehicles and non-electric vehicles, thereby better training the random forest model and making the model training speed and discrimination speed faster.

[0143] The second detection device is used for inputting the first detection result into the trained electric vehicle image restoration model and outputting the restoration image if the first judgment result is the first detection result; using the trained electric vehicle detection model to detect the restoration image and output the restored electric vehicle features; judging whether there is an electric vehicle in the image returned by the elevator camera in real time according to the restored electric vehicle features and outputting the second judgment result; the second judgment result includes the second detection result and the third detection result;

[0144] Specifically, the second detection device is specifically used for:

[0145] The occluded electric vehicle image set in the elevator room and the unoccluded electric vehicle image set corresponding to the occluded electric vehicle image set are used to train the adversarial generation network; wherein the occluded electric vehicle image set is obtained by occluding the features of electric vehicles at different parts of the unoccluded electric vehicle image set; the specific training steps are as follows:

[0146] Acquire a non-electric vehicle image set; the non-electric vehicle image set includes a baby carriage image set, a bicycle image set and a scooter image set; wherein the non-electric vehicle includes a baby carriage, a bicycle and a scooter;

[0147] Blocking different parts of non-electric vehicle features in the non-electric vehicle image set to obtain an occluded non-electric vehicle image set; detecting the edge of the occluder in the occluded non-electric vehicle image set, cropping and removing the occluder according to the edge to obtain the incomplete part of the non-electric vehicle that needs to be repaired and outputting it as a first repair image training set;

[0148] Detecting the edge of the occluded object in the occluded electric vehicle image set, cropping and removing the occluded object according to the edge to obtain the incomplete part of the electric vehicle that needs to be repaired and outputting it as a second repair image training set;

[0149] Inputting the first repaired image training set and the second repaired image training set into a generator and outputting a first repaired image set and a second repaired image set;

[0150] The first inpainted image set and the non-electric vehicle image set are input into the discriminator for discrimination and a first discrimination result is output; the second inpainted image set and the unobstructed electric vehicle image set are input into the discriminator for discrimination and a second discrimination result is output; if both the first discrimination result and the second discrimination result meet the preset conditions, the trained generative adversarial network is output as the electric vehicle image inpainting model;

[0151] The occluded part of the first detection result is cropped to obtain a defective part; the defective part is input into the electric vehicle image restoration model and output as a restored image.

[0152] In the embodiment of the present disclosure, the second detection device uses the occluded electric vehicle images and the occluded non-electric vehicle images to train the generative adversarial network, so that the generative adversarial network model can better understand and adapt to the situation where the electric vehicle or non-electric vehicle is occluded in the elevator, thereby inferring the true appearance of the occluded electric vehicle by learning the mapping from the occluded electric vehicle image to the unobstructed electric vehicle image and the mapping from the occluded non-electric vehicle image to the unobstructed non-electric vehicle image, and better repairing the occluded electric vehicle image and non-electric vehicle image, so that the electric vehicle detection model can better identify the repaired electric vehicle image and non-electric vehicle image.

[0153] Output device: used to use the electric vehicle detection model to detect the elevator room image in each of the n time periods and output the electric vehicle characteristics, output all the judgment results according to the electric vehicle characteristics, if the number of the second detection results in all the judgment results exceeds a preset threshold, then output the final result as the second detection result and issue an early warning; all the judgment results include the first judgment result and the second judgment result.

[0154] In the disclosed embodiment, the acquisition device first acquires the obstructed electric vehicle image set in the elevator room and the unobstructed electric vehicle image set corresponding to the obstructed electric vehicle image set; establishes an electric vehicle feature set based on the unobstructed electric vehicle image set; acquiring the obstructed electric vehicle image set and the unobstructed electric vehicle image set can carry out targeted training on the YOLOv8 model and the random forest model, improve the training speed and accuracy of the model, and establish the electric vehicle feature set to distinguish the features from those of non-electric vehicles, so that the discrimination effect of the random forest model is better. The training device uses the electric vehicle feature set to train the improved YOLOv8 model and output it as a trained electric vehicle detection model; using the edge detection model to detect the edges of the electric vehicle features of the feature images in the feature image set, the edge feature image set obtained can eliminate the influence of the limited space and specific lighting conditions of the elevator room on the training YOLOv8 model to the greatest extent, thereby improving the efficiency, accuracy and adaptability of the model, so as to better meet the needs of electric vehicle detection in the elevator room. The first detection model uses the trained electric vehicle detection model to detect the image returned by the elevator camera in real time and outputs the detected electric vehicle features; wherein the image returned by the elevator camera in real time is an image returned every 5 frames by the elevator monitoring video; based on the electric vehicle features, it is judged whether there is an electric vehicle in the image returned by the elevator camera in real time and a first judgment result is output; reducing different electric vehicle features to train the random forest model can simulate the obstructed electric vehicle images and non-electric vehicle images returned by the elevator, and dividing the electric vehicle features into a first electric vehicle feature set and a second electric vehicle feature set can distinguish the features of electric vehicles and non-electric vehicles, so that the random forest model can be better trained, making the model training speed and discrimination speed faster. The second detection model is used to input the first detection result into the trained electric vehicle image restoration model and output the restoration image if the first judgment result is the first detection result; use the trained electric vehicle detection model to detect the restoration image and output the restoration electric vehicle features; output the second judgment result according to the restoration electric vehicle features; the second judgment result includes the second detection result and the third detection result; using the occluded electric vehicle image and the occluded non-electric vehicle image to train the adversarial generative network can enable the adversarial generative network model to better understand and adapt to the situation where the electric vehicle or non-electric vehicle is occluded in the elevator, thereby inferring the true appearance of the occluded electric vehicle by learning the mapping from the occluded electric vehicle image to the unobstructed electric vehicle image, and from the occluded non-electric vehicle image to the unobstructed non-electric vehicle image, and better repairing the occluded electric vehicle image and the non-electric vehicle image, so that the electric vehicle detection model can better identify the repaired electric vehicle image and the non-electric vehicle image.The output device is used to use the electric vehicle detection model to detect the image returned by the elevator camera in real time in each of the n time periods and output the electric vehicle characteristics, and output all the judgment results according to the electric vehicle characteristics. If the number of the second detection results in all the judgment results exceeds the preset threshold, the final result is output as the second detection result and an early warning is issued. The setting of the predetermined time period, the predetermined number and the preset threshold can better adapt to the actual situation of different elevators and avoid misjudgment.

[0155] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. An electric vehicle detection method based on an improved YOLOv8 model, characterized in that: include: Acquire an obstructed electric vehicle image set in an elevator room and an unobstructed electric vehicle image set corresponding to the obstructed electric vehicle image set; Establishing an electric vehicle feature set according to the unobstructed electric vehicle image set; Using the electric vehicle feature set to train the improved YOLOv8 model and outputting it as a trained electric vehicle detection model; Using the trained electric vehicle detection model to detect the image returned by the elevator camera in real time and output the detected electric vehicle features; wherein the image returned by the elevator camera in real time is an image returned once every 5 frames by the elevator monitoring video; judging whether there is an electric vehicle in the image returned by the elevator camera in real time according to the electric vehicle features and outputting a first judgment result; If the first judgment result is the first detection result, the first detection result is input into the trained electric vehicle image restoration model and the restoration image is output; the restoration image is detected by using the trained electric vehicle detection model and the restored electric vehicle features are output; according to the restored electric vehicle features, it is determined whether there is an electric vehicle in the image returned by the elevator camera in real time and a second judgment result is output; the second judgment result includes the second detection result and the third detection result; The electric vehicle detection model is used to detect the image returned by the elevator camera in real time in each of the n time periods and output the electric vehicle characteristics, and all judgment results are output according to the electric vehicle characteristics. If the number of the second detection results in all the judgment results exceeds a preset threshold, the final result is output as the second detection result and an early warning is issued; all the judgment results include the first judgment result and the second judgment result.

2. According to claim 1, an electric vehicle detection method based on an improved YOLOv8 model is characterized in that: The method of using the electric vehicle feature set to train the improved YOLOv8 model and outputting the trained electric vehicle detection model specifically includes: According to the electric vehicle feature set, each feature in the unobstructed electric vehicle image set is labeled to obtain a feature-labeled image; each feature is an electric vehicle feature in the electric vehicle feature set; The feature-marked image is cropped to obtain a feature image set; the feature image set includes each feature image; wherein each feature image includes only one feature of the electric vehicle; Using an edge detection model to detect the edges of the electric vehicle features in the feature image to obtain an edge feature image set; The improved YOLOv8 model is trained using the edge feature image set and output as a trained electric vehicle detection model.

3. The electric vehicle detection method based on the improved YOLOv8 model according to claim 1 is characterized in that: The loss function of the improved YOLOv8 model is as follows: F = L1 + L2 + L3; Among them, F is the occlusion loss function of the improved YOLOv8 model, L1 is the box loss function, L2 is the classification loss function, and L3 is the electric vehicle occlusion loss function; The formula of the electric vehicle occlusion degree loss function is as follows: L3 = αR1(1-R2); Among them, α is the occlusion coefficient whose value range is between 0 and 1, R1 is the target importance function, A is the area occupied by the occluder in the detection frame, B is the area occupied by the detection target in the detection frame, and R2 is the occlusion degree function.

4. The electric vehicle detection method based on the improved YOLOv8 model according to claim 1 is characterized in that: The specific steps of judging whether there is an electric vehicle in the image returned by the elevator camera in real time according to the electric vehicle characteristics and outputting the judgment result are as follows: Classifying the obstructed electric vehicle images in the obstructed electric vehicle image set into three categories, namely, a first detection result, a second detection result, and a third detection result; Collecting electric vehicle image sets and non-electric vehicle image sets commonly seen in elevators; the non-electric vehicle image sets include baby carriage image sets, bicycle image sets, and scooter image sets; The electric vehicle feature set is divided into a first electric vehicle feature set and a second electric vehicle feature set; the first electric vehicle feature set includes features that distinguish electric vehicles from non-electric vehicles; the second electric vehicle feature set includes features that are common to electric vehicles and non-electric vehicles; wherein the second detection result contains the electric vehicle features in the first electric vehicle feature set and the second electric vehicle feature set; the first detection result only contains the electric vehicle features in the second electric vehicle feature set; Annotating the electric vehicle features in the electric vehicle image set and the non-electric vehicle image set according to the first electric vehicle feature set and the second electric vehicle feature set to obtain an electric vehicle feature training set; The electric vehicle feature set is used to train a random forest model and output a trained electric vehicle discrimination model; wherein the training step includes reducing different electric vehicle features to train the random forest model; the reducing different electric vehicle features are used to simulate the features of some electric vehicles that are blocked in the elevator room; The electric vehicle features in the image returned in real time by the elevator camera are input into the trained electric vehicle discrimination model and a first judgment result is output; the first judgment result includes the first detection result, the second detection result and the third detection result.

5. The electric vehicle detection method based on the improved YOLOv8 model according to claim 1 is characterized in that: If the first judgment result is the first detection result, inputting the first detection result into the trained electric vehicle image restoration model and outputting the restoration image comprises: The occluded electric vehicle image set in the elevator room and the unoccluded electric vehicle image set corresponding to the occluded electric vehicle image set are used to train the adversarial generation network; wherein the occluded electric vehicle image set is obtained by occluding the features of electric vehicles at different parts of the unoccluded electric vehicle image set; the specific training steps are as follows: Acquire a non-electric vehicle image set; the non-electric vehicle image set includes a baby carriage image set, a bicycle image set and a scooter image set; wherein the non-electric vehicle includes a baby carriage, a bicycle and a scooter; Blocking different parts of non-electric vehicle features in the non-electric vehicle image set to obtain an occluded non-electric vehicle image set; detecting the edge of the occluder in the occluded non-electric vehicle image set, cropping and removing the occluder according to the edge to obtain the incomplete part of the non-electric vehicle that needs to be repaired and outputting it as a first repair image training set; Detecting the edge of the occluded object in the occluded electric vehicle image set, cropping and removing the occluded object according to the edge to obtain the incomplete part of the electric vehicle that needs to be repaired and outputting it as a second repair image training set; Inputting the first repaired image training set and the second repaired image training set into a generator and outputting a first repaired image set and a second repaired image set; The first inpainted image set and the non-electric vehicle image set are input into the discriminator for discrimination and a first discrimination result is output; the second inpainted image set and the unobstructed electric vehicle image set are input into the discriminator for discrimination and a second discrimination result is output; if both the first discrimination result and the second discrimination result meet the preset conditions, the trained generative adversarial network is output as the electric vehicle image inpainting model; The occluded part of the first detection result is cropped to obtain a defective part; the defective part is input into the electric vehicle image restoration model and output as a restored image.

6. An electric vehicle detection device based on an improved YOLOv8 model, characterized in that: include: Acquisition device: used for acquiring an obstructed electric vehicle image set in the elevator room and an unobstructed electric vehicle image set corresponding to the obstructed electric vehicle image set; Establishing an electric vehicle feature set according to the unobstructed electric vehicle image set; Training device: used to train the improved YOLOv8 model using the electric vehicle feature set and output a trained electric vehicle detection model; The first detection device is used to use the trained electric vehicle detection model to detect the image returned by the elevator camera in real time and output the detected electric vehicle features; wherein the image returned by the elevator camera in real time is an image returned every 5 frames by the elevator monitoring video; according to the electric vehicle features, it is judged whether there is an electric vehicle in the image returned by the elevator camera in real time and a first judgment result is output; The second detection device is used for inputting the first detection result into the trained electric vehicle image restoration model and outputting the restoration image if the first judgment result is the first detection result; using the trained electric vehicle detection model to detect the restoration image and output the restored electric vehicle features; judging whether there is an electric vehicle in the image returned by the elevator camera in real time according to the restored electric vehicle features and outputting the second judgment result; the second judgment result includes the second detection result and the third detection result; Output device: used to use the electric vehicle detection model to detect the elevator room image in each of the n time periods and output the electric vehicle characteristics, output all the judgment results according to the electric vehicle characteristics, if the number of the second detection results in all the judgment results exceeds a preset threshold, then output the final result as the second detection result and issue an early warning; all the judgment results include the first judgment result and the second judgment result.

7. An electric vehicle detection device based on an improved YOLOv8 model according to claim 6, characterized in that: The training device is specifically used for: According to the electric vehicle feature set, each feature in the unobstructed electric vehicle image set is labeled to obtain a feature-labeled image; each feature is an electric vehicle feature in the electric vehicle feature set; The feature-marked image is cropped to obtain a feature image set; the feature image set includes each feature image; wherein each feature image includes only one feature of the electric vehicle; Using an edge detection model to detect the edges of the electric vehicle features in the feature image to obtain an edge feature image set; The improved YOLOv8 model is trained using the edge feature image set and output as a trained electric vehicle detection model.

8. The electric vehicle detection device based on the improved YOLOv8 model according to claim 7 is characterized in that: The loss function of the improved YOLOv8 model in the training device is as follows: F = L1 + L2 + L3; Among them, F is the occlusion loss function of the improved YOLOv8 model, L1 is the box loss function, L2 is the classification loss function, and L3 is the electric vehicle occlusion loss function; The formula of the electric vehicle occlusion degree loss function is as follows: L3 = αR1(1-R2); Among them, α is the occlusion coefficient whose value range is between 0 and 1, R1 is the target importance function, A is the area occupied by the occluder in the detection frame, B is the area occupied by the detection target in the detection frame, and R2 is the occlusion degree function.

9. The electric vehicle detection device based on the improved YOLOv8 model according to claim 6, characterized in that: The first detection device is specifically used for: Classifying the obstructed electric vehicle images in the obstructed electric vehicle image set into three categories, namely, a first detection result, a second detection result, and a third detection result; Collecting electric vehicle image sets and non-electric vehicle image sets commonly seen in elevators; the non-electric vehicle image sets include baby carriage image sets, bicycle image sets, and scooter image sets; The electric vehicle feature set is divided into a first electric vehicle feature set and a second electric vehicle feature set; the first electric vehicle feature set includes features that distinguish electric vehicles from non-electric vehicles; the second electric vehicle feature set includes features that are common to electric vehicles and non-electric vehicles; wherein the second detection result contains the electric vehicle features in the first electric vehicle feature set and the second electric vehicle feature set; the first detection result only contains the electric vehicle features in the second electric vehicle feature set; Annotating the electric vehicle features in the electric vehicle image set and the non-electric vehicle image set according to the first electric vehicle feature set and the second electric vehicle feature set to obtain an electric vehicle feature training set; The electric vehicle feature set is used to train a random forest model and output a trained electric vehicle discrimination model; wherein the training step includes reducing different electric vehicle features to train the random forest model; the reducing different electric vehicle features are used to simulate the features of some electric vehicles that are blocked in the elevator room; The electric vehicle features in the image returned in real time by the elevator camera are input into the trained electric vehicle discrimination model and a first judgment result is output; the first judgment result includes the first detection result, the second detection result and the third detection result.

10. The electric vehicle detection device based on the improved YOLOv8 model according to claim 6, characterized in that: The second detection device is specifically used for: The occluded electric vehicle image set in the elevator room and the unoccluded electric vehicle image set corresponding to the occluded electric vehicle image set are used to train the adversarial generation network; wherein the occluded electric vehicle image set is obtained by occluding the features of electric vehicles at different parts of the unoccluded electric vehicle image set; the specific training steps are as follows: Acquire a non-electric vehicle image set; the non-electric vehicle image set includes a baby carriage image set, a bicycle image set and a scooter image set; wherein the non-electric vehicle includes a baby carriage, a bicycle and a scooter; Blocking different parts of non-electric vehicle features in the non-electric vehicle image set to obtain an occluded non-electric vehicle image set; detecting the edge of the occluder in the occluded non-electric vehicle image set, cropping and removing the occluder according to the edge to obtain the incomplete part of the non-electric vehicle that needs to be repaired and outputting it as a first repair image training set; Detecting the edge of the occluded object in the occluded electric vehicle image set, cropping and removing the occluded object according to the edge to obtain the incomplete part of the electric vehicle that needs to be repaired and outputting it as a second repair image training set; Inputting the first repaired image training set and the second repaired image training set into a generator and outputting a first repaired image set and a second repaired image set; The first inpainted image set and the non-electric vehicle image set are input into the discriminator for discrimination and a first discrimination result is output; the second inpainted image set and the unobstructed electric vehicle image set are input into the discriminator for discrimination and a second discrimination result is output; if both the first discrimination result and the second discrimination result meet the preset conditions, the trained generative adversarial network is output as the electric vehicle image inpainting model; The occluded part of the first detection result is cropped to obtain a defective part; the defective part is input into the electric vehicle image restoration model and output as a restored image.