filaPro/oneformer3d

visualize the predicted result

TangKexin4646 opened this issue · 6 comments

How can I visualize the predicted result for the instance segmentation task?

Thank you for the reply.

And I changed the oneformer3d.py according to #57
I also write the predicted code according to #67

the code is as follows:

from mmengine.config import Config
from mmengine.registry import Registry, build_functions
import numpy as np
model_registry = Registry('model')
model_config_path = '/media/tang/shared/oneformer3d-main/configs/oneformer3d_1xb2_s3dis-area-5.py'
model_config = Config.fromfile(model_config_path)
checkpoint = '/media/tang/shared/oneformer3d-main/work_dirs/oneformer3d_1xb2_s3dis-area-5/epoth_512.pth'
pcd_path = '/media/tang/shared/oneformer3d-main/data/s3dis/points/Area_1_conferenceRoom_1.bin'
pcd = np.fromfile(pcd_path, dtype=np.float32).reshape(-1, 6)
model = build_functions.build_model_from_cfg(model_config , model_registry)
model.load_checkpoint(checkpoint)
result = model.predict(dict(points=pcd))

but there is an error:
File "/media/tang/shared/oneformer3d-main/s3dis_predict.py", line 20, in
model = build_functions.build_model_from_cfg(model_config , model_registry)
File "/home/tang/anaconda3/envs/mmdetection3d/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 232, in build_model_from_cfg
return build_from_cfg(cfg, registry, default_args)
File "/home/tang/anaconda3/envs/mmdetection3d/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 72, in build_from_cfg
raise KeyError(
KeyError: 'cfg or default_args must contain the key "type", but got Config (path: /media/tang/shared/oneformer3d-main/configs/oneformer3d_1xb2_s3dis-area-5.py): {'default_scope': 'mmdet3d', 'defa.....)

Could you please help me figure out the problem?

Looks like in model_config should be Config.fromfile(model_config_path)['model'].

Also it should be possible to build runner from config like here and then access the model as runner.model.

model_config should be Config.fromfile(model_config_path)['model']
Yes, it works, but there is a new error.

Traceback (most recent call last):
File "/media/tang/shared/oneformer3d-main/s3dis_predict.py", line 21, in
model = build_functions.build_model_from_cfg(model_config , model_registry)
File "/home/tang/anaconda3/envs/mmdetection3d/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 232, in build_model_from_cfg
return build_from_cfg(cfg, registry, default_args)
File "/home/tang/anaconda3/envs/mmdetection3d/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 100, in build_from_cfg
raise KeyError(
KeyError: 'S3DISOneFormer3D is not in the main::model registry. Please check whether the value of S3DISOneFormer3D is correct or it was registered as expected. More details can be found at

  1. Also it should be possible to build runner from config like here and then access the model as runner.model.

I want to predict a single point cloud data like #67, but the runner seems to expect lots of data.

@TangKexin4646
Hi, Previously the author said that pred is inconsistent with gt labels, so I have a problem with the visualization code, unfortunately, I can't help you to solve the problem, because I haven't found a corresponding method myself.

To fix import error you need to use custom_imports key from our config file. To do it please call something like import_modules_from_strings(**cfg_dict['custom_imports']) like here.