TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
when I run "python browse_dataset.py" which is a code to visualize the data, the code and the error are shown below.
The code:
`from mmdet.registry import DATASETS, VISUALIZERS from mmengine.config import Config from mmengine.registry import init_default_scope
cfg = Config.fromfile('rtmdet_tiny_1xb12-40e_cat.py')
init_default_scope(cfg.get('default_scope', 'mmdet'))
dataset = DATASETS.build(cfg.train_dataloader.dataset) visualizer = VISUALIZERS.build(cfg.visualizer) visualizer.dataset_meta = dataset.metainfo
plt.figure(figsize=(16, 5))
for i in range(8): item=dataset[i]
img = item['inputs'].permute(1, 2, 0).numpy() data_sample = item['data_samples'].numpy() gt_instances = data_sample.gt_instances img_path = osp.basename(item['data_samples'].img_path)
gt_bboxes = gt_instances.get('bboxes', None) gt_instances.bboxes = gt_bboxes.tensor data_sample.gt_instances = gt_instances
visualizer.add_datasample( osp.basename(img_path), img, data_sample, draw_pred=False, show=False) drawed_image=visualizer.get_image()
plt.subplot(2, 4, i+1) plt.imshow(drawed_image[..., [2, 1, 0]]) plt.title(f"{osp.basename(img_path)}") plt.xticks([]) plt.yticks([])
plt.tight_layout() `
The error:
$ python browse_dataset.py
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
image path: IMG_20211024_223313.jpg
Traceback (most recent call last):
File "D:\0.Coding\mmdetection\browse_dataset.py", line 32, in
Set show = True, it can show one image, but also have the "TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType"
visualizer.add_datasample( os.path.basename(img_path), img, data_sample, draw_pred=False, show=True) drawed_image=visualizer.get_image()
@chinabing not NoneType is mean the image path is incorrect.
@chinabing
not NoneTypeis mean the image path is incorrect.
I have checked the path and have not found any problem. I can run the training step. Only the visulization step did not work. I guess whether the mmengine version is not suitable.
@chinabing
not NoneTypeis mean the image path is incorrect.
Set show = True, it can show one image, but also have the "TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType" visualizer.add_datasample( os.path.basename(img_path), img, data_sample, draw_pred=False, show=True) drawed_image=visualizer.get_image()
same issue, I just ran inference_demo.ipynb
same issue