Fix: Misc fixes/changes

This commit is contained in:
SnuffSocket committed 2024-10-15 02:47:48 +03:00
1 parent fc56aba7ef
commit e85073a51d
10 files changed
+32 -32

No files matched your search

+1 -1
View File
@@ -13,7 +13,7 @@ from threading import Thread
from one_euro_filter import OneEuroFilter
def run_model(self):
if self.runtime == "ONNX" or self.runtime == "Default (ONNX)":
if self.runtime in ("ONNX", "Default (ONNX)"):
frame = cv2.resize(self.current_image_gray, (256, 256))
frame = transforms.to_tensor(frame)
frame = transforms.unsqueeze(frame,0)
+3 -3
View File
@@ -90,10 +90,10 @@ class BabbleProcessor:
self.opts = ort.SessionOptions()
self.opts.intra_op_num_threads = settings.gui_inference_threads
self.opts.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL
if self.runtime == "ONNX" or self.runtime == "Default (ONNX)": # ONNX
if self.use_gpu: provider = 'DmlExecutionProvider'
if self.runtime in ("ONNX", "Default (ONNX)"): # ONNX
if self.use_gpu: provider = 'DmlExecutionProvider'
else: provider = "CPUExecutionProvider" # Build onnxruntime to get both DML and OpenVINO
self.sess = ort.InferenceSession(f'{self.model}onnx/model.onnx', self.opts, providers=[provider], provider_options=[{'device_id': self.gpu_index}])
self.sess = ort.InferenceSession(f'{self.model}onnx/model.onnx', self.opts, providers=[provider], provider_options=[{'device_id': self.gpu_index}])
self.input_name = self.sess.get_inputs()[0].name
self.output_name = self.sess.get_outputs()[0].name
try:
+2 -2
View File
@@ -203,10 +203,10 @@ def main():
# GUI Render loop
while True:
# First off, check for any events from the GUI
event, values = window.read(timeout=2)
event, values = window.read(timeout=30)
# If we're in either mode and someone hits q, quit immediately
if event == "Exit" or event == sg.WIN_CLOSED:
if event in ("Exit", sg.WIN_CLOSED):
for cam in cams: #yes we only have one cam page but im just gonna leave this incase
cam.stop()
cancellation_event.set()
+1 -1
View File
@@ -54,7 +54,7 @@ class CameraWidget:
self.capture_event = Event()
self.capture_queue = Queue(maxsize=2)
self.roi_queue = Queue(maxsize=2)
self.image_queue = Queue(maxsize=500)
self.image_queue = Queue(maxsize=4)
self.babble_cnn = BabbleProcessor(
self.config,
+1 -1
View File
@@ -249,4 +249,4 @@ class SettingsWidget:
if changed:
self.main_config.save()
self.osc_queue.put((Tab.SETTINGS))
self.osc_queue.put(Tab.SETTINGS)
+1 -1
View File
@@ -13,7 +13,7 @@ from threading import Thread
from one_euro_filter import OneEuroFilter
def run_model(self): # Replace transforms n shit for the pfld model
if self.runtime == "ONNX" or self.runtime == "Default (ONNX)":
if self.runtime in ("ONNX", "Default (ONNX)"):
frame = cv2.resize(self.current_image_gray, (256, 256))
frame = transforms.to_tensor(frame)
frame = transforms.unsqueeze(frame,0)
+2 -2
View File
@@ -92,8 +92,8 @@ class LandmarkProcessor:
self.opts = ort.SessionOptions()
self.opts.intra_op_num_threads = settings.gui_inference_threads
self.opts.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL
if self.runtime == "ONNX" or self.runtime == "Default (ONNX)": # ONNX
if self.use_gpu: provider = 'DmlExecutionProvider'
if self.runtime in ("ONNX", "Default (ONNX)"): # ONNX
if self.use_gpu: provider = 'DmlExecutionProvider'
else: provider = "CPUExecutionProvider" # Build onnxruntime to get both DML and OpenVINO
self.sess = ort.InferenceSession(f'{self.model}onnx/model.onnx', self.opts, providers=[provider, ], provider_options=[{'device_id': self.gpu_index}]) # Load Babble CNN until PFLD has been converted
self.input_name = self.sess.get_inputs()[0].name
+14 -14
View File
@@ -32,21 +32,21 @@ class OneEuroFilter:
t = time()
t_e = t - self.t_prev
if t_e != 0.0: #occasionally when switching to algos this becomes zero causing divide by zero errors crashing the filter.
t_e = np.full(x.shape, t_e)
t_e = np.full(x.shape, t_e)
# The filtered derivative of the signal.
a_d = smoothing_factor(t_e, self.d_cutoff)
dx = (x - self.x_prev) / t_e
dx_hat = exponential_smoothing(a_d, dx, self.dx_prev)
# The filtered derivative of the signal.
a_d = smoothing_factor(t_e, self.d_cutoff)
dx = (x - self.x_prev) / t_e
dx_hat = exponential_smoothing(a_d, dx, self.dx_prev)
# The filtered signal.
cutoff = self.min_cutoff + self.beta * np.abs(dx_hat)
a = smoothing_factor(t_e, cutoff)
x_hat = exponential_smoothing(a, x, self.x_prev)
# The filtered signal.
cutoff = self.min_cutoff + self.beta * np.abs(dx_hat)
a = smoothing_factor(t_e, cutoff)
x_hat = exponential_smoothing(a, x, self.x_prev)
# Memorize the previous values.
self.x_prev = x_hat
self.dx_prev = dx_hat
self.t_prev = t
# Memorize the previous values.
self.x_prev = x_hat
self.dx_prev = dx_hat
self.t_prev = t
return x_hat
return x_hat
+6 -7
View File
@@ -82,15 +82,13 @@ class VRChatOSC:
self.cam = Tab.CAM
def run(self):
while True:
if self.cancellation_event.is_set():
print("\033[94m[INFO] Exiting OSC Queue\033[0m")
return
while not self.cancellation_event.is_set():
try:
(self.cam_id, cam_info) = self.msg_queue.get(block=True, timeout=0.1)
except:
except TypeError:
continue
except queue.Empty:
continue
output_osc(cam_info.output, self)
@@ -114,7 +112,8 @@ class VRChatOSCReceiver:
pass
def recalibrate_mouth(self, address, osc_value):
if type(osc_value) != bool: return # just incase we get anything other than bool
if not isinstance(osc_value, bool):
return # just incase we get anything other than bool
if osc_value:
for cam in self.cams:
cam.babble_cnn.calibration_frame_counter = 300
+1
View File
@@ -10,6 +10,7 @@ class CamId(IntEnum):
class cal():
def __init__(self):
self.calibration_frame_counter = None
self.calibrated_array = None
self.raw_array = None