A method, device, electronic device and storage medium for relaxation degree recognition
By employing a supervised contrastive learning method for relaxation recognition model on wearable devices, and utilizing pulse wave signals for feature extraction and analysis, the problems of low relaxation recognition accuracy and device limitations in existing technologies are solved, enabling high-precision relaxation monitoring and personalized relaxation feedback on portable devices.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGZHOU SHIYUAN ELECTRONICS CO LTD
- Filing Date
- 2023-09-27
- Publication Date
- 2026-05-19
AI Technical Summary
Existing wearable devices have low algorithm accuracy when monitoring changes in human physiological parameters to identify relaxation levels, resulting in a poor user experience. In addition, the devices are bulky and complex to operate, and are only suitable for indoor static conditions.
A relaxation level recognition model based on supervised contrastive learning is adopted. By collecting pulse wave signals for feature extraction and analysis, and combining a self-supervised contrastive loss function to iteratively train the feature extraction model, the accuracy of relaxation level recognition is improved, and real-time monitoring is realized on portable relaxation detection devices and wearable devices.
It improves the accuracy of relaxation level recognition and user experience, can monitor relaxation level in real time under different environments, and adjusts the working parameters of relaxation operation through relaxation level index to help users relax faster and more effectively and maintain mental and physical health.
Smart Images

