GaussianHaircut/download_resource.bat

106 lines
3.1 KiB
Batchfile
Raw Normal View History

2025-02-17 00:55:28 +08:00
@echo off
2025-02-18 00:51:17 +08:00
setlocal enabledelayedexpansion
2025-02-17 23:40:30 +08:00
REM 设置环境变量
2025-02-18 00:51:17 +08:00
set "PROJECT_DIR=%~dp0"
set "PYTHONDONTWRITEBYTECODE=1"
2025-02-18 00:57:00 +08:00
set "GDOWN_CACHE=%PROJECT_DIR%\cache\gdown"
set "TORCH_HOME=%PROJECT_DIR%\cache\torch"
set "HF_HOME=%PROJECT_DIR%\cache\huggingface"
REM 检查 Python
python --version >nul 2>&1
if %ERRORLEVEL% neq 0 (
echo ERROR: Python not found
exit /b 1
)
2025-02-18 00:51:17 +08:00
REM 创建缓存目录
mkdir "%PROJECT_DIR%\cache\gdown" 2>nul
mkdir "%PROJECT_DIR%\cache\torch" 2>nul
mkdir "%PROJECT_DIR%\cache\huggingface" 2>nul
REM 创建资源目录
mkdir "%PROJECT_DIR%\resource\NeuralHaircut\pretrained_models\diffusion_prior" 2>nul
mkdir "%PROJECT_DIR%\resource\NeuralHaircut\pretrained_models\strand_prior" 2>nul
mkdir "%PROJECT_DIR%\resource\NeuralHaircut\PIXIE" 2>nul
mkdir "%PROJECT_DIR%\resource\Matte-Anything\pretrained" 2>nul
mkdir "%PROJECT_DIR%\resource\openpose\models" 2>nul
mkdir "%PROJECT_DIR%\resource\hyperIQA\pretrained" 2>nul
2025-02-17 08:44:22 +08:00
REM 安装gdown
2025-02-18 00:57:00 +08:00
python -m pip install --upgrade pip
2025-02-17 08:44:22 +08:00
python -m pip install gdown
2025-02-18 01:01:41 +08:00
REM 添加目录存在性检查
if not exist "%PROJECT_DIR%\ext" mkdir "%PROJECT_DIR%\ext"
if not exist "%PROJECT_DIR%\cache" mkdir "%PROJECT_DIR%\cache"
if not exist "%PROJECT_DIR%\resource" mkdir "%PROJECT_DIR%\resource"
2025-02-18 00:57:00 +08:00
REM 下载 NeuralHaircut 模型文件
2025-02-18 00:51:17 +08:00
cd "%PROJECT_DIR%\resource\NeuralHaircut"
2025-02-17 00:58:08 +08:00
python -m gdown --folder https://drive.google.com/drive/folders/1TCdJ0CKR3Q6LviovndOkJaKm8S1T9F_8
2025-02-18 00:57:00 +08:00
if %ERRORLEVEL% neq 0 (
echo ERROR: Failed to download NeuralHaircut models
exit /b 1
)
2025-02-18 00:51:17 +08:00
cd "%PROJECT_DIR%\resource\NeuralHaircut\pretrained_models\diffusion_prior"
2025-02-17 00:55:28 +08:00
python -m gdown 1_9EOUXHayKiGH5nkrayncln3d6m1uV7f
2025-02-18 00:57:00 +08:00
if %ERRORLEVEL% neq 0 (
echo ERROR: Failed to download diffusion prior model
exit /b 1
)
2025-02-18 00:51:17 +08:00
cd "%PROJECT_DIR%\resource\NeuralHaircut\PIXIE"
2025-02-17 08:31:59 +08:00
python -m gdown 1mPcGu62YPc4MdkT8FFiOCP629xsENHZf
2025-02-18 00:57:00 +08:00
if %ERRORLEVEL% neq 0 (
echo ERROR: Failed to download PIXIE model
exit /b 1
)
2025-02-18 00:51:17 +08:00
2025-02-18 00:57:00 +08:00
REM 下载 hyperIQA 模型文件
2025-02-18 00:51:17 +08:00
cd "%PROJECT_DIR%\resource\hyperIQA\pretrained"
2025-02-17 00:55:28 +08:00
python -m gdown 1OOUmnbvpGea0LIGpIWEbOyxfWx6UCiiE
2025-02-18 00:57:00 +08:00
if %ERRORLEVEL% neq 0 (
echo ERROR: Failed to download hyperIQA model
exit /b 1
)
2025-02-17 00:55:28 +08:00
2025-02-18 00:57:00 +08:00
REM 下载 Matte-Anything 模型文件
2025-02-18 00:51:17 +08:00
cd "%PROJECT_DIR%\resource\Matte-Anything\pretrained"
curl -L https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth -o sam_vit_h_4b8939.pth
2025-02-18 00:57:00 +08:00
if %ERRORLEVEL% neq 0 (
echo ERROR: Failed to download SAM model
exit /b 1
)
2025-02-18 00:51:17 +08:00
curl -L https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth -o groundingdino_swint_ogc.pth
2025-02-18 00:57:00 +08:00
if %ERRORLEVEL% neq 0 (
echo ERROR: Failed to download GroundingDINO model
exit /b 1
)
2025-02-17 00:55:28 +08:00
python -m gdown 1d97oKuITCeWgai2Tf3iNilt6rMSSYzkW
2025-02-18 00:57:00 +08:00
if %ERRORLEVEL% neq 0 (
echo ERROR: Failed to download Matte-Anything model
exit /b 1
)
2025-02-17 00:55:28 +08:00
2025-02-18 00:57:00 +08:00
REM 下载 OpenPose 模型文件
2025-02-18 00:51:17 +08:00
cd "%PROJECT_DIR%\resource\openpose"
python -m gdown 1Yn03cKKfVOq4qXmgBMQD20UMRRRkd_tV
2025-02-18 00:57:00 +08:00
if %ERRORLEVEL% neq 0 (
echo ERROR: Failed to download OpenPose models
exit /b 1
)
2025-02-18 00:51:17 +08:00
tar -xf models.tar.gz
2025-02-18 00:57:00 +08:00
if %ERRORLEVEL% neq 0 (
echo ERROR: Failed to extract OpenPose models
exit /b 1
)
2025-02-18 00:51:17 +08:00
cd "%PROJECT_DIR%"
2025-02-18 00:57:00 +08:00
echo All resources downloaded successfully!