From c34aac28f64b1a534fb2befdd497b2baabbaf8ff Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Mon, 12 Feb 2024 22:29:32 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8[Feature]=20utils=20:=20weight?= =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=AB=E3=83=80=E5=90=8D=E3=82=92weights?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=99=E3=82=8B=E9=96=A2=E6=95=B0?= =?UTF-8?q?=E3=82=92=E4=B8=80=E6=99=82=E7=9A=84=E3=81=AB=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 4 ++++ utils.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 6b6c0e3e..257a3a63 100644 --- a/main.py +++ b/main.py @@ -8,6 +8,10 @@ if __name__ == "__main__": splash.showSplash() from config import config + # version 2.2.0からweightフォルダをweightsに変更する + from utils import renameWeightFolder + renameWeightFolder(config.PATH_LOCAL) + from models.translation.translation_utils import downloadCTranslate2Weight if config.USE_TRANSLATION_FEATURE is True: downloadCTranslate2Weight(config.PATH_LOCAL, config.CTRANSLATE2_WEIGHT_TYPE, splash.updateDownloadProgress) diff --git a/utils.py b/utils.py index 6a05a08d..6add2b43 100644 --- a/utils.py +++ b/utils.py @@ -1,5 +1,5 @@ from typing import Union -from os import path as os_path +from os import path as os_path, rename as os_rename from PIL.Image import open as Image_open def getImageFile(file_name): @@ -49,4 +49,10 @@ def isUniqueStrings(unique_strings:Union[str, list], input_string:str, require=F return all(count == 1 for count in counts) and counts.count(1) == 2 else: # If require is False, check if unique strings are used exactly once - return all(count == 1 for count in counts) \ No newline at end of file + return all(count == 1 for count in counts) + +# path先のweightフォルダがある場合にはそのフォルダ名をweightsに変更する +def renameWeightFolder(path): + weight_path = os_path.join(path, "weight") + if os_path.exists(weight_path): + os_rename(weight_path, os_path.join(path, "weights")) \ No newline at end of file