0

I am trying to train my point cloud data on PointCNN so I need to convert my dataset to hdf5 as used in PointCNN. PointCNN used the modelnet40_ply_hdf5_2048 dataset. I have tried converting my custom dataset but I am having issues with the label.

I tried this to get the label/shape_names

shape_ids = {}
shape_ids = [line.rstrip() for line in open(os.path.join(PATH, 'filelist1.txt'))]

shape_names = ['_'.join(x.split('_')[0:-1]) for x in shape_ids]
datapath = [(shape_names[i], os.path.join(PATH, shape_names[i], shape_ids[i])) for i
                 in range(len(shape_ids))]

Convert to h5py file

import numpy as np
from tqdm import tqdm
import h5py


filenames = [line.rstrip() for line in open(os.path.join(PATH))]
f = h5py.File("filename", 'w')

data = np.zeros((len(filenames), 1024, 3))

for i in range(0, len(datapath)):
  fn = datapath[i]
  cls = classes[datapath[i][0]]
  label = np.array([cls]).astype(np.int32) 
  
  csvreader = np.genfromtxt("data1/" + filenames[i] + ".csv", delimiter=",").astype(np.float32)
  
  for j in range(0,1024):
    data[i,j] = [csvreader[j][0], csvreader[j][1], csvreader[j][2]]
    label
    
dset1 = f.create_dataset("data", data=data, compression="gzip", compression_opts=4) 
dset2 = f.create_dataset("label", data=label, compression="gzip", compression_opts=1)
f.close()

It did convert successfully but when I tried to train on PointCNN

PointCNN training

------Building model-------
------Successfully Built model-------
Traceback (most recent call last):
  File "train_pytorch.py", line 174, in <module>
    current_data, current_label, _ = provider.shuffle_data(current_data, np.squeeze(current_label))
  File "provider.py", line 28, in shuffle_data
    idx = np.arange(len(labels))
TypeError: len() of unsized object
James Z
  • 12,209
  • 10
  • 24
  • 44
Vickky
  • 1
  • It's hard to diagnose without knowing more about your CSV files and the desired HDF5 file schema. I searched for the modelnet40_ply_hdf5_2048 dataset and found 5 `ply_data_train#.h5` files (#1 to 5). Is that what you are using? If so, you need to match the schema it has. This is what I found: ``. Start by comparing this shaped and dtype to your "label" dataset. – kcw78 Nov 03 '22 at 13:22

0 Answers0