pytorch implementation for PointNet

Overview

PointNet.pytorch

This repo is implementation for PointNet(https://arxiv.org/abs/1612.00593) in pytorch. The model is in pointnet/model.py.

It is tested with pytorch-1.0.

Download data and running

git clone https://github.com/fxia22/pointnet.pytorch
cd pointnet.pytorch
pip install -e .

Download and build visualization tool

cd script
bash build.sh #build C++ code for visualization
bash download.sh #download dataset

Training

cd utils
python train_classification.py --dataset 
   
     --nepoch=
    
      --dataset_type 
     
      
python train_segmentation.py --dataset 
      
        --nepoch=
        
       
      
     
    
   

Use --feature_transform to use feature transform.

Performance

Classification performance

On ModelNet40:

Overall Acc
Original implementation 89.2
this implementation(w/o feature transform) 86.4
this implementation(w/ feature transform) 87.0

On A subset of shapenet

Overall Acc
Original implementation N/A
this implementation(w/o feature transform) 98.1
this implementation(w/ feature transform) 97.7

Segmentation performance

Segmentation on A subset of shapenet.

Class(mIOU) Airplane Bag Cap Car Chair Earphone Guitar Knife Lamp Laptop Motorbike Mug Pistol Rocket Skateboard Table
Original implementation 83.4 78.7 82.5 74.9 89.6 73.0 91.5 85.9 80.8 95.3 65.2 93.0 81.2 57.9 72.8 80.6
this implementation(w/o feature transform) 73.5 71.3 64.3 61.1 87.2 69.5 86.1 81.6 77.4 92.7 41.3 86.5 78.2 41.2 61.0 81.1
this implementation(w/ feature transform) 87.6 81.0

Note that this implementation trains each class separately, so classes with fewer data will have slightly lower performance than reference implementation.

Sample segmentation result: seg

Links

Comments
  • TypeError: __init__() got an unexpected keyword argument 'num_points'

    TypeError: __init__() got an unexpected keyword argument 'num_points'

    when I run train_classification.py, there is an error:

    Traceback (most recent call last):
      File "train_classification.py", line 58, in <module>
        classifier = PointNetCls(k = num_classes, num_points = opt.num_points)
    TypeError: __init__() got an unexpected keyword argument 'num_points'
    

    I noticed that opt.num_points has been used in https://github.com/fxia22/pointnet.pytorch/blob/2ec315f174ed5ffc05d127d5cf14c94ce873c1e0/train_classification.py#L40 so I comment it and run again, but another error: ValueError: Expected more than 1 value per channel when training, got input size [1, 512] and this comes from : https://github.com/fxia22/pointnet.pytorch/blob/2ec315f174ed5ffc05d127d5cf14c94ce873c1e0/pointnet.py#L47 how to solve it? thanks for your help

    opened by 3bobo 6
  • Getting NAN after few iterations

    Getting NAN after few iterations

    Hi, I am using PointNet on Pytorch to train my custom dataset. However, after training around 10-20 batches of examples, the loss goes into NAN.

    I highly doubt that it is a exploding gradient issue. (still trying to diagnose the problem)

    Posting this problem here in expectation of any help or direction that you may provide.

    Things I have tried is -

    1. Reducing the Learning Rate to 0.0001
    2. setting drop_last=True in DataLoader
    3. reducing the batch size from 32 to 10
    opened by dhirajsuvarna 4
  • Difference between nn.Conv1d and nn.Linear

    Difference between nn.Conv1d and nn.Linear

    Hi, I think the nn.Conv1d and nn.Linear are the same for pointwise convolution( if kernel_size = 1 for conv1d), so could you please provide some reasons about why you choose nn.Conv1d for the first three layers and choose nn.Linear for the last two layers ?

    opened by XuyangBai 4
  • No feature transform net

    No feature transform net

    No offense, but I think you don't implement PointNet correctly. For example, the Feature-transform-net isn't found here, and this pointnet.pytorch has much fewer layers than the raw author's design.

    opened by charlesCXK 4
  • Transform network doubt/issue

    Transform network doubt/issue

    Hello,

    I have a doubt of the network STN3D, in the paper the authors says that after the max pooling there are only two layers and the output matrix is initialized as identity matrix. But I am not able to see this implementation on the code. In the file https://github.com/fxia22/pointnet.pytorch/blob/master/pointnet.py in the class stn3d what I can see is a third full connected layer that is not described on the paper but I am guessing that this stage is used in order to generate the output matrix of 3x3 (that I think this is a correct) but my issue is related to this lines:

     x = self.fc3(x)
    
            iden = Variable(torch.from_numpy(np.array([1,0,0,0,1,0,0,0,1]).astype(np.float32))).view(1,9).repeat(batchsize,1)
            if x.is_cuda:
                iden = iden.cuda()
            x = x + iden
            x = x.view(-1, 3, 3)
            return x
    

    Here, I am not able too see the init of this layer as a identity matrix. That I see is that in every iteration you are adding to the matrix calculated by the network an identity matrix but this is not the same that is described on the paper, right?

    Another doubt that I have is related to the convolutional layers, why are you using 1d convolutional layers? In the tensorflow implementation the convolutional layers are 2d. Is it for any specific reason?

    Thanks in advance

    opened by dhorka 4
  • Advice: Regression with PointNet

    Advice: Regression with PointNet

    Hello,

    I am interested in furthering PointNet and using it for regression. Is this possible? Has anyone attempted this yet? Any thoughts or comments would be great!

    Thanks!

    opened by shrutirao94 3
  • Architecture: Very small issue

    Architecture: Very small issue

    Hi Fei Xia,

    I was wondering whether this line (14-15) of code in the PointNet Architecture is missing an extra layer as of the official paper release:

    class STN3d(nn.Module):
        def __init__(self):
            super(STN3d, self).__init__()
            self.conv1 = torch.nn.Conv1d(3, 64, 1)
            *---HERE-> = torch.nn.Conv1d(64,64,1)*
            self.conv2 = torch.nn.Conv1d(64, 128, 1)
    
    

    Not a very big deal but just want to clarify on this.

    Cheers, Tim

    opened by timothylimyl 2
  • View Segementation Results

    View Segementation Results

    Hi @fxia22,

    I would like to know, if train_segmentation.py generates the segemented point cloud, since it would be good to view a segmented point cloud.

    In addition to that, it would also be helpful to view the critical point and the upper bound shapes as mentioned in the pointnet paper. Do let me know your views.

    opened by dhirajsuvarna 2
  • Preprocessing and performance on ModelNet40

    Preprocessing and performance on ModelNet40

    Hi,

    We run the classification model on ModelNet40 dataset (w/o feature transform), but couldn't get > 0.8 accuracy even after 200 epochs (we could reproduce the shapenet result, though). So I'm asking for some suggestions.

    (1) Did you train ModelNet40 with the same learning rate schedule as in train_classification.py?

    (2) We prepared the data loader by randomly subsetting ModelNet40 vertices. As mentioned in https://github.com/fxia22/pointnet.pytorch/issues/35#issuecomment-471158774, you used a data processing pipeline to sample points from the mesh. Could you provide a high-level overview of how it's done or point to a reference that describes ModelNet40 data processing?

    Thanks you very much!

    opened by yueqiw 2
  • def feature_transform_reguliarzer(trans):

    def feature_transform_reguliarzer(trans):

    Hi, your loss implemention is like this ||(A*(A_T-I))||, but the loss should be like ||(I-A*A_T)||, therefore, it should be like this
    loss = torch.mean(torch.norm(torch.bmm(trans, trans.transpose(2, 1) ) - I, dim=(1, 2))), am I right?

    opened by jeannotes 2
  • Confusion about the usage of log_softmax function.

    Confusion about the usage of log_softmax function.

    Thanks for your great work! I have some doubts about the usage of log_softmax function. As written in the 104th line of the file pointnet.py return F.log_softmax(x, dim=0), trans Actually, Dim0 means the dimension of batch. However, the log_softmax should be applied along the channels. So I think the parameter dim should be set as -1. Am I right or I miss something important? Looking forward for your response!

    opened by tengteng95 2
  • I add a python file for convert ModelNet40 format .off to .ply.

    I add a python file for convert ModelNet40 format .off to .ply.

    Hi, @fxia22 When i try training this repo, i found here only can use .ply format, so i add a python file "convert.py" in ModelNet40 folder (use after unzip ModelNet40 dataset.).

    This file had already been tested on my machine (i7-11700 8C16T), and i can successful run cls mission after convert ModelNet40 dataset.

    In detail, this file also check am i successful convert or not, this function approch by check() in 'convert.py', but it cost so much time (about 900 secs on my machine, the other part about 23 secs.), if you don't wont it happen, you can disable that.

    Also, i add a run 'convert.py' command in your README.md, and add 4 .txt you already gave in this page https://github.com/fxia22/pointnet.pytorch/issues/52

    If you have any need for convert, pls let me know.

    Thanks for releasing the package.

    opened by wuyiulin 0
  • Checkpoint request

    Checkpoint request

    Hi, is it possible to have a checkpoint for the results that are shown in the Read.me? Or, if already exists, can anyone point me to the right direction?

    opened by AlessiOrl 0
  • train_classification.py: error: argument --nepoch: invalid int value: '<number epochs>'

    train_classification.py: error: argument --nepoch: invalid int value: ''

    Dear Sir:

    I'm using Python3 and I'm trying to train the two .py files in /utils, I used:

    python3 train_classification.py --dataset='' --nepoch='' --dataset_type='<modelnet40 | shapenet>'

    instead but the system told me that train_classification.py: error: argument --nepoch: invalid int value: ''

    How can I fix this? Thank you very much!

    Best, cellist

    opened by yaminocellist 0
  • Error when running train_segmentation.py

    Error when running train_segmentation.py

    File "show_seg.py", line 30, in data_augmentation=False) File "/home/gene/YuRen/pointnet.pytorch/pointnet/dataset.py", line 107, in init self.num_seg_classes = self.seg_classes[list(self.cat.keys())[0]] IndexError: list index out of range

    As above, I am facing the problem I have no idea to deal with, please help!! PS:The training progress is fine, so I think there might be some part of code I need to change when I am running on my server.

    opened by RonaldYuren 2
  • KeyError: 'conv4.weight'

    KeyError: 'conv4.weight'

    I ran this command python utils/show_seg.py and reported the following error:

    Namespace(class_choice='Chair', dataset='./shapenetcore_partanno_segmentation_benchmark_v0', idx=0, model='./seg/seg_model_Chair_29.pth')
    {'Chair': 0}
    {'Airplane': 4, 'Bag': 2, 'Cap': 2, 'Car': 4, 'Chair': 4, 'Earphone': 3, 'Guitar': 3, 'Knife': 2, 'Lamp': 4, 'Laptop': 2, 'Motorbike': 6, 'Mug': 2, 'Pistol': 3, 'Rocket': 3, 'Skateboard': 3, 'Table': 3} 4
    model 0/704
    torch.Size([2500, 3]) torch.Size([2500])
    Traceback (most recent call last):
      File "utils/show_seg.py", line 45, in <module>
        classifier = PointNetDenseCls(k= state_dict['conv4.weight'].size()[0])
    KeyError: 'conv4.weight'
    

    What should I do? Looking forward to your reply.

    opened by HeBangYan 0
