Skip to content

Commit 5bf3973

Browse files
Merge pull request #94 from dfgHiatus/feat/freesimplegui
(feat) Add FreeSimpleGUI, package manager unification, bugfixes
2 parents 22c7093 + ddca4bf commit 5bf3973

20 files changed

+132
-1122
lines changed

BabbleApp/algo_settings_widget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import PySimpleGUI as sg
1+
import FreeSimpleGUI as sg
22
from config import BabbleSettingsConfig
33
from osc import Tab
44
from queue import Queue

BabbleApp/babble_model_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
os.environ["OMP_NUM_THREADS"] = "1"
55
import onnxruntime as ort
66
import time
7-
import PySimpleGUI as sg
7+
import FreeSimpleGUI as sg
88
import cv2
99
import numpy as np
1010
from pythonosc import udp_client

BabbleApp/babble_processor.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import cv2
1212
from enum import Enum
1313
from one_euro_filter import OneEuroFilter
14-
from utils.misc_utils import PlaySound, SND_FILENAME, SND_ASYNC
14+
from utils.misc_utils import playSound, onnx_providers
1515
import importlib
1616
from osc import Tab
1717
from osc_calibrate_filter import *
@@ -37,7 +37,7 @@ def wrapper(*args, **kwargs):
3737
async def delayed_setting_change(setting, value):
3838
await asyncio.sleep(5)
3939
setting = value
40-
PlaySound("Audio/completed.wav", SND_FILENAME | SND_ASYNC)
40+
playSound(os.path.join("Audio", "completed.wav"))
4141

4242

4343
class BabbleProcessor:
@@ -102,15 +102,14 @@ def __init__(
102102
self.opts.enable_mem_pattern = False
103103
if self.runtime in ("ONNX", "Default (ONNX)"): # ONNX
104104
if self.use_gpu:
105-
provider = "DmlExecutionProvider"
105+
provider = onnx_providers
106106
else:
107-
provider = "CPUExecutionProvider" # Build onnxruntime to get both DML and OpenVINO
107+
provider = [onnx_providers[-1]]
108108
try:
109109
self.sess = ort.InferenceSession(
110110
f"{self.model}/onnx/model.onnx",
111111
self.opts,
112-
providers=[provider],
113-
provider_options=[{"device_id": self.gpu_index}],
112+
providers=provider,
114113
)
115114
except: # Load default model if we can't find the specified model
116115
print(

BabbleApp/babbleapp.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"""
1818

1919
import os
20-
import PySimpleGUI as sg
20+
import FreeSimpleGUI as sg
2121
import queue
2222
import requests
2323
import threading
@@ -33,13 +33,13 @@
3333
from algo_settings_widget import AlgoSettingsWidget
3434
from calib_settings_widget import CalibSettingsWidget
3535
from notification_manager import NotificationManager
36-
from utils.misc_utils import EnsurePath, is_nt, bg_color_highlight, bg_color_clear
36+
from utils.misc_utils import ensurePath, os_type, bg_color_highlight, bg_color_clear
3737
from lang_manager import LocaleStringManager as lang
3838
from logger import setup_logging
3939

4040
winmm = None
4141

42-
if is_nt:
42+
if os_type == 'Windows':
4343
try:
4444
from ctypes import windll
4545
winmm = windll.winmm
@@ -99,7 +99,7 @@ async def check_for_updates(config, notification_manager):
9999
)
100100

101101
async def async_main():
102-
EnsurePath()
102+
ensurePath()
103103
setup_logging()
104104

105105
# Get Configuration

BabbleApp/calib_settings_widget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import PySimpleGUI as sg
1+
import FreeSimpleGUI as sg
22

33
from config import BabbleSettingsConfig
44
from osc import Tab

BabbleApp/camera.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from lang_manager import LocaleStringManager as lang
1313
from colorama import Fore
1414
from config import BabbleConfig, BabbleSettingsConfig
15-
from utils.misc_utils import get_camera_index_by_name, list_camera_names, is_nt
15+
from utils.misc_utils import get_camera_index_by_name, list_camera_names, os_type
1616

1717
from vivefacialtracker.vivetracker import ViveTracker
1818
from vivefacialtracker.camera_controller import FTCameraController
@@ -321,7 +321,7 @@ def start_serial_connection(self, port):
321321
rate = 115200 if sys.platform == "darwin" else 3000000 # Higher baud rate not working on macOS
322322
conn = serial.Serial(baudrate=rate, port=port, xonxoff=False, dsrdtr=False, rtscts=False)
323323
# Set explicit buffer size for serial. This function is Windows only!
324-
if is_nt:
324+
if os_type == 'Windows':
325325
conn.set_buffer_size(rx_size=BUFFER_SIZE, tx_size=BUFFER_SIZE)
326326

327327
print(

BabbleApp/camera_widget.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
from collections import deque
22
from queue import Queue, Empty
33
from threading import Event, Thread
4-
import PySimpleGUI as sg
4+
import FreeSimpleGUI as sg
55
import cv2
6+
import os
67
from babble_processor import BabbleProcessor, CamInfoOrigin
78
from camera import Camera, CameraState, MAX_RESOLUTION
89
from config import BabbleConfig
910
from osc import Tab
1011
from utils.misc_utils import (
11-
PlaySound,
12-
SND_FILENAME,
13-
SND_ASYNC,
12+
playSound,
1413
list_camera_names,
1514
get_camera_index_by_name,
1615
bg_color_highlight,
@@ -19,7 +18,6 @@
1918
)
2019
from lang_manager import LocaleStringManager as lang
2120

22-
2321
class CameraWidget:
2422
def __init__(self, widget_id: Tab, main_config: BabbleConfig, osc_queue: Queue):
2523
self.gui_camera_addr = f"-CAMERAADDR{widget_id}-"
@@ -441,7 +439,7 @@ def render(self, window, event, values):
441439
values[self.use_calibration] == True
442440
): # Don't start recording if the calibration filter is disabled.
443441
self.babble_cnn.calibration_frame_counter = 1500
444-
PlaySound("Audio/start.wav", SND_FILENAME | SND_ASYNC)
442+
playSound(os.path.join("Audio", "start.wav"))
445443

446444
if event == self.gui_stop_calibration:
447445
if (

BabbleApp/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os.path
33
import shutil
44

5-
from utils.misc_utils import EnsurePath
5+
from utils.misc_utils import ensurePath
66
from tab import Tab
77
from pydantic import BaseModel
88
from typing import Union
@@ -64,7 +64,7 @@ class BabbleConfig(BaseModel):
6464

6565
@staticmethod
6666
def load():
67-
EnsurePath()
67+
ensurePath()
6868

6969
if not os.path.exists(CONFIG_FILE_NAME):
7070
return BabbleConfig()
@@ -84,7 +84,7 @@ def load():
8484
return load_config
8585

8686
def save(self):
87-
EnsurePath()
87+
ensurePath()
8888

8989
# make sure this is only called if there is a change
9090
if os.path.exists(CONFIG_FILE_NAME):

BabbleApp/general_settings_widget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import PySimpleGUI as sg
1+
import FreeSimpleGUI as sg
22
from lang_manager import LocaleStringManager as lang
33
from config import BabbleSettingsConfig
44
from osc import Tab

BabbleApp/landmark_model_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
os.environ["OMP_NUM_THREADS"] = "1"
55
import onnxruntime as ort
66
import time
7-
import PySimpleGUI as sg
7+
import FreeSimpleGUI as sg
88
import cv2
99
import numpy as np
1010
from pythonosc import udp_client

0 commit comments

Comments
 (0)