diff --git a/BabbleApp/Models/EFFB0MVE99TIMM/onnx/model.onnx b/BabbleApp/Models/EFFB0MVE99TIMM/onnx/model.onnx new file mode 100644 index 0000000..043acba Binary files /dev/null and b/BabbleApp/Models/EFFB0MVE99TIMM/onnx/model.onnx differ diff --git a/BabbleApp/babbleapp.py b/BabbleApp/babbleapp.py index 08a3f1c..ccb5e3c 100644 --- a/BabbleApp/babbleapp.py +++ b/BabbleApp/babbleapp.py @@ -161,7 +161,6 @@ def main(): ], ] - if config.cam_display_id in [Tab.CAM]: cams[0].start() if config.cam_display_id in [Tab.SETTINGS]: diff --git a/BabbleApp/config.py b/BabbleApp/config.py index ed55fa7..4abc2ea 100644 --- a/BabbleApp/config.py +++ b/BabbleApp/config.py @@ -32,7 +32,7 @@ class BabbleSettingsConfig(BaseModel): gui_ROSC: bool = False gui_osc_location: str = "" gui_multiply: int = 1 - gui_model_file: str = 'Models/ENEXTXXE100D4/' + gui_model_file: str = 'Models/EFFB0MVE99TIMM/' gui_runtime: str = "ONNX" gui_use_gpu: bool = False gui_gpu_index: int = 0 diff --git a/BabbleApp/osc_calibrate_filter.py b/BabbleApp/osc_calibrate_filter.py index f7c3b93..6186a4c 100644 --- a/BabbleApp/osc_calibrate_filter.py +++ b/BabbleApp/osc_calibrate_filter.py @@ -1,4 +1,5 @@ import numpy as np +from math import log from enum import IntEnum from utils.misc_utils import PlaySound, SND_FILENAME, SND_ASYNC @@ -7,43 +8,65 @@ class CamId(IntEnum): SETTINGS = 1 class cal(): + def cal_osc(self, array): #print(self.calibration_frame_counter) if self.calibration_frame_counter == 0: + if not self.config.use_n_calibration: + self.calibration_frame_counter = None + values = np.array(self.val_list) - self.calibration_frame_counter = None - values = np.array(self.val_list) + # Initialize the min_max_array with shape (2, num_outputs) + num_outputs = values.shape[1] + self.min_max_array = np.zeros((2, num_outputs)) - # Initialize the min_max_array with shape (2, num_outputs) - num_outputs = values.shape[1] - self.min_max_array = np.zeros((2, num_outputs)) + # Iterate over each output index + for i in range(num_outputs): + # Calculate the lower and upper thresholds for the current index + lower_threshold = np.percentile(values[:, i], 1) + upper_threshold = np.percentile(values[:, i], 99) + + # Filter out values within the thresholds for the current index + filtered_values = values[(values[:, i] >= lower_threshold) & (values[:, i] <= upper_threshold), i] + + # Extract the minimum and maximum values for the current index + min_value = np.min(filtered_values) + max_value = np.max(filtered_values) + + # Store the min and max values in the min_max_array + self.min_max_array[0, i] = min_value + self.min_max_array[1, i] = max_value + self.settings.calib_array = np.array2string(self.min_max_array, separator=',') + self.config_class.save() + print("[INFO] Calibration completed.") + + PlaySound('Audio/completed.wav', SND_FILENAME | SND_ASYNC) + + if self.config.use_n_calibration: + self.calibration_frame_counter = None + values = np.array(self.val_list) + deadzone_value = -0.01 # Maybe adjust from app???? + # Initialize the min_max_array with shape (2, num_outputs) + num_outputs = values.shape[1] + self.min_max_array = np.zeros((2, num_outputs)) + lower_threshold = np.clip([np.mean(values, axis = 0) + deadzone_value], 0, 1) + upper_threshold = np.ones((1, num_outputs)) # We don't need to adjust the max values. + print(lower_threshold) + print(upper_threshold) + self.min_max_array = np.array([lower_threshold, upper_threshold]) + self.settings.calib_array = np.array2string(self.min_max_array, separator=',') + self.config_class.save() + print("[INFO] Calibration completed.") - # Iterate over each output index - for i in range(num_outputs): - # Calculate the lower and upper thresholds for the current index - lower_threshold = np.percentile(values[:, i], 1) - upper_threshold = np.percentile(values[:, i], 99) - # Filter out values within the thresholds for the current index - filtered_values = values[(values[:, i] >= lower_threshold) & (values[:, i] <= upper_threshold), i] - # Extract the minimum and maximum values for the current index - min_value = np.min(filtered_values) - max_value = np.max(filtered_values) - # Store the min and max values in the min_max_array - self.min_max_array[0, i] = min_value - self.min_max_array[1, i] = max_value - self.settings.calib_array = np.array2string(self.min_max_array, separator=',') - self.config_class.save() - print("[INFO] Calibration completed.") - PlaySound('Audio/completed.wav', SND_FILENAME | SND_ASYNC) elif self.calibration_frame_counter != None: - self.val_list.append(array) self.calibration_frame_counter -= 1 + if self.settings.calib_array is not None and self.config.use_calibration: self.min_max_array = np.fromstring(self.settings.calib_array.replace('[', '').replace(']', ''), sep=',') @@ -70,10 +93,10 @@ class cal(): for i, value in enumerate(array): min_value = self.min_max_array[0, i] - calibrated_value = (value - min_value) / (1.0 - min_value) calibrated_array[i] = calibrated_value array = calibrated_array - + print(array[4]) + #array[4] = log((np.clip(array[4]*10,0,10))+1.0, 11) Log Filter: Move to filter system. return np.clip(array,0,1) # Clamp outputs between 0-1 \ No newline at end of file diff --git a/BabbleApp/requirements.txt b/BabbleApp/requirements.txt index 216de48..20e8332 100644 --- a/BabbleApp/requirements.txt +++ b/BabbleApp/requirements.txt @@ -1,6 +1,5 @@ onnxruntime -onnxruntime-gpu -onnxruntime-openvino +onnxruntime-directml opencv_python Pillow pysimplegui diff --git a/requirements.txt b/requirements.txt index 216de48..7284cad 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,8 @@ onnxruntime -onnxruntime-gpu -onnxruntime-openvino +onnxruntime-directml opencv_python Pillow -pysimplegui +PySimpleGUI python_osc torch torchvision diff --git a/scripts/example_build_app_and_installer.bat b/scripts/example_build_app_and_installer.bat index 5c92212..97b3eb5 100644 --- a/scripts/example_build_app_and_installer.bat +++ b/scripts/example_build_app_and_installer.bat @@ -1,8 +1,8 @@ :: Example script to auto build app and make an installer :: File paths will all need to be updated to your setup -cd C:\Users\epicm\OneDrive\Documents\Github\ProjectBabble\BabbleApp +cd X:\Documents\GitHub\ProjectBabble\BabbleApp pyinstaller babbleapp.spec --noconfirm -cd C:\Users\epicm\OneDrive\Desktop\build +cd X:\Documents\GitHub\ProjectBabble\BabbleApp cd 'C:\Program Files (x86)\Inno Setup 6' ./ISCC X:\Documents\GitHub\ProjectBabble\scripts\installer.iss ::cls diff --git a/scripts/installer.iss b/scripts/installer.iss index f57ffe1..74e315f 100644 --- a/scripts/installer.iss +++ b/scripts/installer.iss @@ -24,7 +24,7 @@ OutputDir=C:\Users\epicm\OneDrive\Desktop\build ; Uncomment the following line to run in non administrative install mode (install for current user only.) ;PrivilegesRequired=lowest OutputBaseFilename=Project_Babble-Setup -SetupIconFile=C:\Users\epicm\OneDrive\Documents\Github\ProjectBabble\BabbleApp\Images\logo.ico +SetupIconFile=X:\Documents\GitHub\ProjectBabble\BabbleApp\Images\logo.ico Compression=lzma/ultra64 SolidCompression=yes @@ -37,8 +37,8 @@ Name: "english"; MessagesFile: "compiler:Default.isl" Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; [Files] -Source: "C:\Users\epicm\OneDrive\Documents\Github\ProjectBabble\BabbleApp\dist\Babble_App\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion -Source: "C:\Users\epicm\OneDrive\Documents\Github\ProjectBabble\BabbleApp\dist\Babble_App\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "X:\Documents\GitHub\ProjectBabble\BabbleApp\dist\Babble_App\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion +Source: "X:\Documents\GitHub\ProjectBabble\BabbleApp\dist\Babble_App\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs ; NOTE: Don't use "Flags: ignoreversion" on any shared system files [Dirs]