Home

Awesome

SelfGeo

This repository contains the code of "SelfGeo: Self-supervised and Geodesic-consistent Estimation of Keypoints on Deformable Shapes", which has been accepted in the ECCV2024.

Authors: Mohammad Zohaib, Luca Cosmo, Alessio Del Bue

<p align="center"> <img src="images/selfgeo_overview.gif" alt="over_view" width="700"/> <img src="images/geodesic_loss.gif" alt="geodesic_loss" width="350"/> <img src="images/temporal_loss.gif" alt="temporal_loss" width="350"/> </p>

Abstract:

<p align="justify"> Unsupervised 3D keypoints estimation from Point Cloud Data (PCD) is a complex task, even more challenging when an object shape is deforming. As keypoints should be semantically and geometrically consistent across all the 3D frames – each keypoint should be anchored to a specific part of the deforming shape irrespective of intrinsic and extrinsic motion. This paper presents, "SelfGeo", a self-supervised method that computes persistent 3D keypoints of non-rigid objects from arbitrary PCDs without the need of human annotations. The gist of SelfGeo is to estimate keypoints between frames that respect invariant properties of deforming bodies. Our main contribution is to enforce that keypoints deform along with the shape while keeping constant geodesic distances among them. This principle is then propagated to the design of a set of losses which minimization let emerge repeatable keypoints in specific semantic locations of the non-rigid shape. We show experimentally that the use of geodesic has a clear advantage in challenging dynamic scenes and with different classes of deforming shapes (humans and animals). </p>

Installation

We highly recommend running this project with a conda environment. The code is tested on Python 3.6.12, Torch 1.10.1, Torchvision 0.11.2. We recommend using Python 3.6+ and installing all the dependencies as provided in "selfgeo.yml". Create a conda environment by following:

git clone https://github.com/IIT-PAVIS/SelfGeo.git
cd SelfGeo

conda env create -f selfgeo.yml
conda activate sg

Datasets

We use the following four datasets; CAPE, Deforming Things 4D, ITOP, and DFAUST. All the datasets are publicly available. We provide a sample set for the CAPE and Deforming Things 4D in the folder "dataset" for an initial start.

CAPE dataset:

Download the sample of the processed CAPE dataset from the following link:

https://drive.google.com/drive/folders/1NP9Ow8CbKAVhhmrHHlZ_MAhle5ehilPj?usp=sharing

CAPE/
  |_ train
      |__ geodesic
            |__ *.npy (containing the geodesics)
            ...
      |__ pcd
            |__ *.npy (containing the point clouds)
            ...      
  |_ test
      |__ geodesic
            |__ *.npy (containing the geodesics)
            ...
      |__ pcd
            |__ *.npy (containing the point clouds)
            ...      
  |_ val
      |__ geodesic
            |__ *.npy (containing the geodesics)
            ...
      |__ pcd
            |__ *.npy (containing the point clouds)
            ...      

Deforming Things 4D dataset:

In the dataset directory /dataset/DeformingThings4D/, we provide a sample of the original dataset original_dataset, sdk.py and splits.

DeformingThings4D/
  |_ correspondences_for_pck
      |__ tigerD8H_Jump0
            |__ tigerD8H_Jump0.npz
            ...
      |__ tigerD8H_Jump1
            |__ tigerD8H_Jump1.npz
            ...      
  |_ original_dataset
      |__ tigerD8H_Jump0
            |__ screenshots
            |__ tigerD8H_Jump0.anime
            ...
      |__ tigerD8H_Jump1
            |__ screenshots
            |__ tigerD8H_Jump1.anime
            ...   
  |_ pcds_geodesics
      |__ geodesic
           tigerD8H_Jump0
            |__ 0_tigerD8H_Jump0.npy
            |__ 1_tigerD8H_Jump0.npy
            ...   
	   tigerD8H_Jump1
            |__ 0_tigerD8H_Jump1.npy
            |__ 1_tigerD8H_Jump1.npy
            ...   
      |__ pcds
           tigerD8H_Jump0
            |__ 0_tigerD8H_Jump0.npy
            |__ 1_tigerD8H_Jump0.npy
            ...   
	   tigerD8H_Jump1
            |__ 0_tigerD8H_Jump1.npy
            |__ 1_tigerD8H_Jump1.npy
            ...     
  |_ splits
      |__ tigerD8H_test.txt
      |__ tigerD8H_train.txt
      |__ tigerD8H_val.txt

Training