Figure CN119700109B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of relaxation therapy, and more specifically, to a method, apparatus, electronic device, and storage medium for recognizing relaxation levels in the field of relaxation therapy. Background Technology
[0002] With increasing work and life pressures in modern society, stress, anxiety, and depression have become increasingly prevalent mental illnesses. They disrupt daily life and, in some cases, can escalate into trauma. Therefore, alleviating stress is a crucial issue in reducing the incidence of these illnesses.
[0003] Existing technologies can monitor human pressure based on non-wearable devices. While the acquisition accuracy of vital signs is high when using non-wearable devices for detection, the devices are large and complex to operate because they require external leads or sensors. They are only suitable for use indoors and in static conditions.
[0004] In recent years, some wearable devices have also been able to monitor changes in human physiological parameters in real time. Wearable devices are small in size, and their monitoring is not limited by indoor or outdoor environments, making them more suitable for practical applications. However, current technologies using wearable devices to monitor changes in human physiological parameters for relaxation level recognition mainly rely on threshold methods, resulting in low accuracy in relaxation level recognition and frequent misjudgments, leading to a poor user experience. Summary of the Invention
[0005] This application provides a method, apparatus, electronic device, and storage medium for relaxation level recognition, which can improve the accuracy of relaxation level recognition and enhance the user experience.
[0006] Firstly, a method for relaxation degree recognition is provided, which includes: acquiring the pulse wave signal of the target object; preprocessing the pulse wave signal to obtain the target pulse wave signal; inputting the target pulse wave signal into a pre-trained relaxation degree recognition model to obtain the relaxation degree index corresponding to the target pulse wave signal; the relaxation degree recognition model is trained based on a supervised contrastive learning method.
[0007] In the above technical solution, the pulse wave signal of the target object is acquired, and a relaxation index corresponding to the pulse wave signal is identified based on a relaxation index recognition model pre-trained using a supervised contrastive learning method. Since the relaxation index can be directly obtained from the pulse wave analysis, this method can be implemented in portable relaxation detection devices and wearable devices (such as smartwatches and rings), providing a good option for intelligent prediction of relaxation states. The supervised contrastive learning method allows for iterative training of the relaxation index recognition model, improving its accuracy.
[0008] In conjunction with the first aspect, in some possible implementations, after obtaining the relaxation index corresponding to the target pulse wave signal, the method further includes: determining whether the relaxation index is less than a preset threshold; when the relaxation index is less than the preset threshold, performing a target relaxation operation based on the relaxation index to relax the target object.
[0009] In the above technical solution, performing target relaxation operations based on the relaxation index can help the target object reduce stress. Improving the target object's relaxation index means that the target object is in a relaxed state, which can improve the target object's user experience.
[0010] Combining the first aspect and the above implementation methods, in some possible implementation methods, the relaxation degree recognition model includes a feature extraction model and a supervised contrastive learning model. The target pulse wave signal is input into the pre-trained relaxation degree recognition model to obtain the relaxation degree index corresponding to the target pulse wave signal. This includes: extracting N signal segments from the target pulse wave signal in a preset unit using the feature extraction model and processing them to obtain a feature map containing N signal segments; where N is greater than or equal to 1; and analyzing and comparing the feature map using the supervised contrastive learning model to obtain the relaxation degree index of the N signal segments.
[0011] In the above technical solution, by dividing the target pulse wave signal into N signal segments and obtaining the relaxation index of the N signal segments, the target object can more clearly understand the specific value of the relaxation index corresponding to different segments. Combining the relaxation index of the N signal segments can help understand the changing trend of the relaxation index.
[0012] Combining the first aspect and the above implementation methods, in some possible implementation methods, when the N signal segments include the current signal segment and the previous signal segment, the relaxation index corresponding to the current signal segment is the first relaxation index, and the relaxation index corresponding to the previous signal segment is the second relaxation index. After performing the target relaxation operation based on the relaxation index, the method further includes: adjusting the target working parameter corresponding to the target relaxation operation according to the change of the first relaxation index relative to the second relaxation index; wherein, when the target relaxation operation is an audio relaxation operation, the target working parameter is the volume; when the target relaxation operation is a cooling relaxation operation, the target working parameter is the temperature.
[0013] In the above technical solution, by adjusting the working parameters of the target relaxation operation through the change of the first relaxation index relative to the second relaxation index, the relaxation feedback adjustment of the target object can be realized, which can help the target object relax more quickly and effectively, and maintain psychological and physical health.
[0014] In combination with the first aspect and the above implementation methods, in some possible implementation methods, when the target relaxation operation is an audio relaxation operation, the target working parameters corresponding to the target relaxation operation are adjusted according to the change of the first relaxation index relative to the second relaxation index, including: when the first relaxation index increases relative to the second relaxation index, the volume of the played audio is reduced; when the first relaxation index decreases relative to the second relaxation index or remains unchanged, the volume of the played audio is increased.
[0015] In conjunction with the first aspect and the above implementation methods, in some possible implementation methods, after increasing the volume of the played audio when the first relaxation index decreases or remains unchanged relative to the second relaxation index, the method further includes: continuously identifying the relaxation index of the target object; determining the relaxation level of the current relaxation index when the relaxation level of the target object continuously decreases or remains unchanged within a preset time period; selecting the target audio corresponding to the relaxation level from a pre-stored audio library for playback; the pre-stored audio library includes multiple audio files and their corresponding relaxation levels.
[0016] In combination with the first aspect and the above implementation methods, in some possible implementation methods, when the target relaxation operation is a cooling relaxation operation, the target working parameters corresponding to the target relaxation operation are adjusted according to the change of the first relaxation index relative to the second relaxation index, including: when the first relaxation index increases relative to the second relaxation index, the temperature is increased within a preset temperature range; when the first relaxation index decreases relative to the second relaxation index or remains unchanged, the temperature is decreased within a preset temperature range.
[0017] In combination with the first aspect and the above implementation methods, in some possible implementation methods, the method is applied to a first electronic device to perform a target relaxation operation based on a relaxation index, including: detecting a second electronic device connected to the first electronic device; when the first electronic device is detected to be connected to the second electronic device, controlling the second electronic device to perform the target relaxation operation based on the relaxation index; when the first electronic device is not detected to be unconnected to the second electronic device, establishing a connection between the first electronic device and the second electronic device, and controlling the second electronic device to perform the target relaxation operation based on the relaxation index after the connection is established.
[0018] Combining the first aspect and the above implementation methods, in some possible implementations, the relaxation degree recognition model includes a feature extraction model and a supervised contrastive learning model. Before inputting the target pulse wave signal into the pre-trained relaxation degree recognition model, the method further includes: acquiring multiple sample data; the sample data includes multiple pulse wave signal samples and their corresponding annotation information, the annotation information being used to characterize the relaxation degree index corresponding to the pulse wave signal sample; extracting coded features for the multiple pulse wave signal samples using the feature extraction model; inputting the coded features extracted from the multiple pulse wave signal samples and the corresponding annotation information into the supervised contrastive learning model; in the supervised contrastive learning model, for any anchor sample specified among the multiple pulse wave signal samples, pulse wave signal samples whose difference between the annotation information and the annotation information of the anchor sample is within a preset difference range are determined as positive samples; using narrowing the distance between the coded features of positive samples as the objective of the supervised contrastive learning loss function, the feature extraction model is iteratively trained.
[0019] In the above technical solution, a novel self-supervised contrastive loss function is used, allowing multiple positive samples for each anchor point and permitting a certain threshold range for positive samples. This combines the feature encoder and the supervised contrastive regression learning model, and iteratively trains the feature extraction model based on the self-supervised contrastive regression learning loss function. This improves the feature extraction performance of the model, enabling the trained model to extract features from pulse wave signals more accurately and enhancing the precision of the relaxation recognition model. Furthermore, by setting the objective of the supervised contrastive regression learning loss function to narrow the distance between the encoded features of positive samples, an optimization objective can be set for the combined models, further improving the accuracy of model recognition.
[0020] In summary, this application acquires the pulse wave signal of the target object and identifies the relaxation index corresponding to the pulse wave signal based on a relaxation index recognition model pre-trained using a supervised contrastive learning method. Since the relaxation index can be obtained directly from the pulse wave analysis, this method can be implemented in portable relaxation detection devices and wearable devices (such as smartwatches and rings), providing a good option for intelligent prediction of relaxation states. The supervised contrastive learning method can iteratively train the relaxation index recognition model, improving its accuracy. In this method, performing a target relaxation operation based on the relaxation index helps reduce stress in the target object, and increasing the target object's relaxation index indicates a relaxed state, improving the user experience. By dividing the target pulse wave signal into N signal segments and obtaining the relaxation index for each segment, the target object can more clearly understand the specific values of the relaxation index corresponding to different segments, and combining the relaxation indices of the N signal segments reveals the trend of the relaxation index. Furthermore, the working parameters of the target relaxation operation can be adjusted based on the changing trend of the relaxation index, enabling relaxation feedback adjustment for the target object. This helps the target object relax more quickly and effectively, maintaining psychological and physical health. A novel self-supervised contrastive loss function allows multiple positive samples for each anchor point and permits a certain threshold range for these positive samples. By combining the feature encoder and the supervised contrastive regression learning model, and iteratively training the feature extraction model based on the self-supervised contrastive regression learning loss function, the feature extraction performance of the feature extraction model can be improved. This allows the trained feature extraction model to more accurately extract features from pulse wave signals, improving the accuracy of the relaxation recognition model. Moreover, by setting the objective of the supervised contrastive regression learning loss function to narrow the distance between the encoded features of positive samples, a model optimization objective can be set for the combined two models, further improving the accuracy of model recognition.
[0021] Secondly, a relaxation degree recognition device is provided, comprising: a acquisition module for acquiring the pulse wave signal of a target object; a preprocessing module for preprocessing the pulse wave signal to obtain a target pulse wave signal; and a recognition module for inputting the target pulse wave signal into a pre-trained relaxation degree recognition model to obtain a relaxation degree index corresponding to the target pulse wave signal; wherein the relaxation degree recognition model is trained based on a supervised contrastive learning method.
[0022] In conjunction with the second aspect, in some possible implementations, the device further includes: a relaxation module, used to perform a target relaxation operation based on the relaxation index when the relaxation index is less than a preset threshold, so as to relax the target object.
[0023] In conjunction with the above implementation methods in the second aspect, in some possible implementation methods, the relaxation degree recognition model includes a feature extraction model and a supervised contrastive learning model. The recognition module is specifically used to extract N signal segments from the target pulse wave signal in a preset unit through the feature extraction model and process them to obtain a feature map containing N signal segments; where N is greater than or equal to 1; and to analyze and compare the feature map through the supervised contrastive learning model to obtain the relaxation degree index of the N signal segments.
[0024] In conjunction with the second aspect and the above implementation methods, in some possible implementation methods, the device further includes: an adjustment module, configured to, when N signal segments include the current signal segment and the previous signal segment of the previous signal segment, define the relaxation index corresponding to the current signal segment as a first relaxation index and the relaxation index corresponding to the previous signal segment as a second relaxation index; adjust the target operating parameter corresponding to the target relaxation operation according to the change of the first relaxation index relative to the second relaxation index; wherein, when the target relaxation operation is an audio relaxation operation, the target operating parameter is the volume; and when the target relaxation operation is a cooling relaxation operation, the target operating parameter is the temperature.
[0025] Combining the second aspect and the above implementation methods, in some possible implementation methods, when the target relaxation operation is an audio relaxation operation, the adjustment module is specifically used to: decrease the volume of the played audio when the first relaxation index increases relative to the second relaxation index; and increase the volume of the played audio when the first relaxation index decreases relative to the second relaxation index or remains unchanged.
[0026] In conjunction with the second aspect and the above implementation methods, in some possible implementation methods, the device further includes: a switching module, configured to continuously identify the relaxation index of the target object after increasing the volume of the played audio when the first relaxation index decreases or remains unchanged relative to the second relaxation index; determine the relaxation level of the current relaxation index when the relaxation level of the target object continues to decrease or remains unchanged within a preset time period; and select a target audio corresponding to the relaxation level from a pre-stored audio library for playback; the pre-stored audio library includes multiple audio files and their corresponding relaxation levels.
[0027] In combination with the second aspect and the above implementation methods, in some possible implementation methods, when the target relaxation operation is a cooling relaxation operation, the adjustment module is specifically used to: increase the temperature within a preset temperature range when the first relaxation index increases relative to the second relaxation index; and decrease the temperature within a preset temperature range when the first relaxation index decreases relative to the second relaxation index or remains unchanged.
[0028] In conjunction with the second aspect and the above implementation methods, in some possible implementations, the device is a first electronic device, and the relaxation module is specifically used to: detect a second electronic device connected to the first electronic device; when the first electronic device is detected to be connected to the second electronic device, control the second electronic device to perform a target relaxation operation based on the relaxation index; when the first electronic device is not detected to be unconnected to the second electronic device, establish a connection between the first electronic device and the second electronic device, and after the connection is established, control the second electronic device to perform a target relaxation operation based on the relaxation index.
[0029] In conjunction with the second aspect and the above implementation methods, in some possible implementation methods, the device further includes: a model training module for acquiring multiple sample data; the sample data includes multiple pulse wave signal samples and their corresponding annotation information, the annotation information being used to characterize the relaxation index corresponding to the pulse wave signal samples; using a feature extraction model to extract encoded features for the multiple pulse wave signal samples respectively; inputting the encoded features extracted from the multiple pulse wave signal samples and the annotation information corresponding to the multiple pulse wave signal samples into a supervised contrastive learning model; in the supervised contrastive learning model, for any anchor sample specified among the multiple pulse wave signal samples, pulse wave signal samples whose difference between the annotation information and the annotation information of the anchor sample is within a preset difference range are determined as positive samples; using narrowing the distance between the encoded features of positive samples as the objective of the supervised contrastive learning loss function, the feature extraction model is iteratively trained.
[0030] Thirdly, an electronic device is provided, including a memory and a processor. The memory is used to store executable program code, and the processor is used to call and run the executable program code from the memory, causing the electronic device to perform the methods of the first aspect or any possible implementation thereof.
[0031] Fourthly, a computer program product is provided, comprising: computer program code, which, when run on a computer, causes the computer to perform the methods described in the first aspect or any possible implementation thereof.
[0032] Fifthly, a computer-readable storage medium is provided that stores computer program code, which, when executed on a computer, causes the computer to perform the methods described in the first aspect or any possible implementation thereof. Attached Figure Description
[0033] Figure 1 This is a schematic flowchart illustrating a relaxation level identification method provided in an embodiment of this application.
[0034] Figure 2This is a schematic diagram of a pulse wave signal provided in an embodiment of this application.
[0035] Figure 3 This is a schematic diagram of a relaxation degree recognition device provided in an embodiment of this application.
[0036] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0037] The technical solutions in this application will be clearly and thoroughly described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B. "And / or" in the text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.
[0038] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature.
[0039] With increasing work and life pressures in modern society, stress, anxiety, and depression have become increasingly prevalent mental illnesses. They disrupt daily life and, in some cases, can escalate into trauma. Therefore, alleviating stress is a crucial issue in reducing the incidence of these illnesses.
[0040] Under stress, depression, or anxiety, the body releases many chemicals, which can manifest as changes in nonverbal body language. Therefore, the degree of relaxation can be assessed using signals such as audio, video, electrocardiogram (ECG), electroencephalogram (EEG), electromyography (EMG), skin temperature, skin conductance, blood pressure, and respiration.
[0041] Based on different signal acquisition methods, relaxation detection systems can be divided into the following types: 1) Relaxation detection systems based on video images, such as those detecting stress states based on facial micro-expressions or behavioral movements. The advantage is that it is imperceptible, but the disadvantage is that it is limited by the camera's coverage area, only allowing detection within a fixed range. Furthermore, the camera's resolution is limited; when the distance to the camera is far, the recognition rate of expressions and accuracy is low, thus affecting the detection of relaxation. 2) Detection systems based on vital signs. These can be further subdivided into relaxation detection systems based on non-wearable devices (EEG caps, ECG machines, etc.) and wearable devices (such as wristbands, headbands). While non-wearable devices offer higher accuracy in acquiring vital signs, they require external leads or sensors, resulting in large equipment size and complex operation, making them suitable only for indoor and static use. For relaxation detection systems based on wearable sensors, the principle is that miniature sensors are embedded in wearable devices, such as wristbands, belts, or vests. Wearable devices are small and portable, can monitor changes in human physiological parameters in real time, and are not limited by indoor or outdoor environments, making them more suitable for practical applications. However, current relaxation detection algorithms based on wearable devices mainly rely on thresholding. While thresholding is simple to calculate and easy to deploy, it suffers from poor accuracy and frequent misjudgments, resulting in a poor user experience for the target user.
[0042] To address the aforementioned problems in existing technologies, this invention proposes a relaxation degree measurement method based on a self-supervised contrastive learning deep model. This method utilizes pulse waves to measure relaxation degree and can be used in portable relaxation detection devices and wearable devices (such as smartwatches and rings). It can also improve the accuracy of relaxation degree recognition and enhance the user experience for the target audience.
[0043] Figure 1 This is a schematic flowchart illustrating a method for recognizing relaxation levels provided in an embodiment of this application. In this embodiment, the executing entity is a first electronic device, which can specifically be a wearable device. Optionally, the wearable device can be a smartwatch, bracelet, ring, etc. This embodiment uses a smartwatch as an example for illustration.
[0044] For example, such as Figure 1 As shown, the method 100 includes:
[0045] Step 101: Acquire the pulse wave signal of the target object;
[0046] The target object is the person wearing the wearable device. The wearable device contains photoelectric sensors that allow it to collect the target object's pulse wave signal. A pulse wave is formed by the heart's beating (vibration) propagating outwards along arteries and blood flow, much like ripples on water. The pulse wave varies slightly in different locations (aorta, arteries, or capillaries) as blood circulates in the blood vessels. The collected pulse wave signal has specific morphology (wave shape), intensity (wave amplitude), velocity (wave speed), and rhythm (wave period). The collected pulse wave can be specifically described as follows: Figure 2 As shown in (a).
[0047] In some embodiments, the wearable device is equipped with an accelerometer in addition to a photoelectric pulse sensor, which can be used to collect human pulse wave signals more accurately.
[0048] Optionally, the wearable device can be configured to collect the pulse wave signal of the target object in real time at a preset frequency. Alternatively, the wearable device can respond to a command sent by the target object to collect the pulse wave signal and collect the target object's pulse wave within a preset duration.
[0049] Step 102: Preprocess the pulse wave signal to obtain the target pulse wave signal.
[0050] Preprocessing can specifically include filtering. Filtering can be categorized by frequency response into low-pass filtering, high-pass filtering, and band-pass filtering.
[0051] Low-pass filtering can be simply understood as setting a frequency point, blocking signals with frequencies higher than this point, and removing signals with frequencies above this threshold. High-pass filtering is the opposite; it can be understood as setting a frequency point and allowing only signals above this point to pass, removing signals with frequencies below this threshold. Band-pass filtering allows only specific frequencies to pass; it can be understood as setting a lower and upper frequency limit, allowing only signals above the lower limit and below the upper limit to pass, removing signals below the lower limit and above the upper limit.
[0052] Considering that the pulse rate typically ranges from 30 to 300 bpm (beats per minute), this embodiment performs bandpass filtering on the pulse wave signal. For example, the passband range of the bandpass filter can be set to 0.5-5 Hz. The resulting bandpass-filtered pulse wave signal is then obtained.
[0053] Preprocessing can also include standardization, which can be performed on the bandpass filtered pulse wave signal using formula (1) to obtain the target pulse wave signal y. proc Where μ is the mean and σ is the standard deviation.
[0054]
[0055] For example, it can be Figure 2 The pulse wave signal shown in (a) is processed as described above to obtain the target pulse wave signal as follows: Figure 2 As shown in (b).
[0056] Step 103: Input the target pulse wave signal into the pre-trained relaxation recognition model to obtain the relaxation index corresponding to the target pulse wave signal; the relaxation recognition model is trained based on a supervised contrastive learning method.
[0057] The target pulse wave signal is input into a relaxation recognition model pre-trained based on a supervised contrastive learning method. The relaxation recognition model can extract features from the target pulse wave signal and obtain the relaxation index corresponding to the target pulse wave signal based on the extracted features.
[0058] It should be understood that the relaxation index is used to characterize the current degree of relaxation of the target object. It is negatively correlated with the current stress of the target object. The larger the relaxation index, the more relaxed the target object is and the less stress it is. The smaller the relaxation index, the more stress the target object is.
[0059] In the above method, the pulse wave signal of the target object is acquired, and the relaxation index corresponding to the pulse wave signal is identified based on a relaxation index recognition model pre-trained using a supervised contrastive learning method. Since the relaxation index can be obtained directly from the pulse wave, this method can be run on portable relaxation detection devices and wearable devices (such as smartwatches and rings), providing a good option for intelligent prediction of relaxation states. The supervised contrastive learning method can iteratively train the relaxation index recognition model, improving its accuracy.
[0060] In one possible implementation, after obtaining the relaxation index corresponding to the target pulse wave signal, the method further includes: determining whether the relaxation index is less than a preset threshold; when the relaxation index is less than the preset threshold, performing a target relaxation operation based on the relaxation index to relax the target object.
[0061] The relaxation index is negatively correlated with stress; the higher the relaxation index, the lower the stress level of the target user. The preset threshold is relative to the maximum value within the normal stress range. The preset threshold indicates whether the current stress level is high and whether relaxation measures are needed for the target individual. When the relaxation index is less than the preset threshold, it indicates that the target individual's stress level is above the normal range, and relaxation measures are needed. When the relaxation index is greater than the preset threshold, it indicates that the target individual's stress level is within the normal range, and relaxation measures are not needed.
[0062] Targeted relaxation operations can be performed by wearable devices on a target object, or by wearable devices controlling other electronic devices to perform operations on the target object. Targeted relaxation operations correspond to certain operating parameters, which can be determined based on a relaxation index, and the targeted relaxation operation is then executed using these parameters.
[0063] For example, suppose the relaxation index corresponding to the target pulse wave signal is 37, which is less than the preset threshold of 60. In this case, the relaxation index is less than the preset threshold, indicating that the target object is under great stress and needs to be relaxed. Assuming that the working parameters are divided into three levels: low, medium, and high, and 37 corresponds to medium, then the target relaxation operation will be performed with medium working parameters.
[0064] In the above method, performing target relaxation operations based on the relaxation index can help the target object reduce stress. Improving the target object's relaxation index means that the target object is in a relaxed state, which can improve the target object's user experience.
[0065] In one possible implementation, the method is applied to a first electronic device to perform a target relaxation operation based on a relaxation index, including: detecting a second electronic device connected to the first electronic device; when the first electronic device is detected to be connected to the second electronic device, controlling the second electronic device to perform the target relaxation operation based on the relaxation index; when the first electronic device is not detected to be unconnected to the second electronic device, establishing a connection between the first electronic device and the second electronic device, and controlling the second electronic device to perform the target relaxation operation based on the relaxation index after the connection is established.
[0066] The first electronic device is the aforementioned wearable device; in this embodiment, a smartwatch is specifically used as an example. The second electronic device is a different device from the first electronic device. The second electronic device can establish a connection with the first electronic device, and after the connection is established, the first electronic device can control the second electronic device to perform target relaxation operations on the target object.
[0067] When the relaxation index of the target object is less than a preset threshold, the first electronic device first checks whether there is a second electronic device connected to it. If the first electronic device is found to be connected to the second electronic device, it directly controls the second electronic device to perform the target relaxation operation. If the first electronic device is not found to be connected to the second electronic device, a connection is established between the first electronic device and the second electronic device.
[0068] When the first electronic device detects that it is not connected to the second electronic device, it can first detect whether there is a connectable second electronic device within a certain range. This certain range can be the maximum range that the first electronic device can detect. Upon detecting a connectable second electronic device, the first electronic device can actively connect to the second electronic device, or it can prompt the target object to connect to the second electronic device. After connecting, the first electronic device can then control the second electronic device to perform a relaxation operation on the target object.
[0069] Optionally, when the first electronic device connects to the second electronic device to remind the target, the reminder can be displayed as a pop-up window on the smartwatch interface. For example, the pop-up window could display text such as "Current stress is high; it is recommended to connect the second electronic device for relaxation," reminding the user to relax. Alternatively, the smartwatch could remind the user to relax by playing a pre-set voice message containing keywords such as "high stress," "recommend connecting the second electronic device," and "relax."
[0070] The target relaxation operation includes at least one relaxation operation, and the second electronic device performing the target relaxation operation can be one or more. The first electronic device can simultaneously establish connections with multiple second electronic devices and control the multiple second electronic devices to perform multiple target operations.
[0071] In some embodiments, the target operation may include massage relaxation, audio relaxation, and cooling relaxation. The second electronic device capable of performing the above relaxation operation may be a smart massage chair, smart headphones, or a smart cooling headband. The second electronic device may also include a smart car. A connection such as Bluetooth or Wireless Fidelity (WiFi) may be established between the first and second electronic devices; however, this embodiment does not limit this.
[0072] For example, the first electronic device, as described in the above embodiment, is a smartwatch. Assume the second electronic device is a smart car, which includes an audio system and an air conditioner. The target operation is an audio relaxation operation and / or a cooling relaxation operation. When the smartwatch detects a connection between the smart car and the smartwatch when the target relaxation index is less than a threshold, the smartwatch sends an audio control command to the smart car, controlling the smart car to play preset audio through the audio system to perform an audio relaxation operation on the target object. And / or, the smartwatch sends a cooling control command to the smart car, controlling the smart car to use the air conditioner to perform a cooling relaxation operation on the target object.
[0073] In one possible implementation, the relaxation level recognition model includes a feature extraction model and a supervised contrastive learning model. The target pulse wave signal is input into the pre-trained relaxation level recognition model to obtain the relaxation level index corresponding to the target pulse wave signal. This includes: extracting N signal segments from the target pulse wave signal in a preset unit using the feature extraction model and processing them to obtain a feature map containing N signal segments; where N is greater than or equal to 1; and analyzing and comparing the feature map using the supervised contrastive learning model to obtain the relaxation level index of the N signal segments.
[0074] The feature extraction model can be a model that uses a feature encoder to extract coded features from the target pulse wave signal. The feature encoder can be used to extract waveform and amplitude features from the pulse wave signal to obtain the coded features, i.e., the feature map mentioned above.
[0075] The preset unit can include a preset number of sampling points. Assuming the preset unit is 62 sampling points, the specific process for extracting the encoded features is as follows:
[0076] Step 1, extract signal segments (seg). Assuming the target pulse wave signal length of the input relaxation recognition model is 640 (sampling rate of 10s×64), the extracted segment length is 62 sampling points, and the extraction step size is 2 sampling points, thus extracting 290 signal segments ((640-62) / 2+1=290), which is the above N signal segments.
[0077] Step 2: Combine the N signal segments into a matrix and transpose it to generate a two-dimensional data matrix with a size of 62×290. The number of its rows (channels) is equal to the length of the signal segment (seg) in Step 1 (62), and the number of its columns (length) is equal to the number of signal segments (seg) (290).
[0078] Step 3: For the data matrix, calculate the standard deviation by column, that is, calculate the standard deviation of 290 segments (segment length is 62), and generate a standard deviation vector representing each column of the data matrix with a size of 1×290.
[0079] Step 4, morphological encoding: The data matrix is averaged column-wise and divided by the standard deviation calculated in step 3 to obtain a new two-dimensional data matrix, which still has the size of (62×290). This operation can amplify the changes in the waveform, making it easier for the feature extraction model to capture these changes.
[0080] Step 5, amplitude encoding: For the standard deviation vector (1×290) calculated in step 3, calculate its sine and cosine respectively to obtain the sine code (1×90) and cosine code (1×90) of the standard deviation vector.
[0081] Step 6, Concatenation. The encoded waveform (62×290) from Step 4 is concatenated row-wise with the sine (1×290) and cosine (1×290) standard deviation vectors from Step 5 to obtain a concatenated feature map (64×290). This feature map serves as the input for the subsequent supervised contrastive learning model. The supervised contrastive model analyzes and processes the obtained feature map to obtain the relaxation index of 290 signal segments.
[0082] In the above method, by dividing the target pulse wave signal into N signal segments and obtaining the relaxation index of N signal segments, the target object can more clearly understand the specific value of the relaxation index corresponding to different segments. Combining the relaxation index of N signal segments can help understand the changing trend of the relaxation index.
[0083] In one possible implementation, when N signal segments include the current signal segment and the previous signal segment, the relaxation index corresponding to the current signal segment is the first relaxation index, and the relaxation index corresponding to the previous signal segment is the second relaxation index. After performing the target relaxation operation based on the relaxation index, the method further includes: adjusting the target operating parameter corresponding to the target relaxation operation according to the change of the first relaxation index relative to the second relaxation index; wherein, when the target relaxation operation is an audio relaxation operation, the target operating parameter is the volume; when the target relaxation operation is a cooling relaxation operation, the target operating parameter is the temperature.
[0084] The first electronic device collects the pulse wave signal of the target object in real time. That is, at any time, there are N signal segments, including the current signal segment and the previous signal segment. Each signal segment corresponds to a relaxation index. The current signal segment corresponds to the first relaxation index, and the previous signal segment corresponds to the second relaxation index.
[0085] The change in the first relaxation index relative to the second relaxation index can be obtained by comparing their magnitudes. The first and second relaxation indices can be greater than, less than, or the same. Therefore, the change in the first relaxation index relative to the second relaxation index can include three possibilities: increase, decrease, or remain unchanged.
[0086] The target relaxation operation is the relaxation operation currently being performed on the target object. The target relaxation operation can be any one or more of the following: massage relaxation, audio relaxation, and cooling relaxation. When the target relaxation operation is a single relaxation operation, the target working parameters are the working parameters corresponding to that single relaxation operation. When the target relaxation operation is multiple relaxation operations, the target working parameters are the working parameters corresponding to each of the multiple relaxation operations.
[0087] The direction and amount of adjustment for the target working parameters corresponding to the target relaxation operation can be determined based on the change of the first relaxation index relative to the second relaxation index, in order to provide relaxation feedback training to the target object. For example, if the change of the first relaxation index relative to the second relaxation index is an increase, it indicates that the target operation has relaxed the target object, and in this case, the working parameters of the target operation can be adjusted in the direction of decreasing the relaxation intensity. If the change of the first relaxation index relative to the second relaxation index is a decrease or remains unchanged, it indicates that the target operation has not relaxed the target object, and in this case, the working parameters of the target operation can be adjusted in the direction of increasing the relaxation intensity.
[0088] In the above method, by adjusting the working parameters of the target relaxation operation through the change of the first relaxation index relative to the second relaxation index, relaxation feedback adjustment can be achieved on the target object, which can help the target object relax more quickly and effectively, and maintain psychological and physical health.
[0089] In one possible implementation, when the target relaxation operation is an audio relaxation operation, the target working parameters corresponding to the target relaxation operation are adjusted according to the change of the first relaxation index relative to the second relaxation index, including: when the first relaxation index increases relative to the second relaxation index, the volume of the played audio is reduced; when the first relaxation index decreases relative to the second relaxation index or remains unchanged, the volume of the played audio is increased.
[0090] When the target relaxation operation is an audio relaxation operation, the target operating parameter is volume. Under the same audio, different volumes have a certain impact on the relaxation intensity. Generally, the higher the volume, the greater the relaxation intensity, and the lower the volume, the less the relaxation intensity.
[0091] When the first relaxation index increases relative to the second relaxation index, it indicates that the currently playing audio and the playback volume can have a relaxing effect on the target object. At this time, the working parameters of the target operation can be adjusted in the direction of reducing the relaxation intensity. The lower the volume, the weaker the relaxation intensity. Therefore, the volume of the playing audio can be reduced appropriately.
[0092] When the first relaxation index decreases or remains unchanged relative to the second relaxation index, it indicates that the currently played audio or the volume of the audio cannot relax the target object. At this time, the working parameters of the target operation should be adjusted in the direction of increasing the relaxation intensity. The higher the volume, the greater the relaxation intensity. Therefore, the volume of the played audio can be increased appropriately to relax the target object.
[0093] In some embodiments, each audio track may also correspond to a volume threshold range, within which the volume of the played audio can be decreased or increased. The volume threshold range can be defined as the range between the minimum and maximum values that the audio track can statistically achieve a relaxing effect.
[0094] In one possible implementation, after increasing the volume of the played audio when the first relaxation index decreases or remains unchanged relative to the second relaxation index, the method further includes: continuously identifying the relaxation index of the target object; determining the relaxation level of the current relaxation index when the relaxation index of the target object continuously decreases or remains unchanged within a preset time period; selecting and playing target audio corresponding to the relaxation level from a pre-stored audio library; the pre-stored audio library includes multiple audio files and their corresponding relaxation levels.
[0095] If, after increasing the volume of the audio being played, the relaxation index of the target object continues to decrease or remains unchanged within a preset duration, it means that the audio being played within the preset duration is not reducing the user's stress. This indicates that the currently played audio is not relaxing for the target object, and it is necessary to switch audio to relax the target object.
[0096] The audio library can be stored in advance in a first electronic device or a second electronic device. The audio library includes multiple audio files and a state table for each audio file, which includes the relaxation level for each audio file.
[0097] In some embodiments, before selecting and playing target audio corresponding to the relaxation level from a pre-stored audio library, the method further includes: dividing the relaxation index into L levels according to a preset index range; playing multiple audios to the target object; monitoring the relaxation index of the target object in real time during the playback of multiple audios; and calculating the relaxation level corresponding to each audio based on the monitored relaxation index.
[0098] The relaxation level of each audio track is calculated based on the monitored relaxation index. Specifically, this can include: for example, taking a first audio track among multiple audio tracks: monitoring the target audience's relaxation index during playback of the first audio track; dividing the total duration of the first audio track into 's' segments, obtaining the relaxation index for each of the 's' segments; calculating the average relaxation index of each segment within the 's' segments; and obtaining the relaxation level of each segment based on the calculated average relaxation index. The durations of audio segments with the same relaxation level are then summed, and the proportion of each relaxation level's duration within the total duration of the first audio track is calculated. Based on the proportion of each relaxation level within the first audio track, the relaxation level of the first audio track is determined.
[0099] Assume the relaxation index is divided into L levels: low (level 1), relatively low (level 2), medium (level 3), relatively high (level 4), ..., high (level L). Based on the relaxation effect of each audio track, we can derive L low levels for each audio track. Assuming the relaxation effect of each audio track also has L levels, then the relaxation effect level and the relaxation index level can be correlated one-to-one, thus obtaining the relaxation level of each audio track.
[0100] In some embodiments, the state table may also store the audio type, total number of plays, and the playback quality of the last k plays, assuming that the playback quality is represented by excellent, good, or poor.
[0101] The status table for audio 1 is shown in Table 1.
[0102] Table 1
[0103] Items in the status table name Audio 1 type Pure music Relaxation Level medium Total number of plays 13 The effect of the most recent k times good
[0104] Before using the first or second electronic device, the target subject needs to select a preferred audio type and collect pulse wave data of the target subject in a quiet state (e.g., room temperature, soft and moderately loud music) for Q minutes (optionally, Q=10) as the baseline for the level of relaxation in the model evaluation.
[0105] Then, an audio clip is randomly selected for playback. The relaxation level index is assessed in real time during playback. After playback is complete, the effectiveness of the content is evaluated, and the status table is updated.
[0106] The specific steps for evaluating the relaxation index may include:
[0107] The first step is to divide the audio into s segments, calculate the average relaxation index of each segment, and obtain the corresponding relaxation level for each segment based on the average relaxation index of each segment.
[0108] Assuming the total duration of the audio is p seconds, and each second corresponds to a relaxation index r, we can obtain p relaxation indices (rp). n Let n = 1, 2, ..., p). Divide the audio into s segments, each segment being t seconds long (if the last segment is less than t seconds long, its start time is pt seconds). Correspondingly, the p relaxation indices can be divided into s groups, each group containing t relaxation indices. Calculate the average relaxation index within each segment, and obtain the relaxation level of each segment based on the average relaxation index per second. i Assuming the relaxation index is expressed as a percentage, where the index representing the most relaxed state is 100, and there are 5 relaxation levels, then the range of each level is 20. The relaxation level of each segment is calculated as shown in formula (2).
[0109]
[0110] Where i = 1, 2, 3, ..., s
[0111] The second step is to calculate the proportion of time corresponding to each relaxation level within the total playback time, and determine the level with the largest proportion as the level of the audio.
[0112] In some embodiments, the audio in the preset audio library can also be marked with a relaxation effect. The relaxation effect is the range of relaxation levels that the track can achieve. For example, a relaxation effect of i->L means that the relaxation level will be increased from i to L. After determining the relaxation level of the target object, the relaxation range of the relaxation effect can be determined to include the relaxation level of the target object. From this range, any audio that is different from the currently playing audio can be selected as the target audio for playback.
[0113] The steps to calculate the relaxation effect of audio are as follows:
[0114] The first step is to divide the audio into 's' segments, calculate the average relaxation index for each segment, and obtain the corresponding relaxation level for each segment based on the average relaxation index. The specific steps are as described in the above embodiment and will not be repeated here.
[0115] The second step is to calculate the proportion of time corresponding to each relaxation level in the total playback time, and calculate the total relaxation effect level0 of the sleep aid content during this playback based on the proportion, as shown in formula (3).
[0116]
[0117] Among them, w i The weight of each relaxation level is calculated as shown in formula (4).
[0118]
[0119] The earlier the playback time, the lower the weight; the later the playback time, the higher the weight. Alternatively, the weight can be set to 1 (i.e., no weight).
[0120] The third step is to find any audio from the audio library that is different from the currently playing audio and is used as the target audio, based on the level corresponding to the relaxation index (assuming the level is i). The relaxation effect is marked as i->L in the status table (meaning that the track can raise the relaxation level from i to L).
[0121] In some embodiments, audio can be assigned priorities corresponding to different relaxation levels. For example, audio A has a relaxation effect of relaxation levels 1 to 3, audio B has a relaxation effect of relaxation levels 1 to 5, and audio C has a relaxation effect of relaxation levels 2 to 4. For the same relaxation level 2, audio B has a higher priority than audio C, and audio C has a higher priority than audio A. When the target object's relaxation level is 2 and the currently playing audio is audio B, the relaxation range can be determined based on the relaxation effect to include audio at relaxation level 2 of the target object: audio A and audio C. Where audio C has a higher priority than audio A, then audio A is determined as the target audio and played.
[0122] In some embodiments, after determining the target audio, volume variation rules can be combined to play it to the target object at an appropriate volume.
[0123] In some embodiments, the preset duration can specifically be the duration of the audio. After the target audio finishes playing, the relaxation level in the target audio status table can be updated based on the recorded relaxation index of the target object when playing the target audio, so as to obtain the actual relaxation level of the target audio based on the target object.
[0124] Fourth, after playback ends, update the relaxation level in the target audio status table based on the recorded relaxation index of the target object during playback.
[0125] Fifth, repeat steps three and four until the target's relaxation level remains at L / 2 or L for a period of time. The time threshold can be changed by the target, with a default value of T.
[0126] In one possible implementation, when the target relaxation operation is a cooling relaxation operation, the target working parameters corresponding to the target relaxation operation are adjusted according to the change of the first relaxation index relative to the second relaxation index, including: increasing the temperature within a preset temperature range when the first relaxation index increases relative to the second relaxation index; and decreasing the temperature within a preset temperature range when the first relaxation index decreases relative to the second relaxation index or remains unchanged.
[0127] When the target relaxation operation is a cooling relaxation operation, the target operating parameter is temperature. Different temperatures have a certain impact on the relaxation force of the relaxation operation. Generally, the lower the temperature, the greater the relaxation force, and the higher the temperature, the smaller the relaxation force.
[0128] The purpose of cooling and relaxation techniques is to make the target subject more comfortable; therefore, the preset temperature range can be the range where the human body feels most comfortable. An example could be 18°C to 28°C.
[0129] The purpose of the cooling and relaxation operation is to lower the temperature of the space where the target object is located to the current temperature. Therefore, in some embodiments, the upper limit of the preset temperature range can also be room temperature.
[0130] When the first relaxation index increases relative to the second relaxation index, it indicates that the current cooling operation temperature can relax the target object. At this time, the working parameters of the target operation should be adjusted in the direction of reducing the relaxation intensity. The closer the temperature is to room temperature, the lower the relaxation intensity of the cooling relaxation operation. Therefore, the temperature can be increased appropriately to relax the target object.
[0131] When the first relaxation index decreases or remains unchanged relative to the second relaxation index, it indicates that the current cooling operation temperature cannot relax the target object. At this time, the working parameters of the target operation should be adjusted in the direction of increasing the relaxation intensity. The lower the temperature, the lower the relaxation intensity of the cooling relaxation operation. At this time, the temperature can be appropriately reduced to relax the target object.
[0132] In existing technologies, machine learning methods first extract relevant features, then use classifiers (Support Vector Machines, Bayesian classifiers, etc.) to classify these features and obtain predictive results. However, extracting these features requires extensive expert experience, and the classification effect largely depends on the extracted features, leading to poor generalization. Deep learning methods can achieve end-to-end training and prediction, requiring no expert experience and offering high algorithm accuracy. However, the lack of labeled data limits the number of samples available for direct training in deep learning, thus limiting the upper limit of algorithm performance. To address these issues, this application proposes a method for training a recognition model based on supervised contrastive learning. This method requires no expert experience and is not limited by the number of labeled data samples.
[0133] In one possible implementation, the relaxation level recognition model includes a feature extraction model and a supervised contrastive learning model. Before inputting the target pulse wave signal into the pre-trained relaxation level recognition model, the method further includes: acquiring multiple sample data; the sample data includes multiple pulse wave signal samples and their corresponding annotation information, where the annotation information is used to characterize the relaxation level index corresponding to the pulse wave signal sample; extracting encoded features for each of the multiple pulse wave signal samples using the feature extraction model; inputting the encoded features extracted from the multiple pulse wave signal samples and the corresponding annotation information into the supervised contrastive learning model; in the supervised contrastive learning model, for any anchor sample specified among the multiple pulse wave signal samples, pulse wave signal samples whose difference between the annotation information and the annotation information of the anchor sample is within a preset difference range are determined as positive samples; and the feature extraction model is iteratively trained with the goal of narrowing the distance between the encoded features of the positive samples as the objective of the supervised contrastive learning loss function.
[0134] The annotation information can be understood as labels for the sample data. Each pulse wave signal sample in the sample data is labeled with a label that represents the relaxation index corresponding to that pulse wave signal sample. Different pulse wave signal samples can be labeled with the same or different labels.
[0135] A self-supervised contrastive learning method can be used to specify arbitrary anchor samples (i.e., fixed samples) from multiple pulse wave signal samples. Multiple anchor samples can be specified. For a given anchor sample, the associated positive and negative samples can be determined.
[0136] As described in the above embodiment, the feature extraction model uses a feature encoder to extract coded features from multiple pulse wave signals, obtaining coded features of multiple pulse wave signals. These coded features and their corresponding annotation information can be used as input to a supervised contrastive learning model. Arbitrary anchor samples are specified among the multiple pulse wave signal samples, and pulse wave signal samples whose difference between the annotation information and the anchor sample's annotation information is within a preset range are defined as positive samples. A supervised contrastive learning loss function is obtained, with the objective of narrowing the distance between the coded features of positive samples. The feature extraction model can then be iteratively trained based on this loss function.
[0137] In some embodiments, after obtaining multiple sample data, each of the multiple samples can be preprocessed as described in the above embodiments to obtain preprocessed sample data (for example, the preprocessed sample data is y). proc The preprocessed sample data is augmented to obtain multiple augmented samples for each sample.
[0138] For example, this section illustrates the use of Empirical Mode Decomposition (EMD) and sample enhancement techniques such as adding noise and flipping to enhance samples. The details are as follows:
[0139] 1. During the EMD decomposition stage:
[0140] 1) Based on the preprocessed pulse wave signal (y proc Find the upper and lower extreme points of the pulse wave signal, draw the upper and lower envelope lines, and obtain the mean of the upper and lower envelope lines to draw the mean envelope line of the pulse wave signal.
[0141] 2) The preprocessed pulse wave signal (y proc Subtracting the mean envelope yields the intermediate signal y. mid .
[0142] 3) Determine y mid If two conditions are met for an Intrinsic Mode Function (IMF), the signal is an IMF component; otherwise, the analysis in steps 1) to 3) is repeated based on the signal. Obtaining an IMF component typically requires several iterations.
[0143] 4) All the obtained IMF components are used as enhanced samples of the pulse wave signal (y IMF ).
[0144] The intrinsic modal components have two constraints: First, the number of extreme points and the number of zero-crossing points must be equal or differ by no more than one throughout the entire data segment. Second, at any given time, the average of the upper envelope formed by local maxima and the lower envelope formed by local minima is zero, meaning the upper and lower envelopes are locally symmetrical with respect to the time axis.
[0145] 2. During the noise addition stage:
[0146] 1) Obtain a set of random values with the same length as the signal, and calculate the white noise X by standardization as shown in formula (1) above. white .
[0147] 2. The preprocessed pulse wave signal y proc With white noise X white The sums are used to obtain the noise-enhanced data, i.e., the enhanced signal y. white =y proc +x white .
[0148] 3. During the flipping phase:
[0149] It is possible to preprocess y proc Data augmentation is achieved by performing forward / backward and vertical flipping operations. The signal after forward / backward flipping is y. flip This can be obtained by using the flip operator, i.e., y. flip =flip(y proc The signal y after flipping back and forth. neg =-(y proc ).
[0150] Multiple enhanced samples can be obtained through the above three stages. Since the enhanced samples are all derived from pulse wave signal samples, the pulse wave signal samples and their corresponding enhanced samples have the same annotation information.
[0151] Since the enhanced samples are all derived from pulse wave signal samples, the enhanced samples are equivalent to representing multiple characteristics of the pulse wave signal samples from different angles. This makes it possible to combine this method of sample enhancement by extracting signal components from different frequency bands with common sample enhancement methods such as noise addition, smoothing, and masking. This can effectively preserve the physical meaning of the pulse wave signal samples and improve the noise resistance of the model, thus playing a more positive role in the training process of the feature extraction model.
[0152] The feature extraction model can be used to extract coding features for multiple pulse wave signal samples and multiple enhanced samples. The extracted coding features of multiple pulse wave signal samples and multiple enhanced samples, along with the corresponding annotation information, are then input into a supervised contrastive learning model.
[0153] In the supervised contrastive learning model, a residual network structure (ResNet) is selected as the backbone network. It can identify any anchor sample from multiple pulse wave signal samples with different relaxation levels and multiple generated enhancement samples. Enhancement samples and pulse wave signal samples whose difference between the labeled information and the labeled information of the anchor sample is within a preset difference range are identified as positive samples, while enhancement samples and pulse wave signal samples whose difference between the labeled information and the labeled information of the anchor sample is outside the preset difference range are identified as negative samples.
[0154] For example, assuming the relaxation index of the anchor sample is M, and the preset range is ±N, then pulse wave signals and their enhanced samples with a relaxation index within the absolute value range of |M±N| are all determined as positive samples, and pulse wave signals and their enhanced samples with a relaxation index outside the absolute value range of |MN| are all determined as negative samples. Optionally, M is any relaxation index, and N can be selected as 10.
[0155] The supervised contrastive learning loss function is determined with the goal of narrowing the distance between the encoded features of positive samples, and the feature extraction model is iteratively trained based on the supervised contrastive learning loss function.
[0156] Based on the objective of self-supervised contrastive regression learning loss function, for example, in an embodiment of this application, a loss function for self-supervised contrastive learning can be defined as:
[0157]
[0158] Among them, L self Let I be the loss function corresponding to the i-th anchor sample used in this round of training iterations, I be the total number of samples used in this round of training iterations, P(i) be all positive samples corresponding to the i-th anchor sample, and r be the loss function corresponding to the anchor sample. i Let be the encoded feature of the i-th anchor sample. Let be the encoded feature of the p-th positive sample corresponding to the i-th anchor sample, Sim() be the similarity calculation function, and A(i) be all other pulse wave signal samples and enhanced samples except for the i-th anchor sample. Let τ be the encoding feature of the a-th sample among all samples except the i-th anchor sample, and τ be the temperature hyperparameter.
[0159] Located on the molecule It can continuously narrow the distance between the encoded features of positive samples, while the features located in the denominator... This allows for a more uniform distribution of the coding features of samples with different annotation information, thereby enabling the coding features of samples with different annotation information to retain as much useful information as possible.
[0160] In some embodiments, after iteratively training the feature extraction model, features can be extracted from multiple pulse wave signal samples and corresponding enhanced samples based on the trained feature extraction model. The extracted features and corresponding annotation information are then input into a supervised contrastive learning model for training. The trained feature extraction model and the supervised contrastive learning model are combined to obtain a relaxation recognition model.
[0161] In the above method, a novel self-supervised contrastive loss function is used, allowing multiple positive samples for each anchor point and permitting a certain threshold range for these positive samples. This combines the feature encoder and the supervised contrastive regression learning model, and iteratively trains the feature extraction model based on the self-supervised contrastive regression learning loss function. This improves the feature extraction performance of the model, enabling it to extract features from pulse wave signals more accurately and enhancing the precision of the relaxation recognition model. Furthermore, by setting the objective of the supervised contrastive regression learning loss function to narrow the distance between the encoded features of positive samples, an optimization objective can be set for the combined models, further improving the accuracy of model recognition.
[0162] In summary, this application acquires the pulse wave signal of the target object and identifies the relaxation index corresponding to the pulse wave signal based on a relaxation index recognition model pre-trained using a supervised contrastive learning method. Since the relaxation index can be obtained directly from the pulse wave analysis, this method can be implemented in portable relaxation detection devices and wearable devices (such as smartwatches and rings), providing a good option for intelligent prediction of relaxation states. The supervised contrastive learning method can iteratively train the relaxation index recognition model, improving its accuracy. In this method, performing a target relaxation operation based on the relaxation index helps reduce stress in the target object, and increasing the target object's relaxation index indicates a relaxed state, improving the user experience. By dividing the target pulse wave signal into N signal segments and obtaining the relaxation index for each segment, the target object can more clearly understand the specific values of the relaxation index corresponding to different segments, and combining the relaxation indices of the N signal segments reveals the trend of the relaxation index. Furthermore, the working parameters of the target relaxation operation can be adjusted based on the changing trend of the relaxation index, enabling relaxation feedback adjustment for the target object. This helps the target object relax more quickly and effectively, maintaining psychological and physical health. A novel self-supervised contrastive loss function allows multiple positive samples for each anchor point and permits a certain threshold range for these positive samples. By combining the feature encoder and the supervised contrastive regression learning model, and iteratively training the feature extraction model based on the self-supervised contrastive regression learning loss function, the feature extraction performance of the feature extraction model can be improved. This allows the trained feature extraction model to more accurately extract features from pulse wave signals, improving the accuracy of the relaxation recognition model. Moreover, by setting the objective of the supervised contrastive regression learning loss function to narrow the distance between the encoded features of positive samples, a model optimization objective can be set for the combined two models, further improving the accuracy of model recognition.
[0163] Figure 3 This is a schematic diagram of a relaxation degree recognition device provided in an embodiment of this application.
[0164] For example, such as Figure 3 As shown, the device 300 includes:
[0165] Acquisition module 301 is used to acquire the pulse wave signal of the target object;
[0166] Preprocessing module 302 is used to preprocess the pulse wave signal to obtain the target pulse wave signal;
[0167] The recognition module 303 is used to input the target pulse wave signal into the pre-trained relaxation recognition model to obtain the relaxation index corresponding to the target pulse wave signal; the relaxation recognition model is trained based on a supervised contrastive learning method.
[0168] Optionally, the device further includes a relaxation module, used to perform a target relaxation operation based on the relaxation index when the relaxation index is less than a preset threshold, so as to relax the target object.
[0169] In one possible implementation, the relaxation degree recognition model includes a feature extraction model and a supervised contrastive learning model. The recognition module 303 is specifically used to extract N signal segments from the target pulse wave signal in a preset unit through the feature extraction model and process them to obtain a feature map containing N signal segments; where N is greater than or equal to 1; and to analyze and compare the feature map through the supervised contrastive learning model to obtain the relaxation degree index of the N signal segments.
[0170] Optionally, the device further includes: an adjustment module, configured to, when the N signal segments include the current signal segment and the previous signal segment of the previous signal segment, define the relaxation index corresponding to the current signal segment as a first relaxation index and the relaxation index corresponding to the previous signal segment as a second relaxation index; and adjust the target operating parameter corresponding to the target relaxation operation based on the change of the first relaxation index relative to the second relaxation index; wherein, when the target relaxation operation is an audio relaxation operation, the target operating parameter is the volume; and when the target relaxation operation is a cooling relaxation operation, the target operating parameter is the temperature.
[0171] In one possible implementation, when the target relaxation operation is an audio relaxation operation, the adjustment module is specifically used to: decrease the volume of the played audio when the first relaxation index increases relative to the second relaxation index; and increase the volume of the played audio when the first relaxation index decreases relative to the second relaxation index or remains unchanged.
[0172] Optionally, the device further includes: a switching module, configured to continuously identify the relaxation index of the target object after increasing the volume of the played audio when the first relaxation index decreases or remains unchanged relative to the second relaxation index; determine the relaxation level of the current relaxation index when the relaxation level of the target object continues to decrease or remains unchanged within a preset time period; and select a target audio corresponding to the relaxation level from a pre-stored audio library for playback; the pre-stored audio library includes multiple audio files and their corresponding relaxation levels.
[0173] In one possible implementation, when the target relaxation operation is a cooling relaxation operation, the adjustment module is specifically used to: increase the temperature within a preset temperature range when the first relaxation index increases relative to the second relaxation index; and decrease the temperature within a preset temperature range when the first relaxation index decreases relative to the second relaxation index or remains unchanged.
[0174] In one possible implementation, the device is a first electronic device, and the relaxation module is specifically used to: detect a second electronic device connected to the first electronic device; when the first electronic device is detected to be connected to the second electronic device, control the second electronic device to perform a target relaxation operation based on a relaxation index; when the first electronic device is not detected to be unconnected to the second electronic device, establish a connection between the first electronic device and the second electronic device, and after the connection is established, control the second electronic device to perform a target relaxation operation based on the relaxation index.
[0175] Optionally, the device further includes: a model training module for acquiring multiple sample data; the sample data includes multiple pulse wave signal samples and their corresponding annotation information, the annotation information being used to characterize the relaxation index corresponding to the pulse wave signal samples; using a feature extraction model to extract encoded features for the multiple pulse wave signal samples respectively; inputting the encoded features extracted from the multiple pulse wave signal samples and the annotation information corresponding to the multiple pulse wave signal samples into a supervised contrastive learning model; in the supervised contrastive learning model, for any anchor sample specified among the multiple pulse wave signal samples, pulse wave signal samples whose difference between the annotation information and the annotation information of the anchor sample is within a preset difference range are determined as positive samples; using narrowing the distance between the encoded features of positive samples as the objective of the supervised contrastive learning loss function, the feature extraction model is iteratively trained.
[0176] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0177] For example, such as Figure 4 As shown, the electronic device 400 includes a memory 401 and a processor 402, wherein the memory 401 stores executable program code 4011, and the processor 402 is used to call and execute the executable program code 4011 to perform a relaxation recognition method.
[0178] This embodiment can divide the electronic device into functional modules according to the above method example. For example, each module can correspond to a separate functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware. It should be noted that the module division in this embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.
[0179] When each functional module is divided according to its corresponding function, the electronic device may include: a data acquisition module, a preprocessing module, an identification module, etc. It should be noted that all relevant content of each step involved in the above method embodiments can be referenced from the functional description of the corresponding functional module, and will not be repeated here.
[0180] The electronic device provided in this embodiment is used to perform the relaxation degree recognition method described above, and therefore can achieve the same effect as the above implementation method.
[0181] When using integrated units, the electronic device may include a processing module and a storage module. The processing module is used to control and manage the operation of the electronic device. The storage module is used to support the execution of program code and data by the electronic device.
[0182] The processing module may be a processor or a controller, which can implement or execute various exemplary logic blocks, modules, and circuits as disclosed in this application. The processor may also be a combination of computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and microprocessors, etc., and the storage module may be a memory.
[0183] This embodiment also provides a computer-readable storage medium storing computer program code. When the computer program code is run on a computer, the computer executes the aforementioned related method steps to implement a relaxation recognition method in the above embodiment.
[0184] This embodiment also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned related steps to implement a relaxation recognition method as described in the above embodiment.
[0185] In addition, the electronic device provided in the embodiments of this application may specifically be a chip, component or module. The electronic device may include a connected processor and a memory. The memory is used to store instructions. When the electronic device is running, the processor may call and execute the instructions to make the chip perform a relaxation recognition method in the above embodiments.
[0186] In this embodiment, the electronic device, computer-readable storage medium, computer program product or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects of the corresponding methods provided above, and will not be repeated here.
[0187] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0188] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0189] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for recognizing relaxation level, characterized in that, The method includes: Acquire pulse wave signals from the target object; The pulse wave signal is preprocessed to obtain the target pulse wave signal; The target pulse wave signal is input into a pre-trained relaxation recognition model to obtain the relaxation index corresponding to the target pulse wave signal; the relaxation recognition model is trained based on a supervised contrastive learning method. The relaxation level recognition model includes a feature extraction model and a supervised contrastive learning model. The step of inputting the target pulse wave signal into the pre-trained relaxation level recognition model to obtain the relaxation level index corresponding to the target pulse wave signal includes: The feature extraction model extracts N signal segments from the target pulse wave signal in preset units; a two-dimensional data matrix is generated based on the N signal segments, and the standard deviation of the data matrix is calculated column by column to generate a standard deviation vector representing each column of the data matrix; the encoded waveform is determined based on the data matrix and the standard deviation, and the sine and cosine codes of the standard deviation vector are determined; the encoded waveform is concatenated row by row with the sine and cosine codes of the standard deviation vector to obtain a feature map containing the N signal segments; where N is greater than or equal to 1. The supervised contrastive learning model is used to analyze and compare the feature maps to obtain the relaxation index of the N signal segments; the relaxation index is used to characterize the current relaxation level of the target object.
2. The method according to claim 1, characterized in that, After obtaining the relaxation index corresponding to the target pulse wave signal, the method further includes: Determine whether the relaxation index is less than a preset threshold; When the relaxation index is less than the preset threshold, a target relaxation operation is performed based on the relaxation index to relax the target object.
3. The method according to claim 1, characterized in that, When the N signal segments include the current signal segment and the previous signal segment of the current signal segment, the relaxation index corresponding to the current signal segment is the first relaxation index, and the relaxation index corresponding to the previous signal segment is the second relaxation index. After performing the target relaxation operation based on the relaxation index, the method further includes: Based on the change of the first relaxation index relative to the second relaxation index, the target working parameters corresponding to the target relaxation operation are adjusted; Wherein, when the target relaxation operation is an audio relaxation operation, the target working parameter is volume; When the target relaxation operation is a cooling relaxation operation, the target operating parameter is temperature.
4. The method according to claim 3, characterized in that, When the target relaxation operation is an audio relaxation operation, adjusting the target working parameters corresponding to the target relaxation operation based on the change of the first relaxation index relative to the second relaxation index includes: When the first relaxation index increases relative to the second relaxation index, the volume of the played audio is reduced; When the first relaxation index decreases or remains unchanged relative to the second relaxation index, the volume of the audio being played is increased.
5. The method according to claim 4, characterized in that, When the first relaxation index decreases or remains unchanged relative to the second relaxation index, after increasing the volume of the played audio, the method further includes: Continuously identify the relaxation index of the target object; When the relaxation level of the target object continues to decrease or remains unchanged within a preset time period, the relaxation level of the current relaxation index is determined. Select the target audio corresponding to the relaxation level from the pre-stored audio library and play it; the pre-stored audio library includes multiple audio files and their corresponding relaxation levels.
6. The method according to claim 3, characterized in that, When the target relaxation operation is a cooling relaxation operation, adjusting the target working parameters corresponding to the target relaxation operation based on the change of the first relaxation index relative to the second relaxation index includes: When the first relaxation index increases relative to the second relaxation index, the temperature is increased within a preset temperature range; When the first relaxation index decreases or remains unchanged relative to the second relaxation index, the temperature is reduced within the preset temperature range.
7. The method according to claim 2, characterized in that, The method is applied to a first electronic device, wherein performing a targeted relaxation operation based on the relaxation index includes: Detect the second electronic device connected to the first electronic device; When the first electronic device is detected to be connected to the second electronic device, the second electronic device is controlled to perform a target relaxation operation based on the relaxation index. When it is not detected that the first electronic device is not connected to the second electronic device, a connection is established between the first electronic device and the second electronic device, and after the connection is established, the second electronic device is controlled to perform the target relaxation operation based on the relaxation index.
8. The method according to any one of claims 1 to 7, characterized in that, The relaxation level recognition model includes a feature extraction model and a supervised contrastive learning model. Before inputting the target pulse wave signal into the pre-trained relaxation level recognition model, the method further includes: Acquire multiple sample data; the sample data includes multiple pulse wave signal samples and their corresponding annotation information, the annotation information being used to characterize the relaxation index corresponding to the pulse wave signal sample; The feature extraction model is used to extract encoded features for the multiple pulse wave signal samples respectively; The encoded features extracted from the multiple pulse wave signal samples and the corresponding annotation information of the multiple pulse wave signal samples are input into the supervised contrastive learning model; In the supervised contrastive learning model, for any anchor sample specified among the multiple pulse wave signal samples, pulse wave signal samples whose difference between the annotation information and the annotation information of the anchor sample is within a preset difference range are determined as positive samples. The feature extraction model is iteratively trained by using the goal of narrowing the distance between the encoded features of the positive samples as the objective of the supervised contrastive learning loss function.
9. A device for recognizing relaxation level, characterized in that, The device includes: The acquisition module is used to acquire the pulse wave signal of the target object; The preprocessing module is used to preprocess the pulse wave signal to obtain the target pulse wave signal; The recognition module is used to input the target pulse wave signal into a pre-trained relaxation recognition model to obtain the relaxation index corresponding to the target pulse wave signal; the relaxation recognition model is trained based on a supervised contrastive learning method. The relaxation level recognition model includes a feature extraction model and a supervised contrastive learning model. The recognition module is specifically used for: extracting N signal segments from the target pulse wave signal using the feature extraction model at preset units; generating a two-dimensional data matrix based on the N signal segments, and calculating the standard deviation of each column of the data matrix to generate a standard deviation vector representing each column; determining the encoded waveform based on the data matrix and the standard deviation, and determining the sine and cosine codes of the standard deviation vector; concatenating the encoded waveform with the sine and cosine codes of the standard deviation vector row-wise to obtain a feature map containing the N signal segments, where N is greater than or equal to 1; and analyzing and comparing the feature map using the supervised contrastive learning model to obtain a relaxation level index for the N signal segments; the relaxation level index is used to characterize the current relaxation level of the target object.
10. An electronic device, characterized in that, The electronic device includes: Memory, used to store executable program code; A processor for calling and running the executable program code from the memory, causing the electronic device to perform the method as described in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed, implements the method as described in any one of claims 1 to 8.