Owner
Fei Xia
PhD @StanfordVL @cvgl Computer Vision and Robotics
Fei Xia
PyTorch implementation of Pointnet2/Pointnet++

Pointnet2/Pointnet++ PyTorch Project Status: Unmaintained. Due to finite time, I have no plans to update this code and I will not be responding to iss

Erik Wijmans 1.2k Dec 29, 2022
ALBERT-pytorch-implementation - ALBERT pytorch implementation

ALBERT-pytorch-implementation developing... 모델의 개념이해를 돕기 위한 구현물로 현재 변수명을 상세히 적었고

BG Kim 3 Oct 6, 2022
An essential implementation of BYOL in PyTorch + PyTorch Lightning

Essential BYOL A simple and complete implementation of Bootstrap your own latent: A new approach to self-supervised Learning in PyTorch + PyTorch Ligh

Enrico Fini 48 Sep 27, 2022
RealFormer-Pytorch Implementation of RealFormer using pytorch

RealFormer-Pytorch Implementation of RealFormer using pytorch. Includes comparison with classical Transformer on image classification task (ViT) wrt C

Simo Ryu 90 Dec 8, 2022
A PyTorch implementation of the paper Mixup: Beyond Empirical Risk Minimization in PyTorch

Mixup: Beyond Empirical Risk Minimization in PyTorch This is an unofficial PyTorch implementation of mixup: Beyond Empirical Risk Minimization. The co

