Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
ENG
- A new interface has been added for those without internet access.
- The "HuBERT Models Download" block has been moved to the "Models Download" tab.
- The installation and launch file for Linux has been improved (`NOT TESTED`).
- Gradio has been updated to version 5.0.1.
- The SSH issue during HuBERT models installation has been fixed.
- The "Transformation Settings" tab has been redesigned as an accordion.

---

RU
- Добавлен новый интерфейс для тех, у кого нет интернета.
- Блок «Загрузка HuBERT моделей» перенесен во вкладку «Загрузка моделей».
- Улучшен файл установки и запуска для Linux (`НЕ ПРОВЕРЕНО`).
- Gradio обновлен до версии 5.0.1.
- Исправлена проблема с SSH при установке HuBERT моделей.
- Вкладка «Настройки преобразования» переделана под аккордион.
  • Loading branch information
Bebra777228 committed Oct 10, 2024
1 parent b5938a5 commit 5e7ab31
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 198 deletions.
14 changes: 8 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from tabs.conversion.edge_tts import edge_tts_tab
from tabs.processing.processing import processing_tab
from tabs.install.install_models import url_download, zip_upload, files_upload

from tabs.install.install_huberts import install_hubert_tab

DEFAULT_PORT = 4000
MAX_PORT_ATTEMPTS = 10
Expand Down Expand Up @@ -38,11 +38,13 @@
with gr.Tab("Преобразование текста в речь (TTS)"):
edge_tts_tab()

with gr.Tab("Загрузка модели"):
url_download()
zip_upload()
files_upload()

with gr.Tab("Загрузка моделей"):
with gr.Tab("Загрузка RVC моделей"):
url_download()
zip_upload()
files_upload()
with gr.Tab("Загрузка HuBERT моделей"):
install_hubert_tab()

