{"id":20373504,"url":"https://github.com/megengine/omnet","last_synced_at":"2025-04-12T06:51:51.598Z","repository":{"id":46383917,"uuid":"397144069","full_name":"MegEngine/OMNet","owner":"MegEngine","description":"OMNet: Learning Overlapping Mask for Partial-to-Partial Point Cloud Registration, ICCV 2021, MegEngine implementation.","archived":false,"fork":false,"pushed_at":"2022-02-06T16:24:50.000Z","size":8266,"stargazers_count":40,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-12T06:51:46.239Z","etag":null,"topics":["deep-learning","megengine"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MegEngine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-17T07:01:52.000Z","updated_at":"2024-12-11T03:18:46.000Z","dependencies_parsed_at":"2022-09-21T12:13:26.113Z","dependency_job_id":null,"html_url":"https://github.com/MegEngine/OMNet","commit_stats":null,"previous_names":["megvii-research/omnet"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegEngine%2FOMNet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegEngine%2FOMNet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegEngine%2FOMNet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegEngine%2FOMNet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MegEngine","download_url":"https://codeload.github.com/MegEngine/OMNet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248530604,"owners_count":21119595,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","megengine"],"created_at":"2024-11-15T01:18:41.993Z","updated_at":"2025-04-12T06:51:51.576Z","avatar_url":"https://github.com/MegEngine.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [ICCV 2021] OMNet: Learning Overlapping Mask for Partial-to-Partial Point Cloud Registration\n\nThis is the official implementation (MegEngine implementation) of our ICCV2021 paper [OMNet](https://openaccess.thecvf.com/content/ICCV2021/papers/Xu_OMNet_Learning_Overlapping_Mask_for_Partial-to-Partial_Point_Cloud_Registration_ICCV_2021_paper.pdf). For our Pytorch implementation, please refer to [this repo](https://github.com/hxwork/OMNet_Pytorch).\n\nOur presentation video: [[Youtube](https://www.youtube.com/watch?v=u2lTKsom8oU)][[Bilibili](https://www.bilibili.com/video/BV1Ef4y1J7XP/)].\n\n## Our Poster\n\n![image](./images/OMNet_poster.png)\n\n## Dependencies\n\n* MegEngine==1.6.0\n* Other requirements please refer to`requirements.txt`.\n* Add`frequency_weighted_cross_entropy` to MegEngine source code.\n\nMegEngine==1.6.0 does not support `frequency_weighted_cross_entropy`, so I write this function based on `cross_entropy` in `loss.py` of the original MegEngine source code, whose location should be like this:\n\n(1) conda environment\n\n`[your_conda_env_path]/lib/[python3.x]/site-packages/megengine/functional/loss.py`.\n\n(2) original python environment\n\n`/usr/local/lib/[python3.x]/dist-packages/megengine/functional/loss.py`.\n\nUse your own path to replace the content in `[]`.\n\n```\nfrom .math import sum\n\n\n@_reduce_output\ndef frequency_weighted_cross_entropy(\n    pred: Tensor,\n    label: Tensor,\n    weight: Tensor = None,\n    axis: int = 1,\n    with_logits: bool = True,\n    label_smooth: float = 0,\n    reduction: str = \"mean\",\n) -\u003e Tensor:\n\n    n0 = pred.ndim\n    n1 = label.ndim\n    assert n0 == n1 + 1, (\"target ndim must be one less than input ndim; input_ndim={} \" \"target_ndim={}\".format(n0, n1))\n\n    if weight is not None:\n        weight = weight / sum(weight)\n        class_weight = weight[label.flatten().astype(np.int32)].reshape(label.shape)\n\n    ls = label_smooth\n\n    if with_logits:\n        logZ = logsumexp(pred, axis)\n        primary_term = indexing_one_hot(pred, label, axis)\n    else:\n        logZ = 0\n        primary_term = log(indexing_one_hot(pred, label, axis))\n    if ls is None or type(ls) in (int, float) and ls == 0:\n        if weight is None:\n            return logZ - primary_term\n        else:\n            return sum((logZ - primary_term) * class_weight, axis=1, keepdims=True) / sum(class_weight, axis=1, keepdims=True)\n    if not with_logits:\n        pred = log(pred)\n    if weight is None:\n        return logZ - ls * pred.mean(axis) - (1 - ls) * primary_term\n    else:\n        return sum((logZ - ls * pred.mean(axis) -\n                    (1 - ls) * primary_term) * class_weight, axis=1, keepdims=True) / sum(class_weight, axis=1, keepdims=True)\n```\n\n## Data Preparation\n\n### OS data\n\nWe refer the original data from PointNet as OS data, where point clouds are only sampled once from corresponding CAD models. We offer two ways to use OS data, (1) you can download this data from its original link [original_OS_data.zip](http://modelnet.cs.princeton.edu/). (2) you can also download the data that has been preprocessed by us from link [our_OS_data.zip](https://drive.google.com/file/d/1rXnbXwD72tkeu8x6wboMP0X7iL9LiBPq/view?usp=sharing).\n\n### TS data\n\nSince OS data incurs over-fitting issue, we propose our TS data, where point clouds are randomly sampled twice from CAD models. You need to download our preprocessed ModelNet40 dataset first, where 8 axisymmetrical categories are removed and all CAD models have 40 randomly sampled point clouds. The download link is [TS_data.zip](https://drive.google.com/file/d/1DPBBI3Ulvp2Mx7SAZaBEyvADJzBvErFF/view?usp=sharing). All 40 point clouds of a CAD model are stacked to form a (40, 2048, 3) numpy array, you can easily obtain this data by using following code:\n\n```\nimport numpy as np\npoints = np.load(\"path_of_npy_file\")\nprint(points.shape, type(points))  # (40, 2048, 3), \u003cclass 'numpy.ndarray'\u003e\n```\n\nThen, you need to put the data into `./dataset/data`, and the contents of directories are as follows:\n\n```\n./dataset/data/\n├── modelnet40_half1_rm_rotate.txt\n├── modelnet40_half2_rm_rotate.txt\n├── modelnet_os\n│   ├── modelnet_os_test.pickle\n│   ├── modelnet_os_train.pickle\n│   ├── modelnet_os_val.pickle\n│   ├── test [1146 entries exceeds filelimit, not opening dir]\n│   ├── train [4194 entries exceeds filelimit, not opening dir]\n│   └── val [1002 entries exceeds filelimit, not opening dir]\n└── modelnet_ts\n    ├── modelnet_ts_test.pickle\n    ├── modelnet_ts_train.pickle\n    ├── modelnet_ts_val.pickle\n    ├── shape_names.txt\n    ├── test [1146 entries exceeds filelimit, not opening dir]\n    ├── train [4196 entries exceeds filelimit, not opening dir]\n    └── val [1002 entries exceeds filelimit, not opening dir]\n```\n\n## Training and Evaluation\n\n### Begin training\n\nFor ModelNet40 dataset, you can just run:\n\n```\npython3 train.py --model_dir=./experiments/experiment_omnet/\n```\n\nFor other dataset, you need to add your own dataset class in `./dataset/data_loader.py`. Training with a lower batch size, such as 16, may obtain worse performance than training with a larger batch size, e.g., 64.\n\n### Begin testing\n\nYou need to download the pretrained checkpoint and run:\n\n```\npython3 evaluate.py --model_dir=./experiments/experiment_omnet --restore_file=./experiments/experiment_omnet/val_model_best.pth\n```\n\nThis model weight is for TS data with Gaussian noise. Note that the performance is a little bit worse than the results reported in our paper (Pytorch implementation).\n\nMegEngine checkpoint for ModelNet40 dataset can be download via [Google Drive](https://drive.google.com/file/d/1xkWQeMabQhO4zqg6X3aj_VQCMHgeBUsD/view?usp=sharing) or [Github Release](https://github.com/megvii-research/OMNet/releases/download/V1.0.0/val_model_best.pth).\n\n## Citation\n\n```\n@InProceedings{Xu_2021_ICCV,\n    author={Xu, Hao and Liu, Shuaicheng and Wang, Guangfu and Liu, Guanghui and Zeng, Bing},\n    title={OMNet: Learning Overlapping Mask for Partial-to-Partial Point Cloud Registration},\n    booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},\n    month={October},\n    year={2021},\n    pages={3132-3141}\n}\n```\n\n## Acknowledgments\n\nIn this project we use (parts of) the official implementations of the following works:\n\n* [RPMNet](https://github.com/yewzijian/RPMNet) (ModelNet40 preprocessing and evaluation)\n* [PRNet](https://github.com/WangYueFt/prnet) (ModelNet40 preprocessing)\n\nWe thank the respective authors for open sourcing their methods.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegengine%2Fomnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmegengine%2Fomnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegengine%2Fomnet/lists"}