isl-org / Open3D-ML

An extension of Open3D to address 3D Machine Learning tasks
Other
1.85k stars 317 forks source link

Can I do semantic segmentation on my point cloud? #617

Open moe0430cagla opened 1 year ago

moe0430cagla commented 1 year ago

Checklist

My Question

The following code is written in the README file.

# load the parameters.
pipeline.load_ckpt(ckpt_path=ckpt_path)

test_split = dataset.get_split("test")
data = test_split.get_data(0)

# run inference on a single example.
# returns dict with 'predict_labels' and 'predict_scores'.
result = pipeline.run_inference(data)

I want to use pipeline.run_inference to my own data that doesn't have labels. Is it possible ?

When I enter my point cloud in the [data] section, I get the following error

torch.tensor(data['label']), model.cfg.num_classes, KeyError: 'label'

My CODE

pcd = o3d.io.read_point_cloud("../pointcloud/test.ply")
points = np.asarray(pcd.points)
data = {
    'point': points,
    'feat': None,  
}
result = pipeline.run_inference(data)

Please tell me the reason why this error occurs. Thank you for your cooperation.

sec-morikawa commented 12 months ago

Hey, @moe0430cagla

It seems you need to add a label Key to your test data. This is the code when creating an existing dataset (SemanticKITTI). https://github.com/isl-org/Open3D-ML/blob/master/ml3d/datasets/semantickitti.py#L268

e.g

labels = np.zeros(np.shape(points)[0], dtype=np.int32)
data = {
            'point': points,
            'feat': None,
            'label': labels,
}