def launch(port):
PolGen.launch(
Expand Down
71 changes: 71 additions & 0 deletions app_offline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import os
import sys
import gradio as gr

from tabs.welcome import welcome_tab
from tabs.conversion.conversion import conversion_tab
from tabs.processing.processing import processing_tab
from tabs.install.install_models import zip_upload, files_upload

DEFAULT_PORT = 4000
MAX_PORT_ATTEMPTS = 10


with gr.Blocks(
title="PolGen - Politrees",
css="footer{display:none !important}",
theme=gr.themes.Soft(
primary_hue="green",
secondary_hue="green",
neutral_hue="neutral",
spacing_size="sm",
radius_size="lg",
),
) as PolGen:

with gr.Tab("Велком/Контакты"):
welcome_tab()

with gr.Tab("Преобразование и обработка голоса"):
with gr.Tab("Замена голоса"):
conversion_tab()

with gr.Tab("Объединение/Обработка"):
processing_tab()

with gr.Tab("Загрузка RVC моделей"):
zip_upload()
files_upload()

def launch(port):
PolGen.launch(
favicon_path=os.path.join(os.getcwd(), "assets", "logo.ico"),
share="--share" in sys.argv,
inbrowser="--open" in sys.argv,
server_port=port,
)


def get_port_from_args():
if "--port" in sys.argv:
port_index = sys.argv.index("--port") + 1
if port_index < len(sys.argv):
return int(sys.argv[port_index])
return DEFAULT_PORT


if __name__ == "__main__":
port = get_port_from_args()
for _ in range(MAX_PORT_ATTEMPTS):
try:
launch(port)
break
except OSError:
print(
f"Не удалось запустить на порту {port}, "
f"повторите попытку на порту {port - 1}..."
)
port -= 1
except Exception as error:
print(f"Произошла ошибка при запуске Gradio: {error}")
break
20 changes: 13 additions & 7 deletions install-run.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ set "step=1"
echo [~!step!~] - Checking internet connection...
ping -n 1 google.com >nul 2>&1
if errorlevel 1 (
echo No internet connection detected. Please check your connection and try again.
goto :error
echo No internet connection detected.
set "INTERNET_AVAILABLE=0"
) else (
echo Internet connection is available.
set "INTERNET_AVAILABLE=1"
)
echo Internet connection is available.
echo.
set /a step+=1

Expand Down Expand Up @@ -92,7 +94,7 @@ if not exist env (
set /a step+=1

echo [!step!] - Installing dependencies...
"%INSTALL_ENV_DIR%\python.exe" -m pip install --no-warn-script-location --no-deps -r requirements-win.txt
"%INSTALL_ENV_DIR%\python.exe" -m pip install --no-warn-script-location --no-deps -r requirements.txt
"%INSTALL_ENV_DIR%\python.exe" -m pip uninstall torch torchvision torchaudio -y
"%INSTALL_ENV_DIR%\python.exe" -m pip install --no-warn-script-location torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 --index-url https://download.pytorch.org/whl/cu121
if errorlevel 1 goto :error
Expand All @@ -102,8 +104,6 @@ if not exist env (
set /a step+=1
)

"%INSTALL_ENV_DIR%\python.exe" -m pip install --no-warn-script-location watchdog

echo [~!step!~] - Checking for required models...
set "hubert_base=%principal%\rvc\models\embedders\hubert_base.pt"
set "fcpe=%principal%\rvc\models\predictors\fcpe.pt"
Expand All @@ -125,7 +125,13 @@ echo.
set /a step+=1

echo [~!step!~] - Running Interface...
env\python app.py --open
if "%INTERNET_AVAILABLE%"=="1" (
echo Running app.py...
env\python app.py --open
) else (
echo Running app_offline.py...
env\python app_offline.py --open
)
if errorlevel 1 goto :error
set /a step+=1

Expand Down
138 changes: 104 additions & 34 deletions install-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,76 +5,146 @@ set -e
title="PolGen"
echo $title

if [ ! -d "env" ]; then
principal=$(pwd)
CONDA_ROOT_PREFIX="$HOME/miniconda3"
INSTALL_ENV_DIR="$principal/env"
MINICONDA_DOWNLOAD_URL="https://repo.anaconda.com/miniconda/Miniconda3-py39_23.9.0-0-Linux-x86_64.sh"
CONDA_EXECUTABLE="$CONDA_ROOT_PREFIX/bin/conda"
principal=$(pwd)
CONDA_ROOT_PREFIX="$HOME/miniconda3"
INSTALL_ENV_DIR="$principal/env"
MINICONDA_DOWNLOAD_URL="https://repo.anaconda.com/miniconda/Miniconda3-py39_23.9.0-0-Linux-x86_64.sh"
CONDA_EXECUTABLE="$CONDA_ROOT_PREFIX/bin/conda"
PYTHON_VERSION_REQUIRED="3.10"
step=1

# Function to handle errors
error() {
echo "An error occurred during the process. Exiting the script..."
read -p "Press any key to continue..." -n1 -s
exit 1
}
trap error ERR

# Check internet connection
echo "[~!$step~] - Checking internet connection..."
if ping -c 1 google.com &> /dev/null; then
echo "Internet connection is available."
INTERNET_AVAILABLE=1
else
echo "No internet connection detected."
INTERNET_AVAILABLE=0
fi
echo
step=$((step + 1))

# Check Python version
echo "[~!$step~] - Checking Python version..."
if ! command -v python &> /dev/null; then
echo "Python is not installed on your system. Please install Python $PYTHON_VERSION_REQUIRED and try again."
error
fi

PYTHON_VERSION=$(python -V 2>&1 | grep -Po '(?<=Python )[0-9]+\.[0-9]+' | cut -d. -f2)
if [ "$PYTHON_VERSION" != "10" ]; then
echo "Unsupported Python version detected: 3.$PYTHON_VERSION"
echo
while true; do
read -p "Your Python version is not $PYTHON_VERSION_REQUIRED. The program may not work correctly. Continue anyway? (y/n): " CONTINUE
case $CONTINUE in
[Yy]* ) echo "Continuing with the script..."; break;;
[Nn]* ) echo "Exiting the script..."; error;;
* ) echo "Invalid input. Please enter 'y' or 'n'.";;
esac
done
else
echo "Compatible Python version detected. Proceeding with the script..."
fi
echo
step=$((step + 1))

