mirror of
https://github.com/Project-Babble/ProjectBabble.git
synced 2026-11-27 12:26:27 -08:00
Merge pull request #51 from SnuffSocket/misc-branch
Fix: Misc fixes/changes
This commit is contained in:
12 files changed
+18
-16
No files matched your search
@@ -15,7 +15,7 @@ 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)
|
||||
|
||||
@@ -92,7 +92,7 @@ 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.runtime in ("ONNX", "Default (ONNX)"): # ONNX
|
||||
if self.use_gpu:
|
||||
provider = "DmlExecutionProvider"
|
||||
else:
|
||||
|
||||
@@ -215,10 +215,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 (
|
||||
|
||||
@@ -63,7 +63,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,
|
||||
|
||||
@@ -91,6 +91,8 @@ class BabbleConfig(BaseModel):
|
||||
BabbleConfig(**json.load(settings_file))
|
||||
shutil.copy(CONFIG_FILE_NAME, BACKUP_CONFIG_FILE_NAME)
|
||||
# print("Backed up settings files.") # Comment out because it's too loud.
|
||||
except shutil.SameFileError:
|
||||
pass
|
||||
except json.JSONDecodeError:
|
||||
# No backup because the saved settings file is broken.
|
||||
pass
|
||||
|
||||
@@ -336,4 +336,4 @@ class SettingsWidget:
|
||||
if changed:
|
||||
self.main_config.save()
|
||||
|
||||
self.osc_queue.put((Tab.SETTINGS))
|
||||
self.osc_queue.put(Tab.SETTINGS)
|
||||
@@ -15,7 +15,7 @@ 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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -31,9 +31,7 @@ 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.
|
||||
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)
|
||||
|
||||
# The filtered derivative of the signal.
|
||||
|
||||
+4
-3
@@ -100,9 +100,10 @@ class VRChatOSC:
|
||||
return
|
||||
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)
|
||||
|
||||
|
||||
@@ -135,7 +136,7 @@ class VRChatOSCReceiver:
|
||||
pass
|
||||
|
||||
def recalibrate_mouth(self, address, osc_value):
|
||||
if type(osc_value) != bool:
|
||||
if not isinstance(osc_value, bool):
|
||||
return # just incase we get anything other than bool
|
||||
if osc_value:
|
||||
for cam in self.cams:
|
||||
|
||||
@@ -13,6 +13,7 @@ class CamId(IntEnum):
|
||||
class cal:
|
||||
|
||||
def __init__(self):
|
||||
self.calibration_frame_counter = None
|
||||
self.calibrated_array = None
|
||||
self.raw_array = None
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ def list_camera_names():
|
||||
|
||||
|
||||
def list_serial_ports():
|
||||
print("DEBUG: Listed Serial Ports")
|
||||
#print("DEBUG: Listed Serial Ports")
|
||||
""" Lists serial port names
|
||||
|
||||
:raises EnvironmentError:
|
||||
|
||||
Reference in new issue
Block a user