Skip to content

Commit 1b5e5b3

Browse files
Replaced Neutral Calibration
1 parent 3f4d23a commit 1b5e5b3

File tree

8 files changed

+57
-37
lines changed

8 files changed

+57
-37
lines changed
22.6 MB
Binary file not shown.

BabbleApp/babbleapp.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ def main():
161161
],
162162
]
163163

164-
165164
if config.cam_display_id in [Tab.CAM]:
166165
cams[0].start()
167166
if config.cam_display_id in [Tab.SETTINGS]:

BabbleApp/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class BabbleSettingsConfig(BaseModel):
3232
gui_ROSC: bool = False
3333
gui_osc_location: str = ""
3434
gui_multiply: int = 1
35-
gui_model_file: str = 'Models/ENEXTXXE100D4/'
35+
gui_model_file: str = 'Models/EFFB0MVE99TIMM/'
3636
gui_runtime: str = "ONNX"
3737
gui_use_gpu: bool = False
3838
gui_gpu_index: int = 0

BabbleApp/osc_calibrate_filter.py

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import numpy as np
2+
from math import log
23
from enum import IntEnum
34
from utils.misc_utils import PlaySound, SND_FILENAME, SND_ASYNC
45

@@ -7,43 +8,65 @@ class CamId(IntEnum):
78
SETTINGS = 1
89

910
class cal():
11+
1012
def cal_osc(self, array):
1113
#print(self.calibration_frame_counter)
1214
if self.calibration_frame_counter == 0:
15+
if not self.config.use_n_calibration:
16+
self.calibration_frame_counter = None
17+
values = np.array(self.val_list)
1318

14-
self.calibration_frame_counter = None
15-
values = np.array(self.val_list)
19+
# Initialize the min_max_array with shape (2, num_outputs)
20+
num_outputs = values.shape[1]
21+
self.min_max_array = np.zeros((2, num_outputs))
1622

17-
# Initialize the min_max_array with shape (2, num_outputs)
18-
num_outputs = values.shape[1]
19-
self.min_max_array = np.zeros((2, num_outputs))
23+
# Iterate over each output index
24+
for i in range(num_outputs):
25+
# Calculate the lower and upper thresholds for the current index
26+
lower_threshold = np.percentile(values[:, i], 1)
27+
upper_threshold = np.percentile(values[:, i], 99)
2028

21-
# Iterate over each output index
22-
for i in range(num_outputs):
23-
# Calculate the lower and upper thresholds for the current index
24-
lower_threshold = np.percentile(values[:, i], 1)
25-
upper_threshold = np.percentile(values[:, i], 99)
29+
# Filter out values within the thresholds for the current index
30+
filtered_values = values[(values[:, i] >= lower_threshold) & (values[:, i] <= upper_threshold), i]
2631

27-
# Filter out values within the thresholds for the current index
28-
filtered_values = values[(values[:, i] >= lower_threshold) & (values[:, i] <= upper_threshold), i]
32+
# Extract the minimum and maximum values for the current index
33+
min_value = np.min(filtered_values)
34+
max_value = np.max(filtered_values)
35+
36+
# Store the min and max values in the min_max_array
37+
self.min_max_array[0, i] = min_value
38+
self.min_max_array[1, i] = max_value
39+
self.settings.calib_array = np.array2string(self.min_max_array, separator=',')
40+
self.config_class.save()
41+
print("[INFO] Calibration completed.")
42+
43+
PlaySound('Audio/completed.wav', SND_FILENAME | SND_ASYNC)
44+
45+
if self.config.use_n_calibration:
46+
self.calibration_frame_counter = None
47+
values = np.array(self.val_list)
48+
deadzone_value = -0.01 # Maybe adjust from app????
49+
# Initialize the min_max_array with shape (2, num_outputs)
50+
num_outputs = values.shape[1]
51+
self.min_max_array = np.zeros((2, num_outputs))
52+
lower_threshold = np.clip([np.mean(values, axis = 0) + deadzone_value], 0, 1)
53+
upper_threshold = np.ones((1, num_outputs)) # We don't need to adjust the max values.
54+
print(lower_threshold)
55+
print(upper_threshold)
56+
self.min_max_array = np.array([lower_threshold, upper_threshold])
57+
self.settings.calib_array = np.array2string(self.min_max_array, separator=',')
58+
self.config_class.save()
59+
print("[INFO] Calibration completed.")
2960

