From 731722e5fcfc2eabb1124224f33dde4f7b564bf8 Mon Sep 17 00:00:00 2001 From: Blaise Date: Fri, 26 Jan 2024 21:17:17 +0100 Subject: [PATCH] uppss... deleted files --- Dockerfile | 19 ++++++++++ Makefile | 24 +++++++++++++ docker-compose.yaml | 16 +++++++++ run-applio.sh | 6 ++++ run-install.sh | 87 +++++++++++++++++++++++++++++++++++++++++++++ run-tensorboard.sh | 6 ++++ 6 files changed, 158 insertions(+) create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 docker-compose.yaml create mode 100644 run-applio.sh create mode 100644 run-install.sh create mode 100644 run-tensorboard.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..c60d425df --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +# syntax=docker/dockerfile:1 + +FROM python:3.10-bullseye + +EXPOSE 6969 + +WORKDIR /app + +RUN apt update && apt install -y -qq ffmpeg aria2 && apt clean + +RUN pip3 install --no-cache-dir -r requirements.txt + +COPY . . + +VOLUME [ "/app/logs/weights", "/app/opt" ] + +ENTRYPOINT [ "python3" ] + +CMD ["app.py"] \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..3d6b0212b --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +.PHONY: +.ONESHELL: + +# Show help message +help: + @grep -hE '^[A-Za-z0-9_ \-]*?:.*##.*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +# Install dependencies +run-install: + apt-get -y install build-essential python3-dev ffmpeg + pip install --upgrade setuptools wheel + pip install --upgrade pip + pip install faiss-gpu fairseq gradio ffmpeg ffmpeg-python praat-parselmouth pyworld numpy==1.23.5 numba==0.56.4 librosa==0.9.1 + pip install -r requirements.txt + pip install --upgrade lxml + apt-get update + +# Run Applio +run-applio: + python app.py + +# Run Tensorboard +run-tensorboard: + python core.py tensorboard diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 000000000..c40724ead --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,16 @@ +version: '1' + +services: + applio: + build: + context: ./ + dockerfile: Dockerfile + ports: + - "6969" + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] \ No newline at end of file diff --git a/run-applio.sh b/run-applio.sh new file mode 100644 index 000000000..1aa8a57f3 --- /dev/null +++ b/run-applio.sh @@ -0,0 +1,6 @@ +#!/bin/sh +printf "\033]0;Applio\007" +. .venv/bin/activate + +clear +python app.py --open \ No newline at end of file diff --git a/run-install.sh b/run-install.sh new file mode 100644 index 000000000..344a09513 --- /dev/null +++ b/run-install.sh @@ -0,0 +1,87 @@ +#!/bin/sh +printf "\033]0;Installer\007" +clear +rm *.bat + +# Function to create or activate a virtual environment +prepare_install() { + if [ -d ".venv" ]; then + echo "Venv found. This implies Applio has been already installed or this is a broken install" + printf "Do you want to execute run-applio.sh? (Y/N): " >&2 + read -r r + r=$(echo "$r" | tr '[:upper:]' '[:lower:]') + if [ "$r" = "y" ]; then + ./run-applio.sh && exit 1 + else + echo "Ok! The installation will continue. Good luck!" + fi + . .venv/bin/activate + else + echo "Creating venv..." + requirements_file="requirements.txt" + echo "Checking if python exists" + if command -v python3 > /dev/null 2>&1; then + py=$(which python3) + echo "Using python3" + else + if python --version | grep -q 3.; then + py=$(which python) + echo "Using python" + else + echo "Please install Python3 or 3.11 manually." + exit 1 + fi + fi + + $py -m venv .venv + . .venv/bin/activate + python -m ensurepip + # Update pip within the virtual environment + pip3 install --upgrade pip + echo + echo "Installing Applio dependencies..." + python -m pip install -r requirements.txt + python -m pip uninstall torch torchvision torchaudio -y + python -m pip install torch==2.0.0 torchvision==0.15.1 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu117 + finish + fi +} + +# Function to finish installation (this should install missing dependencies) +finish() { + # Check if required packages are installed and install them if not + if [ -f "${requirements_file}" ]; then + installed_packages=$(python -m pip freeze) + while IFS= read -r package; do + expr "${package}" : "^#.*" > /dev/null && continue + package_name=$(echo "${package}" | sed 's/[<>=!].*//') + if ! echo "${installed_packages}" | grep -q "${package_name}"; then + echo "${package_name} not found. Attempting to install..." + python -m pip install --upgrade "${package}" + fi + done < "${requirements_file}" + else + echo "${requirements_file} not found. Please ensure the requirements file with required packages exists." + exit 1 + fi + clear + echo "Applio has been successfully downloaded. Run the file run-applio.sh to run the web interface!" + exit 0 +} + +# Loop to the main menu +if [ "$(uname)" = "Darwin" ]; then + if ! command -v brew >/dev/null 2>&1; then + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + else + brew install python + export PYTORCH_ENABLE_MPS_FALLBACK=1 + export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0 + fi +elif [ "$(uname)" != "Linux" ]; then + echo "Unsupported operating system. Are you using Windows...?" + echo "If yes, use the batch (.bat) file instead of this one!" + exit 1 +fi + +prepare_install \ No newline at end of file diff --git a/run-tensorboard.sh b/run-tensorboard.sh new file mode 100644 index 000000000..26e98b58b --- /dev/null +++ b/run-tensorboard.sh @@ -0,0 +1,6 @@ +#!/bin/sh +printf "\033]0;Tensorboard\007" +. .venv/bin/activate + +clear +python core.py tensorboard \ No newline at end of file