Ubuntu16.04从源码安装DensePose
Installing DensePose
DensePose官网 http://densepose.org/
DensePose代码 https://github.com/facebookresearch/Densepose
DensePose安装系统要求:有NVIDIA GPU的Linux系统,满足这一条件便可按照下面的步骤安装。
安装Anaconda
官网下载Linux版的Anaconda3,运行bash Anaconda3-5.2.0-Linux-x86_64.sh
。
安装caffe2(pytorch)
创建caffe2的conda环境
conda create -n densepose python=2.7
进入新创建的环境
source activate densepose
安装一些需要的库
(densepose)$ conda install -y future gflags leveldb mkl mkl-include numpy opencv protobuf
(densepose)$ conda install flask graphviz hypothesis jupyter matplotlib pydot pyyaml requests scikit-image scipy setuptools tornado
下载pytorch及其依赖的第三方库
# git clone --recursive https://github.com/pytorch/pytorch.git
(densepose)$ git clone -b v0.4.1 --recursive https://github.com/pytorch/pytorch.git # 下载v0.4.1分支代码
(densepose)$ cd pytorch
(densepose)$ git submodule update --init
编译并安装
(densepose)$ rm -rf build && mkdir build && cd build
(densepose)$ cmake -DCMAKE_PREFIX_PATH=~/anaconda3/envs/densepose -DCMAKE_INSTALL_PREFIX=~/anaconda3/envs/densepose -DUSE_NATIVE_ARCH=ON ..
(densepose)$ make -j32 install
测试是否安装成功
# To check if Caffe2 build was successful
(densepose)$ python2 -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"
# 输出Success即安装成功,否则失败
# To check if Caffe2 GPU build was successful
(densepose)$ python2 -c 'from caffe2.python import workspace; print(workspace.NumCudaDevices())'
# 输出8或者其他,表示显卡个数
安装cocoapi
# COCOAPI=/path/to/clone/cocoapi
(densepose)$ git clone https://github.com/cocodataset/cocoapi.git $COCOAPI
(densepose)$ cd $COCOAPI/PythonAPI
# Install into global site-packages
(densepose)$ make install
# Alternatively, if you do not have permissions or prefer
# not to install the COCO API into global site-packages
(densepose)$ python2 setup.py install --user
安装densepose
安装densepose
(densepose)$ mkdir $DENSEPOSE_DIR && cd $DENSEPOSE_DIR
(densepose)$ git clone https://github.com/facebookresearch/densepose
(densepose)$ cd densepose
(densepose)$ pip install -r requirements.txt # install Python dependencies
(densepose)$ make # set up python modules
(densepose)$ python2 detectron/tests/test_spatial_narrow_as_op.py # check that Detectron tests pass
(densepose)$ make ops # Build the custom operators library
(densepose)$ python2 detectron/tests/test_zero_even_op.py # check that the custom operator tests pass
下载densepose数据:
(densepose)$ cd DensePoseData
(densepose)$ bash get_densepose_uv.sh
如果需要训练,下载DensePose-COCO数据集:
(densepose)$ bash get_DensePose_COCO.sh
如果评价(evaluation),还需下载其他需要的文件:
(densepose)$ bash get_eval_data.sh
Inference with Pretrained Models
首先从这里下载与DensePose_ResNet101_FPN_s1x-e2e.yaml
相匹配的训练好的模型,并放在weights文件夹下,然后执行下面命令:
(densepose)$ python2 tools/infer_simple.py \
--cfg configs/DensePose_ResNet101_FPN_s1x-e2e.yaml \
--output-dir DensePoseData/infer_out/ \
--image-ext jpg \
--wts weights/DensePose_ResNet101_FPN_s1x-e2e.pkl \
DensePoseData/demo_data/demo_im.jpg
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!