Update to py 3.11, performance improvements, ESP USB camera improvement

This commit is contained in:
Prohurtz committed 2023-12-22 11:22:50 -08:00
1 parent 42c9ecfdab
commit fcb0cc4102
7 files changed
+1083 -26

No files matched your search

+4 -12
View File
@@ -13,26 +13,18 @@ from torchvision import transforms
from threading import Thread
from one_euro_filter import OneEuroFilter
def run_model(self):
if self.runtime == "ONNX" or self.runtime == "Default (ONNX)":
frame = cv2.resize(self.current_image_gray, (256, 256))
# make it pil
frame = Image.fromarray(frame)
# make it grayscale
frame = to_grayscale(frame)
# make it a tensor
frame = transforms.ToTensor()(frame)
# make it a batch
frame = frame.unsqueeze(0)
# make it a numpy array
frame = frame.numpy()
frame = transforms.ToTensor()(frame).unsqueeze(0).numpy()
out = self.sess.run([self.output_name], {self.input_name: frame})
#end = time.time()
output = out[0]
output = output[0]
output = self.one_euro_filter(output)
for i in range(len(output)): # Clip values between 0 - 1
output[i] = max(min(output[i], 1), 0)
self.output = output
+4 -4
View File
@@ -46,8 +46,8 @@ class BabbleProcessor:
fullconfig: "BabbleConfig",
cancellation_event: "threading.Event",
capture_event: "threading.Event",
capture_queue_incoming: "queue.Queue",
image_queue_outgoing: "queue.Queue",
capture_queue_incoming: "queue.Queue(maxsize=2)",
image_queue_outgoing: "queue.Queue(maxsize=2)",
cam_id,
):
self.main_config = BabbleSettingsConfig
@@ -100,8 +100,8 @@ class BabbleProcessor:
beta = float(self.settings.gui_speed_coefficient) # 0.62
except:
print('\033[93m[WARN] OneEuroFilter values must be a legal number.\033[0m')
min_cutoff = 10.0004
beta = 0.62
min_cutoff = 0.9
beta = 0.9
noisy_point = np.array([45])
self.one_euro_filter = OneEuroFilter(
noisy_point,
+1 -1
View File
@@ -183,7 +183,7 @@ def main():
# GUI Render loop
while True:
# First off, check for any events from the GUI
event, values = window.read(timeout=1)
event, values = window.read(timeout=2)
# If we're in either mode and someone hits q, quit immediately
if event == "Exit" or event == sg.WIN_CLOSED:
+2 -2
View File
@@ -36,7 +36,7 @@ class Camera:
cancellation_event: "threading.Event",
capture_event: "threading.Event",
camera_status_outgoing: "queue.Queue[CameraState]",
camera_output_outgoing: "queue.Queue",
camera_output_outgoing: "queue.Queue(maxsize=2)",
settings: BabbleSettingsConfig,
):
self.camera_status = CameraState.CONNECTING
@@ -83,7 +83,7 @@ class Camera:
if (
self.config.capture_source != None and self.config.capture_source != ""
):
self.current_capture_source = self.config.capture_source
if ("COM" in str(self.config.capture_source)):
if (
self.serial_connection is None
+2 -2
View File
@@ -22,8 +22,8 @@ class BabbleCameraConfig(BaseModel):
gui_horizontal_flip: bool = False
class BabbleSettingsConfig(BaseModel):
gui_min_cutoff: str = "10.5004"
gui_speed_coefficient: str = "0.62"
gui_min_cutoff: str = "0.9"
gui_speed_coefficient: str = "0.9"
gui_osc_address: str = "127.0.0.1"
gui_osc_port: int = 8888
gui_osc_receiver_port: int = 9001
Generated
+1065
View File
File diff suppressed because it is too large. Load diff
+5 -5
View File
@@ -7,7 +7,7 @@ license = "MIT"
repository = "https://github.com/SummerSigh/ProjectBabble"
[tool.poetry.dependencies]
python = "~3.10.0"
python = "~3.11.0"
python-osc = "^1.8.0"
requests = "^2.28.1"
opencv-python = "^4.6.0.66"
@@ -23,12 +23,12 @@ onnxruntime-directml = "^1.15.0"
colorama = "^0.4.6"
taskipy = "^1.10.4"
torch = [
{url = "https://download.pytorch.org/whl/cpu/torch-2.0.0%2Bcpu-cp310-cp310-linux_x86_64.whl", markers = "sys_platform == 'linux'"},
{url = "https://download.pytorch.org/whl/cpu/torch-2.0.0%2Bcpu-cp310-cp310-win_amd64.whl", markers = "sys_platform == 'win32'" }
{url = "https://download.pytorch.org/whl/cpu/torch-2.0.0%2Bcpu-cp311-cp311-linux_x86_64.whl", markers = "sys_platform == 'linux'"},
{url = "https://download.pytorch.org/whl/cpu/torch-2.0.0%2Bcpu-cp311-cp311-win_amd64.whl", markers = "sys_platform == 'win32'" }
]
torchvision = [
{url = "https://download.pytorch.org/whl/cpu/torchvision-0.15.1%2Bcpu-cp310-cp310-linux_x86_64.whl", markers = "sys_platform == 'linux'"},
{url = "https://download.pytorch.org/whl/cpu/torchvision-0.15.1%2Bcpu-cp310-cp310-win_amd64.whl", markers = "sys_platform == 'win32'" }
{url = "https://download.pytorch.org/whl/cpu/torchvision-0.15.1%2Bcpu-cp311-cp311-linux_x86_64.whl", markers = "sys_platform == 'linux'"},
{url = "https://download.pytorch.org/whl/cpu/torchvision-0.15.1%2Bcpu-cp311-cp311-win_amd64.whl", markers = "sys_platform == 'win32'" }
]