Harry Yang 121 Dec 17, 2022
A pytorch implementation of Pytorch-Sketch-RNN

Pytorch-Sketch-RNN A pytorch implementation of https://arxiv.org/abs/1704.03477 In order to draw other things than cats, you will find more drawing da

Alexis David Jacq 172 Dec 12, 2022
PyTorch implementation of Advantage async actor-critic Algorithms (A3C) in PyTorch

Advantage async actor-critic Algorithms (A3C) in PyTorch @inproceedings{mnih2016asynchronous, title={Asynchronous methods for deep reinforcement lea

LEI TAI 111 Dec 8, 2022
Pytorch-diffusion - A basic PyTorch implementation of 'Denoising Diffusion Probabilistic Models'

PyTorch implementation of 'Denoising Diffusion Probabilistic Models' This reposi

Arthur Juliani 76 Jan 7, 2023
Fang Zhonghao 13 Nov 19, 2022
RETRO-pytorch - Implementation of RETRO, Deepmind's Retrieval based Attention net, in Pytorch

RETRO - Pytorch (wip) Implementation of RETRO, Deepmind's Retrieval based Attent

Phil Wang 556 Jan 4, 2023
HashNeRF-pytorch - Pure PyTorch Implementation of NVIDIA paper on Instant Training of Neural Graphics primitives

HashNeRF-pytorch Instant-NGP recently introduced a Multi-resolution Hash Encodin

Yash Sanjay Bhalgat 616 Jan 6, 2023
Generic template to bootstrap your PyTorch project with PyTorch Lightning, Hydra, W&B, and DVC.

NN Template Generic template to bootstrap your PyTorch project. Click on Use this Template and avoid writing boilerplate code for: PyTorch Lightning,

Luca Moschella 520 Dec 30, 2022
A PyTorch Extension: Tools for easy mixed precision and distributed training in Pytorch

This repository holds NVIDIA-maintained utilities to streamline mixed precision and distributed training in Pytorch. Some of the code here will be included in upstream Pytorch eventually. The intention of Apex is to make up-to-date utilities available to users as quickly as possible.

NVIDIA Corporation 6.9k Jan 3, 2023
Objective of the repository is to learn and build machine learning models using Pytorch. 30DaysofML Using Pytorch

30 Days Of Machine Learning Using Pytorch Objective of the repository is to learn and build machine learning models using Pytorch. List of Algorithms

Mayur 119 Nov 24, 2022
Pretrained SOTA Deep Learning models, callbacks and more for research and production with PyTorch Lightning and PyTorch

Pretrained SOTA Deep Learning models, callbacks and more for research and production with PyTorch Lightning and PyTorch

Pytorch Lightning 1.4k Jan 1, 2023
Amazon Forest Computer Vision: Satellite Image tagging code using PyTorch / Keras with lots of PyTorch tricks

Amazon Forest Computer Vision Satellite Image tagging code using PyTorch / Keras Here is a sample of images we had to work with Source: https://www.ka

Mamy Ratsimbazafy 360 Dec 10, 2022
The Incredible PyTorch: a curated list of tutorials, papers, projects, communities and more relating to PyTorch.

This is a curated list of tutorials, projects, libraries, videos, papers, books and anything related to the incredible PyTorch. Feel free to make a pu

Ritchie Ng 9.2k Jan 2, 2023
Amazon Forest Computer Vision: Satellite Image tagging code using PyTorch / Keras with lots of PyTorch tricks

Amazon Forest Computer Vision Satellite Image tagging code using PyTorch / Keras Here is a sample of images we had to work with Source: https://www.ka

Mamy Ratsimbazafy 359 Jan 5, 2023
A bunch of random PyTorch models using PyTorch's C++ frontend

PyTorch Deep Learning Models using the C++ frontend Gettting started Clone the repo 1. https://github.com/mrdvince/pytorchcpp 2. cd fashionmnist or

Vince 0 Jul 13, 2021