mirror of
https://github.com/Project-Babble/ProjectBabble.git
synced 2026-12-04 15:52:21 -08:00
GPU Selection stuff
This commit is contained in:
1 parent
6ac566e800
commit
5daca3dff1
7 files changed
+25
-13
No files matched your search
@@ -13,3 +13,4 @@ BabbleApp/dist
|
||||
scripts/example_build_app_and_installer.bat
|
||||
scripts/example_build_app_and_installer.bat
|
||||
scripts/installer.iss
|
||||
Glia_cap.py
|
||||
Binary file not shown.
@@ -5,6 +5,7 @@ from osc import Tab
|
||||
from queue import Queue
|
||||
from threading import Event
|
||||
|
||||
|
||||
class AlgoSettingsWidget:
|
||||
def __init__(self, widget_id: Tab, main_config: BabbleSettingsConfig, osc_queue: Queue):
|
||||
|
||||
@@ -21,6 +22,7 @@ class AlgoSettingsWidget:
|
||||
self.main_config = main_config
|
||||
self.config = main_config.settings
|
||||
self.osc_queue = osc_queue
|
||||
self.backend_list = "OpenVino", "ONNX"
|
||||
|
||||
# Define the window's contents
|
||||
self.general_settings_layout = [
|
||||
@@ -41,12 +43,19 @@ class AlgoSettingsWidget:
|
||||
),
|
||||
],
|
||||
[sg.Text("Backend:", background_color='#424042'), # Replace with Dropdown once I have internet to view docs.
|
||||
sg.InputText(
|
||||
sg.OptionMenu(
|
||||
self.backend_list,
|
||||
self.config.gui_backend,
|
||||
key=self.gui_backend,
|
||||
size=(4),
|
||||
tooltip = "Method to run the model.",
|
||||
),
|
||||
),
|
||||
#sg.InputText(
|
||||
# self.config.gui_backend,
|
||||
# key=self.gui_backend,
|
||||
# size=(4),
|
||||
# tooltip = "Method to run the model.",
|
||||
|
||||
#),
|
||||
|
||||
sg.Text("GPU Index:", background_color='#424042'), # Replace with Dropdown once I have internet to view docs.
|
||||
sg.InputText(
|
||||
self.config.gui_gpu_index,
|
||||
@@ -54,6 +63,7 @@ class AlgoSettingsWidget:
|
||||
size=(4),
|
||||
tooltip = "Select which device to run inference.",
|
||||
),
|
||||
|
||||
sg.Checkbox(
|
||||
"Use GPU",
|
||||
default=self.config.gui_use_gpu,
|
||||
@@ -144,8 +154,8 @@ class AlgoSettingsWidget:
|
||||
self.config.gui_gpu_index = int(values[self.gui_gpu_index])
|
||||
changed = True
|
||||
|
||||
if self.config.gui_backend != int(values[self.gui_backend]):
|
||||
self.config.gui_backend = int(values[self.gui_backend])
|
||||
if self.config.gui_backend != str(values[self.gui_backend]):
|
||||
self.config.gui_backend = str(values[self.gui_backend])
|
||||
changed = True
|
||||
|
||||
if self.config.gui_inference_threads != int(values[self.gui_inference_threads]):
|
||||
|
||||
@@ -16,7 +16,7 @@ from one_euro_filter import OneEuroFilter
|
||||
|
||||
|
||||
def run_model(self):
|
||||
if self.backend == 0:
|
||||
if self.backend == "OpenVino":
|
||||
frame = cv2.resize(self.current_image_gray, (256, 256))
|
||||
# make it pil
|
||||
frame = Image.fromarray(frame)
|
||||
@@ -38,7 +38,7 @@ def run_model(self):
|
||||
output[i] = max(min(output[i], 1), 0)
|
||||
self.output = output
|
||||
|
||||
if self.backend == 1:
|
||||
if self.backend == "ONNX":
|
||||
frame = cv2.resize(self.current_image_gray, (256, 256))
|
||||
# make it pil
|
||||
frame = Image.fromarray(frame)
|
||||
|
||||
@@ -90,15 +90,15 @@ class BabbleProcessor:
|
||||
self.opts.intra_op_num_threads = settings.gui_inference_threads
|
||||
self.opts.inter_op_num_threads = settings.gui_inference_threads # Figure out how to set openvino threads
|
||||
self.opts.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL
|
||||
if self.backend == 0: # OpenVino
|
||||
if self.use_gpu: provider = f'GPU{self.gpu_index}'
|
||||
if self.backend == "OpenVino": # OpenVino
|
||||
if self.use_gpu: provider = f'GPU.{self.gpu_index}'
|
||||
else: provider = 'CPU'
|
||||
ie = IECore()
|
||||
net = ie.read_network(model=f'{self.model}openvino/model.xml', weights=f'{self.model}openvino/model.bin')
|
||||
self.sess = ie.load_network(network=net, device_name=provider)
|
||||
self.input_name = next(iter(net.input_info))
|
||||
self.output_name = next(iter(net.outputs))
|
||||
if self.backend == 1: # ONNX
|
||||
if self.backend == "ONNX": # ONNX
|
||||
if self.use_gpu: provider = 'DmlExecutionProvider' # Figure out how to set ONNX gpu index
|
||||
else: provider = "CPUExecutionProvider"
|
||||
self.sess = ort.InferenceSession(f'{self.model}onnx/model.onnx', self.opts, providers=[provider])
|
||||
|
||||
+2
-2
@@ -33,12 +33,12 @@ class BabbleSettingsConfig(BaseModel):
|
||||
gui_osc_location: str = ""
|
||||
gui_multiply: int = 1
|
||||
gui_model_file: str = 'Models/MOS3E26MCJPEG/'
|
||||
gui_backend: int = 0
|
||||
gui_backend: str = "OpenVino"
|
||||
gui_use_gpu: bool = False
|
||||
gui_gpu_index: int = 0
|
||||
gui_inference_threads: int = 1
|
||||
gui_use_red_channel: bool = False
|
||||
calib_array: str = ""
|
||||
calib_array: str = "[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]]"
|
||||
gui_cam_resolution_x: int = 0
|
||||
gui_cam_resolution_y: int = 0
|
||||
gui_cam_framerate: int = 0
|
||||
|
||||
@@ -21,6 +21,7 @@ winotify = [
|
||||
onnxruntime = "^1.13.1"
|
||||
onnxruntime-directml = "^1.15.0"
|
||||
openvino = "^2023.0.1"
|
||||
|
||||
colorama = "^0.4.6"
|
||||
taskipy = "^1.10.4"
|
||||
torch = [
|
||||
|
||||
Reference in new issue
Block a user