dvlab-research / Stratified-Transformer

Stratified Transformer for 3D Point Cloud Segmentation (CVPR 2022)
MIT License
362 stars 40 forks source link

How to write test results as ply #13

Closed alien19 closed 2 years ago

alien19 commented 2 years ago

Hi, I was lucky to try your code and test it on the S3DIS dataset, also I noticed the presence of "write_ply_color" and "write_ply_rgb" but it is not obvious how to be used in the test code so, if there a way to do so, it would be appreciated. specifically, how can points argument be passed to the functions

X-Lai commented 2 years ago

You can use the following function to output the .obj file, and open it with MeshLab.

def write_obj(points, colors, out_filename):
    N = points.shape[0]
    fout = open(out_filename, 'w')
    for i in range(N):
        c = colors[i]
        fout.write('v %f %f %f %d %d %d\n' % (points[i, 0], points[i, 1], points[i, 2], c[0], c[1], c[2]))
    fout.close()
alien19 commented 2 years ago

thanks @X-Lai , I have checked this function too in a previous issue, but I can't understand what is the points object that is to be passed to the function.

X-Lai commented 2 years ago

points is a numpy array object (np.ndarray) of the shape (N, 3), which means xyz of all points.

alien19 commented 2 years ago

@X-Lai I understand this thanks. but when I run the test.py script the output .npy files which contain pred and labels are 1d arrays that's why I can't figure out from where points object would be constructed!

X-Lai commented 2 years ago

The .npy files produced by test.py don't contain the xyz position information, you may need to use the corresponding input file with the same filename for visualization.

alien19 commented 2 years ago

I managed to do the visualization successfully thanks @X-Lai , but I'm wondering about the correct order of the classes so as to list them correctly in the s3dis_names.txt file since there is a mismatch between what is present in the test_log file (downloaded with the model) and the colors dictionary in the code

X-Lai commented 2 years ago

Thank you for pointing out this issue, I find that the order of s3dis_names.txt is problematic. Please refer to the https://github.com/yanx27/Pointnet_Pointnet2_pytorch for the correct class mapping.