mirror of
https://github.com/Project-Babble/ProjectBabble.git
synced 2026-11-20 09:01:16 -08:00
Replaced Neutral Calibration
This commit is contained in:
1 parent
3f4d23a78a
commit
1b5e5b361b
8 files changed
+57
-37
No files matched your search
Binary file not shown.
@@ -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]:
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -1,6 +1,5 @@
|
||||
onnxruntime
|
||||
onnxruntime-gpu
|
||||
onnxruntime-openvino
|
||||
onnxruntime-directml
|
||||
opencv_python
|
||||
Pillow
|
||||
pysimplegui
|
||||
|
||||
+2
-3
@@ -1,9 +1,8 @@
|
||||
onnxruntime
|
||||
onnxruntime-gpu
|
||||
onnxruntime-openvino
|
||||
onnxruntime-directml
|
||||
opencv_python
|
||||
Pillow
|
||||
pysimplegui
|
||||
PySimpleGUI
|
||||
python_osc
|
||||
torch
|
||||
torchvision
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in new issue
Block a user