if [ ! -d "env" ]; then
echo "[~!$step~] - Checking for Miniconda installation..."
if [ ! -f "$CONDA_EXECUTABLE" ]; then
echo "Miniconda not found. Starting download and installation..."
echo "Miniconda is not installed. Starting download and installation..."
echo "Downloading Miniconda..."
curl -o miniconda.sh $MINICONDA_DOWNLOAD_URL
if [ ! -f "miniconda.sh" ]; then
echo "Download failed. Please check your internet connection and try again."
exit 1
echo "Miniconda download failed. Please check your internet connection and try again."
error
fi

echo "Installing Miniconda..."
bash miniconda.sh -b -p $CONDA_ROOT_PREFIX
if [ $? -ne 0 ]; then
echo "Miniconda installation failed."
exit 1
error
fi
rm miniconda.sh
echo "Miniconda installation complete."
echo "Miniconda installation completed successfully."
else
echo "Miniconda already installed. Skipping installation."
echo "Miniconda is already installed. Skipping installation."
fi
echo
step=$((step + 1))

echo "Creating Conda environment..."
echo "[~!$step~] - Creating Conda environment..."
$CONDA_EXECUTABLE create --no-shortcuts -y -k --prefix "$INSTALL_ENV_DIR" python=3.9
if [ $? -ne 0 ]; then
exit 1
error
fi
echo "Conda environment created successfully."
echo
step=$((step + 1))

echo "[~!$step~] - Installing specific pip version..."
if [ -f "$INSTALL_ENV_DIR/bin/python" ]; then
echo "Installing specific pip version..."
$INSTALL_ENV_DIR/bin/python -m pip install "pip<24.1"
if [ $? -ne 0 ]; then
exit 1
error
fi
echo "Pip installation complete."
echo "Pip installed successfully."
echo
fi
step=$((step + 1))

echo "Installing dependencies..."
echo "[~!$step~] - Installing dependencies..."
source "$CONDA_ROOT_PREFIX/etc/profile.d/conda.sh"
conda activate "$INSTALL_ENV_DIR" || exit 1
pip install --upgrade setuptools || exit 1
pip install -r "$principal/requirements.txt" || exit 1
conda activate "$INSTALL_ENV_DIR" || error
pip install --upgrade setuptools || error
pip install -r "$principal/requirements-win.txt" || error
pip uninstall torch torchvision torchaudio -y
pip install torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 --index-url https://download.pytorch.org/whl/cu121 || exit 1
pip install torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 --index-url https://download.pytorch.org/whl/cu121 || error
conda deactivate
echo "Dependencies installation complete."
echo "Dependencies installed successfully."
echo
step=$((step + 1))
fi

$INSTALL_ENV_DIR/bin/python download_models.py
echo
echo "[~!$step~] - Checking for required models..."
hubert_base="$principal/rvc/models/embedders/hubert_base.pt"
fcpe="$principal/rvc/models/predictors/fcpe.pt"
rmvpe="$principal/rvc/models/predictors/rmvpe.pt"

$INSTALL_ENV_DIR/bin/python app.py --open
if [ ! -f "$hubert_base" ] || [ ! -f "$fcpe" ] || [ ! -f "$rmvpe" ]; then
echo "Required models were not found. Installing models..."
echo
$INSTALL_ENV_DIR/bin/python download_models.py
if [ $? -ne 0 ]; then
error
fi
fi
echo
read -p "Press any key to continue..." -n1 -s
exit 0
step=$((step + 1))

error() {
echo "An error occurred during installation. Please check the output above for details."
read -p "Press any key to continue..." -n1 -s
exit 1
}
trap error ERR
echo "[~!$step~] - Running Interface..."
if [ "$INTERNET_AVAILABLE" == "1" ]; then
echo "Running app.py..."
$INSTALL_ENV_DIR/bin/python app.py --open
else
echo "Running app_offline.py..."
$INSTALL_ENV_DIR/bin/python app_offline.py --open
fi
if [ $? -ne 0 ]; then
error
fi
step=$((step + 1))

echo "Script completed successfully."
read -p "Press any key to continue..." -n1 -s
exit 0
Loading

0 comments on commit 5e7ab31

Please sign in to comment.