SelfGeo can be trained for any deformable dataset. These instructions show how the train.py can be used for CAPE and Deforming Things 4D dataset.

First, set the training parameters using the configuration file "config/config_cape.yaml" or "config/config_deforming_Things.yaml". For example:

For the CAPE dataset:

  split: train  # train the network
  class_name: human   # Remains the same for the CAPE dataset
  pcd_root: dataset/CAPE_00032   # directory of the CAPE dataset
  best_model_path: 'path_to_best_weights' 

For the Deforming Things 4D dataset:

  split: train  # train the network
  class_name: tigerD8H  # Change the object’s name
  pcd_root: dataset/DeformingThings4D/pcds_geodesics  # pcds and geodesics created from the Deforming Things 4D dataset
  best_model_path: 'path_to_best_weights' 

Second, open train.py and change the data loader and hydra configuration. For example:

For the CAPE dataset:

  data loader: import data_loader_cape as dataset
  hydra_config: @hydra.main(config_path='config', config_name='config_cape')

For the Deforming Things 4D dataset:

  data loader: import data_loader_deformingThings4d as dataset
  hydra_config: @hydra.main(config_path='config', config_name='config_deforming_Things') 

From the SelfGeo directory, run python train.py for starting the training: Follow the training progress using output/train/class_name/. The best weights will be saved in the same folder with the name Best_model_class_name_12kp.pth. By default, the configurations are set for the CAPE dataset.

Inference

Set the parameters using the configuration file "config/config.yaml" or "config/config_deforming_Things.yaml" as:

For the CAPE dataset:

  split: test  # test the network
  class_name: human   # Remains the same for the CAPE dataset
  pcd_root: dataset/CAPE_00032   # directory of the CAPE dataset
  best_model_path: outputs/train/human/Best_model_human_12kp.pth # Path of the trained model

For the Deforming Things 4D dataset:

  split: train  # train the network
  class_name: tigerD8H  # Change the object’s name
  pcd_root: dataset/DeformingThings4D/pcds_geodesics  # pcds and geodesics created from the Deforming Things 4D dataset
  best_model_path: outputs/train/tigerD8H/Best_model_tigerD8H_12kp.pth  # tigerD8H is the class_name

Same as before, open test.py and change the data loader and hydra configuration. For example:

For the CAPE dataset:

  data loader: import data_loader_cape as dataset
  hydra_config: @hydra.main(config_path='config', config_name='config_cape')

For the Deforming Things 4D dataset:

  data loader: import data_loader_deformingThings4d as dataset
  hydra_config: @hydra.main(config_path='config', config_name='config_deforming_Things') 

From the SelfGeo directory, run python test.py for testing: Find the results in directory output/test/class_name/.

Computing Probability of Correct Keypoints (PCK)

Visualizations

To save the qualitative results (visualizations), you can run python test.py, keeping save_results: True in the "config_cape.yml" or "config_deforming_Things.yml" file. You will find the output files in the "outputs/test/class_id/*_visualizations".

The estimated keypoints on the Tiger should look like:

<p align="center"> <img src="images/visualizations_tiger.png" height="150"/> </p>

The estimated keypoints on the CAPE human should look like:

<p align="center"> <img src="images/visualizations_human.png" height="150"/> </p>

Cite us:

If you use this project for your research, please cite as:

@InProceedings{zohaib2024selfgeo,
    author    = {Zohaib, Mohammad and Cosmo, Luca and Del Bue, Alessio},
    title     = {SelfGeo: Self-supervised and Geodesic-consistent Estimation of Keypoints on Deformable Shapes},
    booktitle = {Proceedings of the European Conference on Computer Vision (ECCV)},
    month     = {July},
    year      = {2024},
    pages     = {--}
}

Previous related works:

  1. SC3K: Self-supervised and Coherent 3D Keypoints Estimation from Rotated, Noisy, and Decimated Point Cloud Data

  2. CDHN: Cross-Domain Hallucination Network for 3D Keypoints Estimation

  3. 3D Key-Points Estimation from Single-View RGB Images

Acknowledgements:

<p align="justify"> We would like to acknowledge <a href="https://www.iit.it/it/people/pietro-morerio">Pietro Morerio</a> for fruitful discussions. This work was carried out within the frameworks of the project “RAISE - Robotics, and AI for Socio-economic Empowerment” and the PRIN 2022 project n. 2022AL45R2 (EYE-FI.AI, CUP H53D2300350-0001). This work has been supported by European Union - NextGenerationEU. </p>