From 9d62906903ce2e3f7b2f6c151179eae3c488fd09 Mon Sep 17 00:00:00 2001 From: misyaguziya <53165965+misyaguziya@users.noreply.github.com> Date: Mon, 2 Dec 2024 10:05:45 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8D=EF=B8=8F[Update]=20Main=20:=20Add?= =?UTF-8?q?=20endpoint=20"/get/data/compute=5Fmode"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-python/webui_controller.py | 8 ++++++++ src-python/webui_mainloop.py | 1 + 2 files changed, 9 insertions(+) diff --git a/src-python/webui_controller.py b/src-python/webui_controller.py index 2c7256a2..e935cfe7 100644 --- a/src-python/webui_controller.py +++ b/src-python/webui_controller.py @@ -407,6 +407,14 @@ class Controller: def getMessageBoxRatioRange(*args, **kwargs) -> dict: return {"status":200, "result":config.MESSAGE_BOX_RATIO_RANGE} + @staticmethod + def getComputeMode(*args, **kwargs) -> dict: + if torch.cuda.is_available(): + compute_mode = "cuda" + else: + compute_mode = "cpu" + return {"status":200, "result":compute_mode} + @staticmethod def getComputeDeviceList(*args, **kwargs) -> dict: device_list = [] diff --git a/src-python/webui_mainloop.py b/src-python/webui_mainloop.py index 2ad86c02..80a26f62 100644 --- a/src-python/webui_mainloop.py +++ b/src-python/webui_mainloop.py @@ -133,6 +133,7 @@ mapping = { "/set/data/main_window_geometry": {"status": True, "variable":controller.setMainWindowGeometry}, # Translation + "/get/data/compute_mode": {"status": True, "variable":controller.getComputeMode}, "/get/data/translation_compute_device_list": {"status": True, "variable":controller.getComputeDeviceList}, "/get/data/selected_translation_compute_device": {"status": True, "variable":controller.getSelectedTranslationComputeDevice}, "/set/data/selected_translation_compute_device": {"status": True, "variable":controller.setSelectedTranslationComputeDevice},