Code Monkey home page Code Monkey logo

pointnet.pytorch's Introduction

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 scripts
bash build.sh #build C++ code for visualization
bash download.sh #download dataset

Training

cd utils
python train_classification.py --dataset <dataset path> --nepoch=<number epochs> --dataset_type <modelnet40 | shapenet>
python train_segmentation.py --dataset <dataset path> --nepoch=<number epochs> 

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

pointnet.pytorch's People

Contributors

delldu avatar elliottzheng avatar fxia22 avatar gsp-27 avatar jeekzhang avatar jingpengw avatar ranahanocka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pointnet.pytorch's Issues

Issues with .eval() for batchnorm

I ran across a few problems when running show_seg.py with the newest version of pytorch.
Two problems in show_seg.py

  • batchnorm needs a batchsize>1. I solved this problem by adding .eval() to show_seg.py
  • There also seems to be a difference in the dim data.max() returns.

One problem in pointnet.py

  • PointNetDenseCls uses log_softmax() which now requires a dim parameter

I have fixed them, but I am new to using github and I've never done a pull request before. How could I submit the changes?

Conv1d kernel size in transformer nets

Comparing your code to the official TensorFlow implementation I believe the kernel size ought to be 3 for the conv1 in the transformer network code (starting here).

The official implementation convolves 64 1x3 filters over each of N 1x3 points. The result is 64 scalar values describing each point (i.e. a N x 64 matrix). Your code uses a filter size of 1.

Perhaps you could clarify?

pointnet++

Do you have any plan to port pointnet++ to pytorch?
if so, I could help :)

When I run show_cls.py

teacher:
When I run show_cls.py
i:1 loss: 2.079445 accuracy: 0.031250
i:2 loss: 2.079467 accuracy: 0.000000
i:3 loss: 2.079436 accuracy: 0.062500
i:4 loss: 2.079478 accuracy: 0.000000
i:5 loss: 2.079460 accuracy: 0.000000
i:6 loss: 2.079444 accuracy: 0.000000
i:7 loss: 2.079463 accuracy: 0.000000
i:8 loss: 2.079488 accuracy: 0.000000
i:9 loss: 2.079418 accuracy: 0.062500
i:10 loss: 2.079412 accuracy: 0.031250
"""
"""
why is that?

Some operation on points data (train_seg)

Hi,

Thanks for the nice implementation.
I am a little confused about the transpose operation you have on the points data (and in STN):
points = points.transpose(2,1)
which I don't see in the original tensorflow implementation.
Could you help explain the purpose of this operation? Thank you very much!

need more guidance

hi, im new to use this tool, can you give a more specific guidance on how to use on win10? i dont know exactly how to use at the first place. thanks

How to using pointnet without segmentation?

Thanks for help,I want using pointnet for classification with new data, but data only have points,it didn't have points_label and seg_img, can pointnet classification without points_label and seg_img?

Wrong implementation

I think this implementation of PointNet is not consistent with the network in the paper or the Tensorflow implementation.
There are two transform steps in the original paper, and only one is implemented in PointNetfeat(), I will try to implement what I think is in the paper and pull a request, or correct me if I'm wrong.

Classification results on ModelNet40

Compared with the tensorflow version, I am confused about your released classification results on modelnet40 which are obviously lower. Can you explain why? and are your results the average values of several times experiments? Thank you!

train_classification.py error

@fxia22 I can run with train_segmentation.py, but when I try to run train_classification.py, the data is all zero like this:

[0: 0/15990] train loss: 0.000000 accuracy: 1.000000
[0: 0/15990] test loss: 0.000000 accuracy: 0.000000
[0: 1/15990] train loss: 0.000000 accuracy: 0.000000
[0: 2/15990] train loss: 0.000000 accuracy: 0.000000
[0: 3/15990] train loss: 0.000000 accuracy: 0.000000
[0: 4/15990] train loss: 0.000000 accuracy: 0.000000
[0: 5/15990] train loss: 0.000000 accuracy: 0.000000
[0: 6/15990] train loss: 0.000000 accuracy: 1.000000
[0: 7/15990] train loss: 0.000000 accuracy: 0.000000
[0: 8/15990] train loss: 0.000000 accuracy: 0.000000
[0: 9/15990] train loss: 0.000000 accuracy: 0.000000
[0: 10/15990] train loss: 0.000000 accuracy: 0.000000
[0: 10/15990] test loss: 0.000000 accuracy: 0.000000
[0: 11/15990] train loss: 0.000000 accuracy: 0.000000
[0: 12/15990] train loss: 0.000000 accuracy: 0.000000
[0: 13/15990] train loss: 0.000000 accuracy: 1.000000
[0: 14/15990] train loss: 0.000000 accuracy: 0.000000
[0: 15/15990] train loss: 0.000000 accuracy: 0.000000
[0: 16/15990] train loss: 0.000000 accuracy: 1.000000
[0: 17/15990] train loss: 0.000000 accuracy: 0.000000
[0: 18/15990] train loss: 0.000000 accuracy: 0.000000
[0: 19/15990] train loss: 0.000000 accuracy: 1.000000
[0: 20/15990] train loss: 0.000000 accuracy: 0.000000

because my computer's gpu is not enough strong, I set batch_size to 1, does is matter?
thanks for your help.

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

dataset = PartDataset(root = 'shapenetcore_partanno_segmentation_benchmark_v0', classification = True, npoints = opt.num_points)

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 :
x = F.relu(self.bn4(self.fc1(x)))

how to solve it? thanks for your help

OSError: Input/output error

