Multi_BG_Removal / Multi_Birefnet_for_Background_Removal.bat
NegiTurkey's picture
Update Multi_Birefnet_for_Background_Removal.bat
4eef563 verified
raw
history blame
1.4 kB
@echo off
pushd %~dp0
set BIREFNET_PORT=7860
set HOME=%USERPROFILE%
set CUDA_VERSION=
:: Check if CUDA 12.1 is installed
python -c "import torch; print(torch.version.cuda)" 2>nul | findstr /C:"12.1" >nul
if %errorlevel% == 0 (
set CUDA_VERSION=12.1
) else (
set CUDA_VERSION=none
)
if not exist MBBR_venv\ (
python -m venv MBBR_venv
call MBBR_venv\Scripts\activate
python -m pip install --upgrade pip
REM pip install Multi_Birefnet_for_Background_Removal
git clone https://huggingface.co/spaces/NegiTurkey/Multi_Birefnetfor_Background_Removal temp
REM Move all files and folders from temp to the parent directory
del /q temp\*.bat
xcopy temp\* .\
REM Remove the now-empty temp directory
rmdir /s /q temp
if "%CUDA_VERSION%"=="12.1" (
pip install torch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2 --index-url https://download.pytorch.org/whl/cu121
powershell -Command "(Get-Content app.py) -replace 'to\(\"cpu\"\)', 'to(\"cuda\")' | Set-Content app.py"
) else (
pip install torch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2 --index-url https://download.pytorch.org/whl/cpu
)
pip install -r requirements.txt
)
call MBBR_venv\Scripts\activate
start http://localhost:%BIREFNET_PORT%/
echo http://localhost:%BIREFNET_PORT%/
python -m app --port %BIREFNET_PORT%
REM python -m app --port %BIREFNET_PORT%
popd