TEXTure
- 環境配置
- 安裝kaolin這個包,這里可能會遇到各種問題
- 配置huggingface的訪問令牌
- 運行Text Conditioned Texture Generation指令
- 報錯1
- 報錯2
- 成功運行
- 查看結果
- 查看貼圖后的三維網格模型
環境配置
# 創建一個名為texture的環境
conda create -n texture python=3.9 -y# 激活環境
conda activate texture# 按照https://github.com/TEXTurePaper/TEXTurePaper的要求安裝requirements.txt里面的各種包
pip install -r requirements.txt
安裝kaolin這個包,這里可能會遇到各種問題
pip install kaolin==0.11.0 -f https://nvidia-kaolin.s3.us-east-2.amazonaws.com/{TORCH_VER}_{CUDA_VER}.html
建議直接上pytorch官網裝最新版本的cuda以及對應的pytorch,肯定就可以讓所有顯卡都可以用
(避免出現運行Text Conditioned Texture Generation指令里面的報錯1
的情況)
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
按下面截圖部分,查看torch_version和cuda_version
上面截圖顯示torch-2.0.1_cu117
可以來這個網頁來查看對應版本的torch,cuda的html
所以安裝kaolin這個包的命令應該為:
pip install kaolin==0.14.0 -f https://nvidia-kaolin.s3.us-east-2.amazonaws.com/torch-2.0.1_cu117.html
配置huggingface的訪問令牌
在使用Hugging Face的功能或資源之前,你應該通過運行 huggingface-cli login 命令登錄到你的Hugging Face帳戶,這將在默認位置存儲你的訪問令牌。這個訪問令牌將用于驗證你的身份,以便你可以訪問私有模型、數據集等。
下面是具體的步驟:
Stept1:設置好token
在setting里面的Access Tokens里面設置新的token:
Name隨便取
點擊Generate a token生成token
可以見下面的例子,已經設置好了一個名為texture的token
也可以參看這個鏈接如何設置Token:
https://huggingface.co/docs/hub/security-tokens
Step2:
打開終端或命令行界面:打開一個終端窗口或命令行界面,確保你可以在命令行中輸入指令。
運行登錄命令:在終端中運行以下命令,這會啟動登錄過程:
huggingface-cli login
在Token那里,輸入step1中得到的token,(直接復制粘貼即可),這里輸入的密碼是不可見的,就像ubuntu那樣
運行Text Conditioned Texture Generation指令
python -m scripts.run_texture --config_path=configs/text_guided/napoleon.yaml
可能會出現如下報錯:
報錯1
/home/aaa/anaconda3/envs/texture/lib/python3.9/site-packages/torch/cuda/__init__.py:146: UserWarning:
NVIDIA GeForce RTX 3090 with CUDA capability sm_86 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_37 sm_50 sm_60 sm_70.
If you want to use the NVIDIA GeForce RTX 3090 GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/warnings.warn(incompatible_device_warn.format(device_name, capability, " ".join(arch_list), device_name))
報錯原因:CUDA capability sm_86:算力8.6
上面表面上是說PyTorch,實際上是PyTorch依賴的CUDA版本的問題
翻譯一下就是:RTX 3090的算力是8.6,但是當前的PyTorch依賴的CUDA版本支持的算力只有3.7、5.0、6.0、7.0
算力7.0的顯卡可以在支持最高算力7.5的CUDA版本下運行,但是算力7.5的顯卡不可以在支持最高算力7.0的CUDA版本下運行
同理算力8.x的顯卡不可以在支持最高算力7.x的CUDA版本下運行
解決方法:
直接上pytorch官網裝最新版本的cuda以及對應的pytorch,肯定就可以讓所有顯卡都可以用。
參考博客
報錯2
解決上述問題后,重新執行命令,
出現報錯:
ValueError: Could not find a backend to open `experiments/napoleon/results/step_00010_rgb.mp4`` with iomode `wI`.
Based on the extension, the following plugins might add capable backends:FFMPEG: pip install imageio[ffmpeg]pyav: pip install imageio[pyav]
100% painting step 10/10 [02:03<00:00, 12.32s/it]
解決方法:
按照提示,安裝
pip install imageio[ffmpeg]pip install imageio[pyav]
成功運行
解決上述問題后,重新執行指令:
python -m scripts.run_texture --config_path=configs/text_guided/napoleon.yaml
運行成功!
查看結果
運行的結果會保存在experiments
文件夾下,experiments/napoleon/mesh/mesh.obj
就是貼圖后的三維網格模型
查看貼圖后的三維網格模型
可以打開mesh.obj文件在本地的位置
下載MeshLab軟件,然后就可以直接打開mesh.obj查看貼圖后的三維網格模型啦