From e147f68a19a40230f15a360cc6cfb24305b071cb Mon Sep 17 00:00:00 2001 From: misyaguziya <53165965+misyaguziya@users.noreply.github.com> Date: Fri, 15 Nov 2024 10:58:40 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=91=8D=EF=B8=8F[Update]=20Controller?= =?UTF-8?q?=20:=20AI=20model=E3=81=AE=E3=83=80=E3=82=A6=E3=83=B3=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=82=92CTranslate2=E3=81=A8Whisper=E5=90=8C?= =?UTF-8?q?=E6=99=82=E3=81=AB=E8=A1=8C=E3=81=86=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-python/webui_controller.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src-python/webui_controller.py b/src-python/webui_controller.py index 158e66bf..a1d13699 100644 --- a/src-python/webui_controller.py +++ b/src-python/webui_controller.py @@ -6,7 +6,7 @@ import re from device_manager import device_manager from config import config from model import model -from utils import isUniqueStrings, printLog +from utils import isUniqueStrings, removeLog, printLog import torch class Controller: @@ -1694,6 +1694,7 @@ class Controller: return {"status":200, "result":True} def init(self, *args, **kwargs) -> None: + removeLog() printLog("Start Initialization") printLog("Start check DeepL API Key") @@ -1707,20 +1708,31 @@ class Controller: # download CTranslate2 Model Weight printLog("Download CTranslate2 Model Weight") weight_type = config.CTRANSLATE2_WEIGHT_TYPE + th_download_ctranslate2 = None if model.checkTranslatorCTranslate2ModelWeight(weight_type) is False: - self.downloadCtranslate2Weight(weight_type, False) + th_download_ctranslate2 = Thread(target=self.downloadCtranslate2Weight, args=(weight_type, False)) + th_download_ctranslate2.daemon = True + th_download_ctranslate2.start() + + # download Whisper Model Weight + printLog("Download Whisper Model Weight") + weight_type = config.WHISPER_WEIGHT_TYPE + th_download_whisper = None + if model.checkTranscriptionWhisperModelWeight(weight_type) is False: + th_download_whisper = Thread(target=self.downloadWhisperWeight, args=(weight_type, False)) + th_download_whisper.daemon = True + th_download_whisper.start() + + if isinstance(th_download_ctranslate2, Thread): + th_download_ctranslate2.join() + if isinstance(th_download_whisper, Thread): + th_download_whisper.join() # set Translation Engine printLog("Set Translation Engine") self.updateDownloadedCTranslate2ModelWeight() self.updateTranslationEngineAndEngineList() - # download Whisper Model Weight - printLog("Download Whisper Model Weight") - weight_type = config.WHISPER_WEIGHT_TYPE - if model.checkTranscriptionWhisperModelWeight(weight_type) is False: - self.downloadWhisperWeight(weight_type, False) - # set Transcription Engine printLog("Set Transcription Engine") self.updateDownloadedWhisperModelWeight() From b37d9248c37833e8ce89c4c4cb32ca201421e74a Mon Sep 17 00:00:00 2001 From: misyaguziya <53165965+misyaguziya@users.noreply.github.com> Date: Fri, 15 Nov 2024 11:00:06 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=91=8D=EF=B8=8F[Update]=20Controller?= =?UTF-8?q?=20:=20process.log=E3=81=AE=E5=89=8A=E9=99=A4=E6=A9=9F=E8=83=BD?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-python/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src-python/utils.py b/src-python/utils.py index 9ea1725e..59bd6488 100644 --- a/src-python/utils.py +++ b/src-python/utils.py @@ -65,6 +65,10 @@ def splitList(lst:list, split_count:int, to_shuffle:bool=False): def encodeBase64(data:str) -> dict: return json.loads(base64.b64decode(data).decode('utf-8')) +def removeLogFiles(): + with open('process.log', 'w', encoding="utf-8") as f: + f.write("") + def printLog(log:str, data:Any=None) -> None: response = { "status": 348,