optimize: run.sh
This commit is contained in:
parent
e15b37e0ca
commit
edcff1df04
64
run.sh
Normal file → Executable file
64
run.sh
Normal file → Executable file
@ -9,37 +9,49 @@ elif [[ "$(uname)" != "Linux" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
requirements_file="requirements.txt"
|
if [ -d ".venv" ]; then
|
||||||
|
echo "Activate venv..."
|
||||||
|
source .venv/bin/activate
|
||||||
|
else
|
||||||
|
echo "Create venv..."
|
||||||
|
requirements_file="requirements.txt"
|
||||||
|
|
||||||
# Check if Python 3.8 is installed
|
# Check if Python 3.8 is installed
|
||||||
if ! command -v python3.8 &> /dev/null; then
|
if ! command -v python3 &> /dev/null; then
|
||||||
echo "Python 3.8 not found. Attempting to install..."
|
echo "Python 3 not found. Attempting to install 3.8..."
|
||||||
if [[ "$(uname)" == "Darwin" ]] && command -v brew &> /dev/null; then
|
if [[ "$(uname)" == "Darwin" ]] && command -v brew &> /dev/null; then
|
||||||
brew install python@3.8
|
brew install python@3.8
|
||||||
elif [[ "$(uname)" == "Linux" ]] && command -v apt-get &> /dev/null; then
|
elif [[ "$(uname)" == "Linux" ]] && command -v apt-get &> /dev/null; then
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install python3.8
|
sudo apt-get install python3.8
|
||||||
|
else
|
||||||
|
echo "Please install Python 3.8 manually."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
python3 -m venv .venv
|
||||||
|
source .venv/bin/activate
|
||||||
|
|
||||||
|
# Check if required packages are installed and install them if not
|
||||||
|
if [ -f "${requirements_file}" ]; then
|
||||||
|
installed_packages=$(python3 -m pip freeze)
|
||||||
|
while IFS= read -r package; do
|
||||||
|
[[ "${package}" =~ ^#.* ]] && continue
|
||||||
|
package_name=$(echo "${package}" | sed 's/[<>=!].*//')
|
||||||
|
if ! echo "${installed_packages}" | grep -q "${package_name}"; then
|
||||||
|
echo "${package_name} not found. Attempting to install..."
|
||||||
|
python3 -m pip install --upgrade "${package}"
|
||||||
|
fi
|
||||||
|
done < "${requirements_file}"
|
||||||
else
|
else
|
||||||
echo "Please install Python 3.8 manually."
|
echo "${requirements_file} not found. Please ensure the requirements file with required packages exists."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if required packages are installed and install them if not
|
# Download models
|
||||||
if [ -f "${requirements_file}" ]; then
|
./tools/dlmodels.sh
|
||||||
installed_packages=$(python3.8 -m pip freeze)
|
|
||||||
while IFS= read -r package; do
|
|
||||||
[[ "${package}" =~ ^#.* ]] && continue
|
|
||||||
package_name=$(echo "${package}" | sed 's/[<>=!].*//')
|
|
||||||
if ! echo "${installed_packages}" | grep -q "${package_name}"; then
|
|
||||||
echo "${package_name} not found. Attempting to install..."
|
|
||||||
python3.8 -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
|
|
||||||
|
|
||||||
# Run the main script
|
# Run the main script
|
||||||
python3.8 infer-web.py --pycmd python3.8
|
python3 infer-web.py --pycmd python3
|
||||||
|
@ -524,7 +524,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo checking $hb
|
echo checking $hb
|
||||||
if [ -f "./pretrained/$hb" ]; then
|
if [ -f "./$hb" ]; then
|
||||||
echo $hb in ./pretrained checked.
|
echo $hb in ./pretrained checked.
|
||||||
else
|
else
|
||||||
echo failed. starting download from huggingface.
|
echo failed. starting download from huggingface.
|
||||||
@ -543,4 +543,3 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo required files check finished.
|
echo required files check finished.
|
||||||
read -p "Press any key to continue..." -n1 -s
|
|
||||||
|
Loading…
Reference in New Issue
Block a user