Hi, this error occured under training, and repeated after reboot.
1
2

The system seemed to be crashed as the icons in the dock went wrong. The original icons are shown below.
3

In addition, commands didn't work.
5

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 #35 (comment), 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!

doubt about the PointNetCls

last return sentence in classPointNetCls is:

return F.log_softmax(x, dim=0), trans

however in my opnion shape(x) should be (batchsize,k),then the last return should be:

return F.log_softmax(x, dim=-1), trans
or
return F.log_softmax(x, dim=1), trans

I don't know if I just thought wrong, can anyone solve my doubt.

Performance

Can you please comment on the performance of this implementation (accuracies and speed) compared to the original Tensorflow one?

Thanks!

OSError: no file with expected extension

Traceback (most recent call last):
File "C:/Users/123456/Desktop/PointNet/pointnet_pytorch-master_lingzhang1/show3d_balls.py", line 19, in
dll=np.ctypeslib.load_library('render_balls_so','.')
File "F:\anaconda1\lib\site-packages\numpy\ctypeslib.py", line 155, in load_library
raise OSError("no file with expected extension")
OSError: no file with expected extension

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?

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 ?

segmentation file

Hello, I want to use my data for classification i don't have .seg files. i have its .pts file and image file.
how can i use this without .seg files.

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

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

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!

Trans Matrix regularize seems wrong

Hi , In train_classification.py, it used the `loss += feature_transform_regularize(trans_feat)*0.001', it should be trans, not trans_feat, trans is the transfromation matrix which needs to be regularized.

Training with individual point numbers crashed

Dear authors, thanks for sharing the PyTorch version of PointNet which is helping me a lot. I'm encountering this problem. PointNet itself allows individual inputs to vary in the number of points as a symmetric max function would erase the difference in dimension. However, based on your code, when I changed batch size to be 1 in train_classification.py, commented out the num_points and random choice part in dataset.py, canceled batch_normal operations in model.py, and made other related changes, and then run the scripts with num_workers=32 on either 4 GPUs or 1 GPU (1 node in both cases), the same error occurs upon calling classifier:

RuntimeError: cuDNN error: CUDNN_STATUS_NOT_SUPPORTED. This error may appear if you passed in a non-contiguous input.

I looked up in GitHub and they say this error results from a bug in CUDA. Actually, with all other changes remained, if I restored the random choice part, the program runs healthily then.

So my question is, how do you accomplish training on the original inputs (each with a different number of points)? If possible, please provide details.

Another thing is, if batch size is taken to be 1 for the sake of dimension variation, how to conduct something similar to batch normalization so as to improve training? As in the trial where I set batchsize = 1, canceled batch_normals, and used random choice to circumvent the aforementioned bug, I noticed that its training effect is significantly worse than your original setting.

Thank you for your time!
Seikegn

How to handle dataset with intensity?

Hi, I,m interested in the great work, now I want to use the network to handle my own dataset. The dataset I have is different from the dataset mentioned in the project. The input data only has the XYZ ,intensity. If I want to use the dataset to do semantic segmentation, how do I handle the dataset? Thanks a lot!

Doubt of "feature transform"

Hello,
I didn't see the feature transform network(64*64 transform). Do you think it is not necessary?
Thanks.

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.

tiain_segmentation issue

teacher:
I have two question Q1:In train_segmentation.py,I run 200 epochs,However,the accuracy is about 30%, it is far away 90%. Q2 :In train_segmentation.py or In train_classification.py ,the train and the test is runing at the same time?

where can I get .ply data of ModelNet40?

Hi,
When I run
pointnet.pytorch/utils$ python train_classification.py --dataset ../ModelNet40 --dataset_type modelnet40
I get error

  File "train_classification.py", line 102, in <module>
    for i, data in enumerate(dataloader, 0):
  File "/home/aming/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 819, in __next__
    return self._process_data(data)
  File "/home/aming/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 846, in _process_data
    data.reraise()
  File "/home/aming/anaconda3/lib/python3.7/site-packages/torch/_utils.py", line 385, in reraise
    raise self.exc_type(msg)
plyfile.PlyHeaderParseError: Caught PlyHeaderParseError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/home/aming/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/aming/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/aming/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/aming/文档/cls/pointnet.pytorch/pointnet/dataset.py", line 170, in __getitem__
    plydata = PlyData.read(f)
  File "/home/aming/anaconda3/lib/python3.7/site-packages/plyfile.py", line 392, in read
    data = PlyData._parse_header(stream)
  File "/home/aming/anaconda3/lib/python3.7/site-packages/plyfile.py", line 373, in _parse_header
    while parser.consume(stream.readline()):
  File "/home/aming/anaconda3/lib/python3.7/site-packages/plyfile.py", line 128, in consume
    ", ".join(self._allowed))
  File "/home/aming/anaconda3/lib/python3.7/site-packages/plyfile.py", line 134, in _error
    raise PlyHeaderParseError(message, self.lines)
plyfile.PlyHeaderParseError: line 1: expected one of {ply}

I think it's because my ModelNet40 only has .off data like ModelNet40/airplane/train/airplane_0001.off, which I download on http://modelnet.cs.princeton.edu/

Why there's no code to read from .off ?
How can I convert .off to .ply?

Questions for other dataset

I was wondering if this would work for other datasets. For example, if I have another point cloud data or sample some random distribution and try to learn with pointNet, how should the data be organized?
Thanks

meshio for i/o

I recently updated meshio to include support for PLY, and using it as a drop-in replacement for plyfile would increase the number of supported mesh formats by a great deal. Perhaps that's worth considering.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.