From 567907fc4db809e25810573c48f499e9e04455f8 Mon Sep 17 00:00:00 2001 From: misyaguziya <53165965+misyaguziya@users.noreply.github.com> Date: Thu, 2 Jan 2025 08:32:35 +0900 Subject: [PATCH 01/54] =?UTF-8?q?=F0=9F=90=9B[bugfix]=20Model=20:=20Added?= =?UTF-8?q?=20the=20ability=20to=20automatically=20select=20calculation=20?= =?UTF-8?q?types=20from=20GPU=20devices?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../transcription/transcription_whisper.py | 3 +- .../translation/translation_translator.py | 4 +- src-python/utils.py | 65 +++---------------- 3 files changed, 12 insertions(+), 60 deletions(-) diff --git a/src-python/models/transcription/transcription_whisper.py b/src-python/models/transcription/transcription_whisper.py index 3eb574c7..080054b5 100644 --- a/src-python/models/transcription/transcription_whisper.py +++ b/src-python/models/transcription/transcription_whisper.py @@ -4,6 +4,7 @@ from typing import Callable import huggingface_hub from faster_whisper import WhisperModel import logging +from utils import getBestComputeType logger = logging.getLogger('faster_whisper') logger.setLevel(logging.CRITICAL) @@ -73,7 +74,7 @@ def downloadWhisperWeight(root, weight_type, callback=None, end_callback=None): def getWhisperModel(root, weight_type, device="cpu", device_index=0): path = os_path.join(root, "weights", "whisper", weight_type) - compute_type = "int8" if device == "cpu" else "float16" + compute_type = getBestComputeType(device, device_index) return WhisperModel( path, device=device, diff --git a/src-python/models/translation/translation_translator.py b/src-python/models/translation/translation_translator.py index 44004155..fad96744 100644 --- a/src-python/models/translation/translation_translator.py +++ b/src-python/models/translation/translation_translator.py @@ -6,7 +6,7 @@ from .translation_utils import ctranslate2_weights import ctranslate2 import transformers -from utils import errorLogging +from utils import errorLogging, getBestComputeType import warnings warnings.filterwarnings("ignore") @@ -37,7 +37,7 @@ class Translator(): weight_path = os_path.join(path, "weights", "ctranslate2", directory_name) tokenizer_path = os_path.join(path, "weights", "ctranslate2", directory_name, "tokenizer") - compute_type = "int8" if device == "cpu" else "float16" + compute_type = getBestComputeType(device, device_index) self.ctranslate2_translator = ctranslate2.Translator( weight_path, device=device, diff --git a/src-python/utils.py b/src-python/utils.py index 31d589bd..8e23af38 100644 --- a/src-python/utils.py +++ b/src-python/utils.py @@ -1,68 +1,19 @@ import base64 from typing import Any import json -import random -from typing import Union -from os import path as os_path, rename as os_rename import traceback import logging -from PIL.Image import open as Image_open -def getImageFile(file_name): - img = Image_open(os_path.join(os_path.dirname(__file__), "img", file_name)) - return img +from ctranslate2 import get_supported_compute_types -def callFunctionIfCallable(function, *args): - if callable(function) is True: - function(*args) +def getBestComputeType(device, device_index) -> str: + compute_types = get_supported_compute_types(device, device_index) + compute_types = set(compute_types) + preferred_types = ["int8_bfloat16", "int8_float16", "int8", "bfloat16", "float16", "int8_float32", "float32"] -def isEven(number): - return number % 2 == 0 - -def makeEven(number, minus:bool=False): - if minus is True: - return number if isEven(number) else number - 1 - return number if isEven(number) else number + 1 - -def intToPctStr(value:int): - return f"{value}%" - -def floatToPctStr(value:float): - return f"{int(value*100)}%" - -def strPctToInt(value:str): - return int(value.replace("%", "")) - -def isUniqueStrings(unique_strings:Union[str, list], input_string:str, require=False): - import re - if isinstance(unique_strings, str): - unique_strings = [unique_strings] - patterns = [re.escape(s) for s in unique_strings] - - counts = [len(re.findall(pattern, input_string)) for pattern in patterns] - - if require is True: - # If require is True, unique_strings must appear once - 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) - -# 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")) - -def splitList(lst:list, split_count:int, to_shuffle:bool=False): - if to_shuffle is True: - random.shuffle(lst) - - split_lists = [] - for i in range(0, len(lst), split_count): - sub_list = lst[i:i+split_count] - split_lists.append(sub_list) - return split_lists + for preferred_type in preferred_types: + if preferred_type in compute_types: + return preferred_type def encodeBase64(data:str) -> dict: return json.loads(base64.b64decode(data).decode('utf-8')) From d798562de7aab2e5b94d99593aa1b175112eed35 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Thu, 2 Jan 2025 16:00:00 +0900 Subject: [PATCH 02/54] [bugfix] Main Page: MessageInputBox: Fix the bug that can't bring the history back and occur undefined error when shift+arrow down kay pressed. --- .../message_container/message_input_box/MessageInputBox.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-ui/app/main_page/main_section/message_container/message_input_box/MessageInputBox.jsx b/src-ui/app/main_page/main_section/message_container/message_input_box/MessageInputBox.jsx index 88ee0605..53bce2e5 100644 --- a/src-ui/app/main_page/main_section/message_container/message_input_box/MessageInputBox.jsx +++ b/src-ui/app/main_page/main_section/message_container/message_input_box/MessageInputBox.jsx @@ -69,7 +69,7 @@ export const MessageInputBox = () => { if (history_index > -1) { const new_index = history_index - 1; setHistoryIndex(new_index); - setInputValue( + updateMessageInputValue( new_index >= 0 ? message_history[message_history.length - 1 - new_index] : "" From 5d0e9e055956ae4fb7f61d2e7251b73bf68d3611 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Thu, 2 Jan 2025 19:22:09 +0900 Subject: [PATCH 03/54] [Refactor] Tidy up the color variables. --- src-ui/app/_index_css/root.css | 2 +- src-ui/app/_index_css/variables.css | 9 ++++- .../_atoms/_entry/_Entry.module.scss | 1 - .../deepl_auth_key/DeeplAuthKey.module.scss | 7 ++-- .../download_models/DownloadModels.jsx | 22 ++---------- .../DownloadModels.module.scss | 2 -- .../LabelComponent.module.scss | 1 - .../setting_box/_components/slider/Slider.jsx | 7 ---- .../ThresholdEntry.module.scss | 1 - .../VolumeCheckButton.module.scss | 1 - .../word_filter/WordFilter.module.scss | 4 +-- .../setting_box/device/Device.module.scss | 1 - .../setting_box/vr/Vr.module.scss | 4 +-- .../SidebarSection.module.scss | 1 - src-ui/app/main_page/MainPage.module.scss | 36 ------------------- .../LanguageSelector.module.scss | 1 - .../MessageContainer.module.scss | 1 - .../MessageSubMenuContainer.module.scss | 2 +- .../LanguageSelectorOpenButton.module.scss | 2 -- .../LanguageSwapButton.module.scss | 2 +- .../PresetTabSelector.module.scss | 2 +- .../TranslatorSelectorOpenButton.module.scss | 3 +- .../TranslatorSelector.module.scss | 6 ++-- .../MainFunctionSwitch.module.scss | 3 -- .../update_modal/UpdateModal.module.scss | 3 -- .../SnackbarController.module.scss | 4 +-- .../SplashComponent.module.scss | 8 ++--- .../WindowTitleBar.module.scss | 4 +-- 28 files changed, 30 insertions(+), 110 deletions(-) diff --git a/src-ui/app/_index_css/root.css b/src-ui/app/_index_css/root.css index e2bcc6e7..4d96f38b 100644 --- a/src-ui/app/_index_css/root.css +++ b/src-ui/app/_index_css/root.css @@ -3,7 +3,7 @@ :root { font-size: 62.5%; - color: #F2F2F2; + color: var(--dark_basic_text_color); } * { diff --git a/src-ui/app/_index_css/variables.css b/src-ui/app/_index_css/variables.css index 2d38f67a..d212b415 100644 --- a/src-ui/app/_index_css/variables.css +++ b/src-ui/app/_index_css/variables.css @@ -20,6 +20,10 @@ --sent_400_color: #6197b4; --received_300_color: #a861b4; + --error_bc_color: #bb4448; + --error_bc_active_color: #9c3938; + --success_bc_color: #368777; + --waring_color: #cb944f; --dark_basic_text_color: #f2f2f2; --dark_100_color: #f5f7fb; @@ -48,8 +52,11 @@ --dark_975_color: #1a1b1d; --dark_1000_color: #151517; - --dark_825_color_cc: #434447cc; --dark_550_color_22: #94959922; + --dark_825_color_cc: #434447cc; + --dark_1000_color_66: #15151766; + --dark_1000_color_aa: #151517aa; + --dark_1000_color_dd: #151517dd; --title_bar_height: 2rem; diff --git a/src-ui/app/config_page/setting_section/setting_box/_components/_atoms/_entry/_Entry.module.scss b/src-ui/app/config_page/setting_section/setting_box/_components/_atoms/_entry/_Entry.module.scss index c9744de6..5dd43ff1 100644 --- a/src-ui/app/config_page/setting_section/setting_box/_components/_atoms/_entry/_Entry.module.scss +++ b/src-ui/app/config_page/setting_section/setting_box/_components/_atoms/_entry/_Entry.module.scss @@ -16,7 +16,6 @@ height: 100%; font-size: 1.4rem; resize: none; - color: var(--dark_basic_text_color); &.is_disabled { color: var(--dark_500_color); pointer-events: none; diff --git a/src-ui/app/config_page/setting_section/setting_box/_components/deepl_auth_key/DeeplAuthKey.module.scss b/src-ui/app/config_page/setting_section/setting_box/_components/deepl_auth_key/DeeplAuthKey.module.scss index 915f300c..1f5a530e 100644 --- a/src-ui/app/config_page/setting_section/setting_box/_components/deepl_auth_key/DeeplAuthKey.module.scss +++ b/src-ui/app/config_page/setting_section/setting_box/_components/deepl_auth_key/DeeplAuthKey.module.scss @@ -22,11 +22,11 @@ bottom: 0; left: 0; border-radius: 0.4rem; - background-color: (#00000044); + background-color: var(--dark_1000_color_66); backdrop-filter: blur(4rem); border: solid 0.1rem var(--dark_700_color); &:hover { - background-color: (#00000088); + background-color: var(--dark_1000_color_aa); } &:active { backdrop-filter: blur(1.4rem); @@ -35,7 +35,6 @@ .edit_button { padding: 0.8rem 1.2rem; - color: var(--dark_basic_text_color); height: 100%; width: 100%; font-size: 1.4rem; @@ -62,7 +61,6 @@ } .save_button_label { - color: var(--dark_basic_text_color); font-size: 1.4rem; } @@ -91,7 +89,6 @@ .open_webpage_text { font-size: 1.2rem; - color: var(--dark_basic_text_color); } .external_link_svg { diff --git a/src-ui/app/config_page/setting_section/setting_box/_components/download_models/DownloadModels.jsx b/src-ui/app/config_page/setting_section/setting_box/_components/download_models/DownloadModels.jsx index 6ec51fb1..b1f2360b 100644 --- a/src-ui/app/config_page/setting_section/setting_box/_components/download_models/DownloadModels.jsx +++ b/src-ui/app/config_page/setting_section/setting_box/_components/download_models/DownloadModels.jsx @@ -1,12 +1,10 @@ -import { useState, useEffect } from "react"; import { useTranslation } from "react-i18next"; -import clsx from "clsx"; import CircularProgress from "@mui/material/CircularProgress"; import styles from "./DownloadModels.module.scss"; import { RadioButton, - // DownloadModels, } from "../index"; + export const DownloadModels = (props) => { const options = props.options.map(item => ({ ...item, @@ -25,25 +23,11 @@ export const DownloadModels = (props) => { downloadStartFunction={props.downloadStartFunction} /> - //
- // {props.models.map((option) => ( - // - // ))} - //
); }; const ModelSelector = ({option, ...props}) => { const { t } = useTranslation(); - const [circular_color, setCircularColor] = useState(""); - const [circular_color_2, setCircularColor2] = useState(""); - useEffect(() => { - const circular_color = getComputedStyle(document.documentElement).getPropertyValue("--dark_600_color"); - setCircularColor(circular_color.trim()); - const circular_color_2 = getComputedStyle(document.documentElement).getPropertyValue("--primary_300_color"); - setCircularColor2(circular_color_2.trim()); - }, []); - const renderContent = () => { const circular_progress = Math.floor(option.progress / 10) * 10; @@ -56,13 +40,13 @@ const ModelSelector = ({option, ...props}) => { variant={(option.progress === 100) ? "indeterminate" : "determinate"} value={circular_progress} size="3rem" - sx={{ color: circular_color_2 }} + sx={{ color: "var(--primary_300_color)" }} />

{`${Math.round(option.progress)}%`}

); case option.is_pending: - return ; + return ; case !option.is_downloaded: return (