30-
# Extract the minimum and maximum values for the current index
31-
min_value = np.min(filtered_values)
32-
max_value = np.max(filtered_values)
3361

34-
# Store the min and max values in the min_max_array
35-
self.min_max_array[0, i] = min_value
36-
self.min_max_array[1, i] = max_value
37-
self.settings.calib_array = np.array2string(self.min_max_array, separator=',')
38-
self.config_class.save()
39-
print("[INFO] Calibration completed.")
4062

41-
PlaySound('Audio/completed.wav', SND_FILENAME | SND_ASYNC)
4263

43-
elif self.calibration_frame_counter != None:
4464

65+
66+
elif self.calibration_frame_counter != None:
4567
self.val_list.append(array)
4668
self.calibration_frame_counter -= 1
69+
4770

4871
if self.settings.calib_array is not None and self.config.use_calibration:
4972
self.min_max_array = np.fromstring(self.settings.calib_array.replace('[', '').replace(']', ''), sep=',')
@@ -70,10 +93,10 @@ def cal_osc(self, array):
7093
for i, value in enumerate(array):
7194
min_value = self.min_max_array[0, i]
7295

73-
7496
calibrated_value = (value - min_value) / (1.0 - min_value)
7597

7698
calibrated_array[i] = calibrated_value
7799
array = calibrated_array
78-
100+
print(array[4])
101+
#array[4] = log((np.clip(array[4]*10,0,10))+1.0, 11) Log Filter: Move to filter system.
79102
return np.clip(array,0,1) # Clamp outputs between 0-1

BabbleApp/requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
onnxruntime
2-
onnxruntime-gpu
3-
onnxruntime-openvino
2+
onnxruntime-directml
43
opencv_python
54
Pillow
65
pysimplegui

requirements.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
onnxruntime
2-
onnxruntime-gpu
3-
onnxruntime-openvino
2+
onnxruntime-directml
43
opencv_python
54
Pillow
6-
pysimplegui
5+
PySimpleGUI
76
python_osc
87
torch
98
torchvision

scripts/example_build_app_and_installer.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
:: Example script to auto build app and make an installer
22
:: File paths will all need to be updated to your setup
3-
cd C:\Users\epicm\OneDrive\Documents\Github\ProjectBabble\BabbleApp
3+
cd X:\Documents\GitHub\ProjectBabble\BabbleApp
44
pyinstaller babbleapp.spec --noconfirm
5-
cd C:\Users\epicm\OneDrive\Desktop\build
5+
cd X:\Documents\GitHub\ProjectBabble\BabbleApp
66
cd 'C:\Program Files (x86)\Inno Setup 6'
77
./ISCC X:\Documents\GitHub\ProjectBabble\scripts\installer.iss
88
::cls

scripts/installer.iss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ OutputDir=C:\Users\epicm\OneDrive\Desktop\build
2424
; Uncomment the following line to run in non administrative install mode (install for current user only.)
2525
;PrivilegesRequired=lowest
2626
OutputBaseFilename=Project_Babble-Setup
27-
SetupIconFile=C:\Users\epicm\OneDrive\Documents\Github\ProjectBabble\BabbleApp\Images\logo.ico
27+
SetupIconFile=X:\Documents\GitHub\ProjectBabble\BabbleApp\Images\logo.ico
2828
Compression=lzma/ultra64
2929

3030
SolidCompression=yes
@@ -37,8 +37,8 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
3737
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}";
3838

3939
[Files]
40-
Source: "C:\Users\epicm\OneDrive\Documents\Github\ProjectBabble\BabbleApp\dist\Babble_App\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
41-
Source: "C:\Users\epicm\OneDrive\Documents\Github\ProjectBabble\BabbleApp\dist\Babble_App\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
40+
Source: "X:\Documents\GitHub\ProjectBabble\BabbleApp\dist\Babble_App\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
41+
Source: "X:\Documents\GitHub\ProjectBabble\BabbleApp\dist\Babble_App\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
4242
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
4343

4444
[Dirs]

0 commit comments

Comments
 (0)