【代码复现】UNOPose: Unseen Object Pose Estimation with an Unposed RGB-D Reference Image

安装UNOPose环境

  1. 修改requirements.txt文件:

    1. 第59行:注释torch==2.2.0+cu118
    2. 第61行:注释torchvision==0.17.0+cu118
  2. 创建环境:

    1
    conda create --name unopose python=3.10.12

  3. 激活环境:

    1
    conda activate unopose

  4. 安装依赖:

    1
    2
    3
    4
    5
    6
    pip3 install torch==2.0.0 torchvision==0.15.0 --index-url https://download.pytorch.org/whl/cu117
    pip3 install mmcv==2.2.0 -f https://download.openmmlab.com/mmcv/dist/cu117/torch2.0/index.html

    pip3 install -r requirements.txt

    python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'

  5. 安装bop_toolkit:

    1
    2
    cd third_party/bop_toolkit
    python setup.py install

  6. 安装pointnet2:

    1
    2
    cd core/unopose/model/pointnet2/
    pip3 install -e .

数据集下载

  1. 在代码对应的Hugging Face🤗数据集仓库中下载数据集配对文件:

    • https://huggingface.co/datasets/shanice-l/UNOPose_data/resolve/main/CustomSamAutomaticMaskGeneratorOnerefTargetsCrosssceneRot50Refvisib_ycbv-test.json
    • https://huggingface.co/datasets/shanice-l/UNOPose_data/resolve/main/CustomSamAutomaticMaskGenerator_test_oneref_targets_crossscene_rot50_refvisib_ycbv.json
    • https://huggingface.co/datasets/shanice-l/UNOPose_data/resolve/main/megapose_gso_fixed_obj_id_to_visib0_8_scene_im_inst_ids.json
    • https://huggingface.co/datasets/shanice-l/UNOPose_data/resolve/main/megapose_gso_fixed_valid_inst_ids.json
    • https://huggingface.co/datasets/shanice-l/UNOPose_data/resolve/main/megapose_shapenetcore_fixed_obj_id_to_visib0_8_scene_im_inst_ids.json
    • https://huggingface.co/datasets/shanice-l/UNOPose_data/resolve/main/megapose_shapenetcore_fixed_valid_inst_ids.json
    • https://huggingface.co/datasets/shanice-l/UNOPose_data/resolve/main/test_ref_targets_crossscene_rot50.json
  2. 下载YCB-V数据集的部份数据:

    • https://huggingface.co/datasets/bop-benchmark/ycbv/resolve/main/ycbv_test_all.zip
    • https://huggingface.co/datasets/bop-benchmark/ycbv/resolve/main/ycbv_models.zip
    • https://huggingface.co/datasets/bop-benchmark/ycbv/resolve/main/ycbv_base.zip

下载预训练模型

执行:

1
python core/unopose/scripts/download_and_save_dinov2_ckpt.py

下载的预训练模型如下:

1
2
$ ls checkpoints/
timm_vit_base_patch14_reg4_dinov2_lvd142m.pth

运行代码

解压ycbv_test_all.zip,并将上述下载的7个配对文件组织如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
datasets
├── BOP_DATASETS
│   └── ycbv
│   ├── models_eval -> /data1/dataset/unopose/ycbv/models_eval/
│   ├── test -> /data1/dataset/unopose/ycbv/test/
│   ├── test_ref_targets_crossscene_rot50.json -> /data1/dataset/unopose/test_ref_targets_crossscene_rot50.json
│   └── test_targets_bop19.json -> /data1/dataset/unopose/ycbv/ycbv/test_targets_bop19.json
├── MegaPose-Training-Data
│   ├── megapose_gso_fixed_obj_id_to_visib0_8_scene_im_inst_ids.json -> /data1/dataset/unopose/megapose_gso_fixed_obj_id_to_visib0_8_scene_im_inst_ids.json
│   ├── megapose_gso_fixed_valid_inst_ids.json -> /data1/dataset/unopose/megapose_gso_fixed_valid_inst_ids.json
│   ├── megapose_shapenetcore_fixed_obj_id_to_visib0_8_scene_im_inst_ids.json -> /data1/dataset/unopose/megapose_shapenetcore_fixed_obj_id_to_visib0_8_scene_im_inst_ids.json
│   └── megapose_shapenetcore_fixed_valid_inst_ids.json -> /data1/dataset/unopose/megapose_shapenetcore_fixed_valid_inst_ids.json
└── segmentation
└── CustomSamAutomaticMaskGenerator_test_oneref_targets_crossscene_rot50_refvisib_ycbv.json -> /data1/dataset/unopose/CustomSamAutomaticMaskGenerator_test_oneref_targets_crossscene_rot50_refvisib_ycbv.json

6 directories, 7 files

执行:

1
./core/unopose/save_unopose.sh configs/main_cfg.py <gpu_ids> checkpoints/timm_vit_base_patch14_reg4_dinov2_lvd142m.pth