diff --git a/.gitignore b/.gitignore index 4bddcc0..c17024a 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ ext/diff_gaussian_rasterization_hair/third_party # Executable files scripts resource +resource1 Scripts pkgs envs diff --git a/README.md b/README.md index d39c014..be6645e 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,6 @@ resource/ │ └── ViTMatte_B_DIS.pth ├── NeuralHaircut/ # NeuralHaircut models │ ├── PIXIE/ -│ │ └── pixie_data.tar.gz │ └── pretrained_models/ │ ├── diffusion_prior/ │ │ ├── dif_ckpt.pth diff --git a/download_resource.bat b/download_resource.bat index c358bb3..22b2587 100644 --- a/download_resource.bat +++ b/download_resource.bat @@ -1,54 +1,127 @@ @echo off +setlocal enabledelayedexpansion @CALL SET PROJECT_DIR=%~dp0 -@CALL python -m pip install --upgrade pip -@CALL python -m pip install gdown +REM 创建基本目录结构 +@CALL mkdir ext 2>nul +@CALL mkdir cache 2>nul +@CALL mkdir cache\gdown 2>nul +@CALL mkdir cache\torch 2>nul +@CALL mkdir cache\huggingface 2>nul +@CALL mkdir resource 2>nul +@CALL mkdir resource\NeuralHaircut\pretrained_models\diffusion_prior 2>nul +@CALL mkdir resource\NeuralHaircut\PIXIE 2>nul +@CALL mkdir resource\hyperIQA\pretrained 2>nul +@CALL mkdir resource\Matte-Anything\pretrained 2>nul +@CALL mkdir resource\openpose 2>nul +@CALL mkdir resource\PIXIE\data 2>nul -@CALL mkdir resource\NeuralHaircut\PIXIE -@CALL mkdir resource\hyperIQA\pretrained -@CALL mkdir resource\Matte-Anything\pretrained -@CALL mkdir resource\openpose +@CALL python -m pip install --upgrade pip +@CALL python -m pip install gdown wget echo "Downloading NeuralHaircut..." @CALL cd resource\NeuralHaircut @CALL python -m gdown --folder https://drive.google.com/drive/folders/1TCdJ0CKR3Q6LviovndOkJaKm8S1T9F_8 -@CALL cd ..\.. +@CALL cd %PROJECT_DIR% @CALL cd resource\NeuralHaircut\pretrained_models\diffusion_prior @CALL python -m gdown 1_9EOUXHayKiGH5nkrayncln3d6m1uV7f -@CALL cd ..\..\..\.. +@CALL cd %PROJECT_DIR% + echo "Downloading PIXIE..." @CALL cd resource\NeuralHaircut\PIXIE @CALL python -m gdown 1mPcGu62YPc4MdkT8FFiOCP629xsENHZf @CALL tar -xvzf pixie_data.tar.gz -@CALL cd ..\..\.. +@CALL cd %PROJECT_DIR% + echo "Downloading hyperIQA..." @CALL cd resource\hyperIQA\pretrained @CALL python -m gdown 1OOUmnbvpGea0LIGpIWEbOyxfWx6UCiiE -@CALL cd ..\.. +@CALL cd %PROJECT_DIR% echo "Downloading Matte-Anything..." @CALL cd resource\Matte-Anything\pretrained @CALL curl -L -o sam_vit_h_4b8939.pth https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth @CALL curl -L -o groundingdino_swint_ogc.pth https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth @CALL python -m gdown 1d97oKuITCeWgai2Tf3iNilt6rMSSYzkW -@CALL cd ..\.. +@CALL cd %PROJECT_DIR% echo "Downloading openpose..." @CALL cd resource\openpose @CALL python -m gdown 1Yn03cKKfVOq4qXmgBMQD20UMRRRkd_tV @CALL tar -xvzf models.tar.gz -@CALL cd ..\.. +@CALL cd %PROJECT_DIR% -echo "Downloading SMPL-X..." +echo "Downloading SMPL-X 2020 (neutral SMPL-X model with the FLAME 2020 expression blendshapes)" +echo "You need to register at https://smpl-x.is.tue.mpg.de" +set /p SMPLX_USER="Username (SMPL-X): " +set /p SMPLX_PASS="Password (SMPL-X): " + +echo "Downloading PIXIE pretrained model and utilities" @CALL cd resource\PIXIE\data -@CALL python -m gdown 1d97oKuITCeWgai2Tf3iNilt6rMSSYzkW -@CALL cd ..\.. +@CALL wget --post-data "username=%SMPLX_USER%&password=%SMPLX_PASS%" "https://download.is.tue.mpg.de/download.php?domain=smplx&sfile=SMPLX_NEUTRAL_2020.npz&resume=1" -O SMPLX_NEUTRAL_2020.npz --no-check-certificate --continue +@CALL cd %PROJECT_DIR% + +echo "You need to register at https://pixie.is.tue.mpg.de/" +set /p PIXIE_USER="Username (PIXIE): " +set /p PIXIE_PASS="Password (PIXIE): " + +echo "Downloading PIXIE model..." +@CALL cd resource\PIXIE\data +@CALL wget --post-data "username=%PIXIE_USER%&password=%PIXIE_PASS%" "https://download.is.tue.mpg.de/download.php?domain=pixie&sfile=pixie_model.tar&resume=1" -O pixie_model.tar --no-check-certificate --continue +@CALL wget --post-data "username=%PIXIE_USER%&password=%PIXIE_PASS%" "https://download.is.tue.mpg.de/download.php?domain=pixie&sfile=utilities.zip&resume=1" -O utilities.zip --no-check-certificate --continue +@CALL tar -xf pixie_model.tar +@CALL unzip -o utilities.zip +@CALL cd %PROJECT_DIR% + +echo "Clean up temporary files" +@CALL cd %PROJECT_DIR%\ext\NeuralHaircut\PIXIE +@CALL del /f /q pixie_data.tar.gz +@CALL cd %PROJECT_DIR%\ext\openpose +@CALL del /f /q models.tar.gz +@CALL cd %PROJECT_DIR%\resource\PIXIE\data +@CALL del /f /q pixie_model.tar +@CALL del /f /q utilities.zip + +echo "Check downloads" +if not exist "%PROJECT_DIR%\resource\NeuralHaircut\pretrained_models\diffusion_prior\dif_ckpt.pth" ( + echo ERROR: Failed to download NeuralHaircut models + exit /b 1 +) + +if not exist "%PROJECT_DIR%\resource\Matte-Anything\pretrained\sam_vit_h_4b8939.pth" ( + echo ERROR: Failed to download SAM model + exit /b 1 +) + +if not exist "%PROJECT_DIR%\resource\Matte-Anything\pretrained\sam_vit_h_4b8939.pth" ( + echo ERROR: Failed to download SAM model + exit /b 1 +) + +if not exist "%PROJECT_DIR%\resource\Matte-Anything\pretrained\groundingdino_swint_ogc.pth" ( + echo ERROR: Failed to download GroundingDINO model + exit /b 1 +) + +if not exist "%PROJECT_DIR%\resource\PIXIE\data\SMPLX_NEUTRAL_2020.npz" ( + echo ERROR: Failed to download SMPL-X model + exit /b 1 +) + +if not exist "%PROJECT_DIR%\resource\PIXIE\data\pixie_model" ( + echo ERROR: Failed to download PIXIE model + exit /b 1 +) + +if not exist "%PROJECT_DIR%\resource\PIXIE\data\utilities" ( + echo ERROR: Failed to download PIXIE utilities + exit /b 1 +) echo "Download complete" - -echo pause +pause diff --git a/fetch_model.bat b/fetch_model.bat deleted file mode 100644 index e6f307b..0000000 --- a/fetch_model.bat +++ /dev/null @@ -1,26 +0,0 @@ -@echo off - -mkdir .\resource\PIXIE\data - -echo. -echo You need to register at https://smpl-x.is.tue.mpg.de -set /P username_smplx="jeffreytsai1004@gmail.com " -set /P password_smplx="XXXXXX" - -echo Downloading SMPL-X 2020 (neutral SMPL-X model)... -curl -o ".\resource\PIXIE\data\SMPLX_NEUTRAL_2020.npz" --post-fields "username=%username_smplx%&password=%password_smplx%" "https://download.is.tue.mpg.de/download.php?domain=smplx&sfile=SMPLX_NEUTRAL_2020.npz&resume=1" --insecure --continue - -echo. -echo You need to register at https://pixie.is.tue.mpg.de/ -set /P username_pixie="jeffreytsai1004@gmail.com " -set /P password_pixie="XXXXXX" - -echo Downloading PIXIE pretrained model... -curl -o ".\resource\PIXIE\data\pixie_model.tar" --post-fields "username=%username_pixie%&password=%password_pixie%" "https://download.is.tue.mpg.de/download.php?domain=pixie&sfile=pixie_model.tar&resume=1" --insecure --continue - -echo Downloading PIXIE utilities... -curl -o ".\resource\PIXIE\data\utilities.zip" --post-fields "username=%username_pixie%&password=%password_pixie%" "https://download.is.tue.mpg.de/download.php?domain=pixie&sfile=utilities.zip&resume=1" --insecure --continue - -echo. -echo Model download and extraction completed. -pause \ No newline at end of file diff --git a/install.bat b/install.bat index 6b21b9e..6a32e9f 100644 --- a/install.bat +++ b/install.bat @@ -1,13 +1,33 @@ @echo off +setlocal enabledelayedexpansion + +REM Set environment variables +set "PYTHONDONTWRITEBYTECODE=1" +set "GDOWN_CACHE=%PROJECT_DIR%\cache\gdown" +set "TORCH_HOME=%PROJECT_DIR%\cache\torch" +set "HF_HOME=%PROJECT_DIR%\cache\huggingface" @CALL "%~dp0micromamba.exe" shell init --shell cmd.exe --prefix "%~dp0\" -@CALL SET PROJECT_DIR=%~dp0 -@CALL SET CUDA_HOME="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\" -@CALL SET BLENDER_DIR="C:\Program Files\Blender Foundation\Blender 3.6\" -@CALL SET VS_DIR="D:\Program Files\Microsoft Visual Studio\2022\Community\" +@CALL SET PROJECT_DIR="%~dp0" +@CALL SET CUDA_HOME="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8" +@CALL SET BLENDER_DIR="C:\Program Files\Blender Foundation\Blender 3.6" +@CALL SET VS_DIR="D:\Program Files\Microsoft Visual Studio\2022\Community" @CALL SET VS_VCVARS="%VS_DIR%\VC\Auxiliary\Build\vcvars64.bat" @CALL SET PATH=%CUDA_HOME%\bin;%PROJECT_DIR%\condabin;%PATH% +REM Check prerequisites +where git >nul 2>&1 +if %ERRORLEVEL% neq 0 ( + echo ERROR: Git not found + exit /b 1 +) + +where cmake >nul 2>&1 +if %ERRORLEVEL% neq 0 ( + echo ERROR: CMake not found + exit /b 1 +) + REM Create gaussian_splatting_hair environment @CALL "%~dp0micromamba.exe" create -n gaussian_splatting_hair python=3.9 ^ pytorch=2.1.1 torchvision=0.16.1 torchaudio=2.1.1 pytorch-cuda=11.8 ^ @@ -22,83 +42,89 @@ REM Create gaussian_splatting_hair environment REM Clone repositories @CALL cd %PROJECT_DIR% -@CALL mkdir ext -@CALL cd ext -@CALL git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose --depth 1 -@CALL cd openpose && git submodule update --init --recursive --remote -@CALL cd .. -@CALL git clone https://github.com/hustvl/Matte-Anything -@CALL cd Matte-Anything && git clone https://github.com/IDEA-Research/GroundingDINO.git -@CALL cd .. -@CALL git clone https://github.com/egorzakharov/NeuralHaircut.git --recursive -@CALL git clone https://github.com/facebookresearch/pytorch3d -@CALL cd pytorch3d && git checkout 2f11ddc5ee7d6bd56f2fb6744a16776fab6536f7 -@CALL cd .. -@CALL git clone https://github.com/camenduru/simple-knn -@CALL git clone https://github.com/g-truc/glm -@CALL cd glm && git checkout 5c46b9c07008ae65cb81ab79cd677ecc1934b903 -@CALL cd .. -@CALL git clone --recursive https://github.com/NVIDIAGameWorks/kaolin -@CALL cd kaolin && git checkout v0.15.0 -@CALL cd .. -@CALL git clone https://github.com/SSL92/hyperIQA -@CALL git clone https://github.com/yfeng95/PIXIE - -REM Copy resources +@CALL git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose %PROJECT_DIR%\ext\openpose --depth 1 +@CALL cd %PROJECT_DIR%\ext\openpose && git submodule update --init --recursive --remote +@CALL cd %PROJECT_DIR% +@CALL git clone https://github.com/hustvl/Matte-Anything %PROJECT_DIR%\ext\Matte-Anything +@CALL git clone https://github.com/IDEA-Research/GroundingDINO.git %PROJECT_DIR%\ext\Matte-Anything\GroundingDINO +@CALL git clone https://github.com/egorzakharov/NeuralHaircut.git --recursive %PROJECT_DIR%\ext\NeuralHaircut +@CALL git clone https://github.com/facebookresearch/pytorch3d %PROJECT_DIR%\ext\pytorch3d +@CALL cd %PROJECT_DIR%\ext\pytorch3d && git checkout 2f11ddc5ee7d6bd56f2fb6744a16776fab6536f7 +@CALL cd %PROJECT_DIR% +@CALL git clone https://github.com/camenduru/simple-knn %PROJECT_DIR%\ext\simple-knn +@CALL git clone https://github.com/g-truc/glm %PROJECT_DIR%\ext\diff_gaussian_rasterization_hair\third_party\glm +@CALL cd %PROJECT_DIR%\ext\diff_gaussian_rasterization_hair\third_party\glm && git checkout 5c46b9c07008ae65cb81ab79cd677ecc1934b903 +@CALL cd %PROJECT_DIR% +@CALL git clone https://github.com/SSL92/hyperIQA %PROJECT_DIR%\ext\hyperIQA @CALL cd %PROJECT_DIR% -@CALL copy /E /I /Y "%PROJECT_DIR%\resource\NeuralHaircut\*" "%PROJECT_DIR%\ext\NeuralHaircut\" -@CALL copy /E /I /Y "%PROJECT_DIR%\resource\hyperIQA\*" "%PROJECT_DIR%\ext\hyperIQA\" -@CALL copy /E /I /Y "%PROJECT_DIR%\resource\openpose\*" "%PROJECT_DIR%\ext\openpose\" -@CALL copy /E /I /Y "%PROJECT_DIR%\resource\PIXIE\data\*" "%PROJECT_DIR%\ext\PIXIE\data\" -@CALL copy /E /I /Y "%PROJECT_DIR%\resource\NeuralHaircut\PIXIE\data\*" "%PROJECT_DIR%\ext\NeuralHaircut\PIXIE\data\" -@CALL copy /E /I /Y "%PROJECT_DIR%\resource\Matte-Anything\pretrained\*" "%PROJECT_DIR%\ext\Matte-Anything\pretrained\" -@CALL cd %PROJECT_DIR%\ext\NeuralHaircut\PIXIE\data +REM Download Neural Haircut files +@CALL cd %PROJECT_DIR%\ext\NeuralHaircut +@CALL python -m gdown --folder https://drive.google.com/drive/folders/1TCdJ0CKR3Q6LviovndOkJaKm8S1T9F_8 +@CALL cd %PROJECT_DIR%\ext\NeuralHaircut\pretrained_models\diffusion_prior +@CALL python -m gdown 1_9EOUXHayKiGH5nkrayncln3d6m1uV7f +@CALL cd %PROJECT_DIR%\ext\NeuralHaircut\PIXIE +@CALL python -m gdown 1mPcGu62YPc4MdkT8FFiOCP629xsENHZf @CALL tar -xvzf pixie_data.tar.gz +@CALL del /f /q pixie_data.tar.gz +@CALL cd %PROJECT_DIR%\ext\hyperIQA +@CALL mkdir pretrained +@CALL cd pretrained +@CALL python -m gdown 1OOUmnbvpGea0LIGpIWEbOyxfWx6UCiiE @CALL cd %PROJECT_DIR% @CALL "%~dp0condabin\micromamba.bat" deactivate REM Create matte_anything environment +@CALL cd %PROJECT_DIR% @CALL "%~dp0micromamba.exe" create -n matte_anything python=3.9 ^ pytorch=2.0.0 pytorch-cuda=11.8 torchvision tensorboard timm=0.5.4 ^ opencv=4.5.3 mkl=2024.0 setuptools=58.2.0 easydict scikit-image gradio=3.46.1 ^ -c pytorch -c nvidia -c conda-forge -r "%~dp0\" -y @CALL "%~dp0condabin\micromamba.bat" activate matte_anything -@CALL python -m pip install fairscale wget -@CALL cd %PROJECT_DIR%\ext\Matte-Anything -@CALL pip install git+https://github.com/facebookresearch/segment-anything.git -@CALL git clone https://github.com/facebookresearch/detectron2 -@CALL cd detectron2 -@CALL CALL %VS_VCVARS% && python setup.py build develop +@CALL cd %PROJECT_DIR%\ext\Matte-Anything\ +@CALL python -m pip install git+https://github.com/facebookresearch/segment-anything.git +@CALL python -m pip install git+https://github.com/facebookresearch/detectron2.git @CALL cd %PROJECT_DIR%\ext\Matte-Anything\GroundingDINO -@CALL pip install -e . -@CALL pip install supervision==0.22.0 -@CALL cd %PROJECT_DIR% +@CALL python -m pip install -e . +@CALL python -m pip install supervision==0.22.0 +@CALL cd %PROJECT_DIR%\ext\Matte-Anything +@CALL mkdir pretrained +@CALL cd pretrained +@CALL curl -L -o sam_vit_h_4b8939.pth https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth +@CALL curl -L -o groundingdino_swint_ogc.pth https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth +@CALL python -m gdown 1d97oKuITCeWgai2Tf3iNilt6rMSSYzkW @CALL "%~dp0condabin\micromamba.bat" deactivate REM Create openpose environment +@CALL cd %PROJECT_DIR% +@CALL git submodule update --init --recursive --remote @CALL "%~dp0micromamba.exe" create -n openpose cmake=3.20 -c conda-forge -r "%~dp0\" -y @CALL "%~dp0condabin\micromamba.bat" activate openpose @CALL cd %PROJECT_DIR%\ext\openpose +@CALL python -m gdown 1Yn03cKKfVOq4qXmgBMQD20UMRRRkd_tV +@CALL tar -xvzf models.tar.gz +@CALL del /f /q models.tar.gz @CALL mkdir build @CALL cd build @CALL CALL %VS_VCVARS% -@CALL cmake .. -G "Visual Studio 16 2019" -A x64 -T host=x64 -DBUILD_PYTHON=true -DUSE_CUDNN=off +@CALL cmake .. -G "Visual Studio 17 2022" -A x64 -T host=x64 -DBUILD_PYTHON=true -DUSE_CUDNN=off @CALL cmake --build . --config Release @CALL cd %PROJECT_DIR% @CALL "%~dp0condabin\micromamba.bat" deactivate REM Create pixie-env environment +@CALL cd %PROJECT_DIR% @CALL "%~dp0micromamba.exe" create -n pixie-env python=3.8 ^ pytorch=2.0.0 torchvision torchaudio pytorch-cuda=11.8 fvcore kornia matplotlib ^ - -c pytorch -c nvidia -c fvcore -c conda-forge -r "%~dp0\" -y + -c pytorch -c nvidia -c fvcore -c conda-forge -c pytorch3d -r "%~dp0\" -y @CALL "%~dp0condabin\micromamba.bat" activate pixie-env -@CALL pip install pytorch3d==0.7.5 +@CALL copy %PROJECT_DIR%\resource\PIXIE\data\* %PROJECT_DIR%\ext\PIXIE\ @CALL cd %PROJECT_DIR%\ext\PIXIE +@CALL pip install pytorch3d==0.7.5 @CALL pip install pyyaml==5.4.1 @CALL pip install git+https://github.com/1adrianb/face-alignment.git@54623537fd9618ca7c15688fd85aba706ad92b59 @CALL cd %PROJECT_DIR%