Skip to content

Commit 5daca3d

Browse files
GPU Selection stuff
1 parent 6ac566e commit 5daca3d

File tree

7 files changed

+25
-13
lines changed

7 files changed

+25
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ BabbleApp/dist
1313
scripts/example_build_app_and_installer.bat
1414
scripts/example_build_app_and_installer.bat
1515
scripts/installer.iss
16+
Glia_cap.py
4.58 MB
Binary file not shown.

BabbleApp/algo_settings_widget.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from queue import Queue
66
from threading import Event
77

8+
89
class AlgoSettingsWidget:
910
def __init__(self, widget_id: Tab, main_config: BabbleSettingsConfig, osc_queue: Queue):
1011

@@ -21,6 +22,7 @@ def __init__(self, widget_id: Tab, main_config: BabbleSettingsConfig, osc_queue:
2122
self.main_config = main_config
2223
self.config = main_config.settings
2324
self.osc_queue = osc_queue
25+
self.backend_list = "OpenVino", "ONNX"
2426

2527
# Define the window's contents
2628
self.general_settings_layout = [
@@ -41,19 +43,27 @@ def __init__(self, widget_id: Tab, main_config: BabbleSettingsConfig, osc_queue:
4143
),
4244
],
4345
[sg.Text("Backend:", background_color='#424042'), # Replace with Dropdown once I have internet to view docs.
44-
sg.InputText(
46+
sg.OptionMenu(
47+
self.backend_list,
4548
self.config.gui_backend,
4649
key=self.gui_backend,
47-
size=(4),
48-
tooltip = "Method to run the model.",
49-
),
50+
),
51+
#sg.InputText(
52+
# self.config.gui_backend,
53+
# key=self.gui_backend,
54+
# size=(4),
55+
# tooltip = "Method to run the model.",
56+
57+
#),
58+
5059
sg.Text("GPU Index:", background_color='#424042'), # Replace with Dropdown once I have internet to view docs.
5160
sg.InputText(
5261
self.config.gui_gpu_index,
5362
key=self.gui_gpu_index,
5463
size=(4),
5564
tooltip = "Select which device to run inference.",
5665
),
66+
5767
sg.Checkbox(
5868
"Use GPU",
5969
default=self.config.gui_use_gpu,
@@ -144,8 +154,8 @@ def render(self, window, event, values):
144154
self.config.gui_gpu_index = int(values[self.gui_gpu_index])
145155
changed = True
146156

147-
if self.config.gui_backend != int(values[self.gui_backend]):
148-
self.config.gui_backend = int(values[self.gui_backend])
157+
if self.config.gui_backend != str(values[self.gui_backend]):
158+
self.config.gui_backend = str(values[self.gui_backend])
149159
changed = True
150160

151161
if self.config.gui_inference_threads != int(values[self.gui_inference_threads]):

BabbleApp/babble_model_loader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
def run_model(self):
19-
if self.backend == 0:
19+
if self.backend == "OpenVino":
2020
frame = cv2.resize(self.current_image_gray, (256, 256))
2121
# make it pil
2222
frame = Image.fromarray(frame)
@@ -38,7 +38,7 @@ def run_model(self):
3838
output[i] = max(min(output[i], 1), 0)
3939
self.output = output
4040

41-
if self.backend == 1:
41+
if self.backend == "ONNX":
4242
frame = cv2.resize(self.current_image_gray, (256, 256))
4343
# make it pil
4444
frame = Image.fromarray(frame)

BabbleApp/babble_processor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ def __init__(
9090
self.opts.intra_op_num_threads = settings.gui_inference_threads
9191
self.opts.inter_op_num_threads = settings.gui_inference_threads # Figure out how to set openvino threads
9292
self.opts.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL
93-
if self.backend == 0: # OpenVino
94-
if self.use_gpu: provider = f'GPU{self.gpu_index}'
93+
if self.backend == "OpenVino": # OpenVino
94+
if self.use_gpu: provider = f'GPU.{self.gpu_index}'
9595
else: provider = 'CPU'
9696
ie = IECore()
9797
net = ie.read_network(model=f'{self.model}openvino/model.xml', weights=f'{self.model}openvino/model.bin')
9898
self.sess = ie.load_network(network=net, device_name=provider)
9999
self.input_name = next(iter(net.input_info))
100100
self.output_name = next(iter(net.outputs))
101-
if self.backend == 1: # ONNX
101+
if self.backend == "ONNX": # ONNX
102102
if self.use_gpu: provider = 'DmlExecutionProvider' # Figure out how to set ONNX gpu index
103103
else: provider = "CPUExecutionProvider"
104104
self.sess = ort.InferenceSession(f'{self.model}onnx/model.onnx', self.opts, providers=[provider])

BabbleApp/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ class BabbleSettingsConfig(BaseModel):
3333
gui_osc_location: str = ""
3434
gui_multiply: int = 1
3535
gui_model_file: str = 'Models/MOS3E26MCJPEG/'
36-
gui_backend: int = 0
36+
gui_backend: str = "OpenVino"
3737
gui_use_gpu: bool = False
3838
gui_gpu_index: int = 0
3939
gui_inference_threads: int = 1
4040
gui_use_red_channel: bool = False
41-
calib_array: str = ""
41+
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]]"
4242
gui_cam_resolution_x: int = 0
4343
gui_cam_resolution_y: int = 0
4444
gui_cam_framerate: int = 0

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ winotify = [
2121
onnxruntime = "^1.13.1"
2222
onnxruntime-directml = "^1.15.0"
2323
openvino = "^2023.0.1"
24+
2425
colorama = "^0.4.6"
2526
taskipy = "^1.10.4"
2627
torch = [

0 commit comments

Comments
 (0)