Open chinabing opened 1 year ago
@chinabing not NoneType
is mean the image path is incorrect.
@chinabing
not NoneType
is 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 NoneType
is 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
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
visualizer.add_datasample(
File "C:\Users\robin\AppData\Roaming\Python\Python310\site-packages\mmengine\dist\utils.py", line 401, in wrapper
return func(*args, *kwargs)
File "D:\0.Coding\mmdetection\mmdet\visualization\local_visualizer.py", line 506, in add_datasample
self.add_image(name, drawn_img, step)
File "C:\Users\robin\AppData\Roaming\Python\Python310\site-packages\mmengine\dist\utils.py", line 401, in wrapper
return func(args, **kwargs)
File "C:\Users\robin\AppData\Roaming\Python\Python310\site-packages\mmengine\visualization\visualizer.py", line 1084, in add_image
vis_backend.add_image(name, image, step) # type: ignore
File "C:\Users\robin\AppData\Roaming\Python\Python310\site-packages\mmengine\visualization\vis_backend.py", line 56, in wrapper
obj._init_env() # type: ignore
File "C:\Users\robin\AppData\Roaming\Python\Python310\site-packages\mmengine\visualization\vis_backend.py", line 213, in _init_env
if not os.path.exists(self._save_dir):
File "D:\ProgramData\Anaconda3\envs\gpt\lib\genericpath.py", line 20, in exists
os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
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()