Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

跟着步骤,自己做了数据集,但是更改类别后,模型训练中报错 #11

Open
yulongAI opened this issue Sep 2, 2023 · 5 comments

Comments

@yulongAI
Copy link

yulongAI commented Sep 2, 2023

after_test_epoch:
(VERY_HIGH ) RuntimeInfoHook
(NORMAL ) IterTimerHook
(BELOW_NORMAL) LoggerHook

after_test:
(VERY_HIGH ) RuntimeInfoHook

after_run:
(BELOW_NORMAL) LoggerHook

#上面都是正常的,下面就开始报错了
Traceback (most recent call last):
File "tools/train.py", line 104, in
main()
File "tools/train.py", line 100, in main
runner.train()
File "/environment/miniconda3/lib/python3.7/site-packages/mmengine/runner/runner.py", line 1704, in train
self._train_loop) # type: ignore
File "/environment/miniconda3/lib/python3.7/site-packages/mmengine/runner/runner.py", line 1498, in build_train_loop
runner=self, dataloader=self._train_dataloader))
File "/environment/miniconda3/lib/python3.7/site-packages/mmengine/registry/registry.py", line 570, in build
return self.build_func(cfg, *args, **kwargs, registry=self)
File "/environment/miniconda3/lib/python3.7/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
obj = obj_cls(**args) # type: ignore
File "/environment/miniconda3/lib/python3.7/site-packages/mmengine/runner/loops.py", line 219, in init
super().init(runner, dataloader)
File "/environment/miniconda3/lib/python3.7/site-packages/mmengine/runner/base_loop.py", line 27, in init
dataloader, seed=runner.seed, diff_rank_seed=diff_rank_seed)
File "/environment/miniconda3/lib/python3.7/site-packages/mmengine/runner/runner.py", line 1353, in build_dataloader
dataset = DATASETS.build(dataset_cfg)
File "/environment/miniconda3/lib/python3.7/site-packages/mmengine/registry/registry.py", line 570, in build
return self.build_func(cfg, *args, **kwargs, registry=self)
File "/environment/miniconda3/lib/python3.7/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
obj = obj_cls(**args) # type: ignore
File "/home/featurize/mmsegmentation/mmseg/datasets/ZihaoDataset.py", line 21, in init
**kwargs)
File "/home/featurize/mmsegmentation/mmseg/datasets/basesegdataset.py", line 142, in init
self.full_init()
File "/environment/miniconda3/lib/python3.7/site-packages/mmengine/dataset/base_dataset.py", line 305, in full_init
self.data_bytes, self.data_address = self._serialize_data()
File "/environment/miniconda3/lib/python3.7/site-packages/mmengine/dataset/base_dataset.py", line 765, in _serialize_data
data_bytes = np.concatenate(data_list)
File "<array_function internals>", line 6, in concatenate
ValueError: need at least one array to concatenate

重新跟着步骤改了好几遍,发现还是不行,但是子豪兄的数据集可以,是我做的数据集有问题吗

@Wei-Wu233
Copy link

一样的错误

@TommyZihao
Copy link
Owner

估计是你没有严格按照样例数据集的格式去整理

@Wei-Wu233
Copy link

估计是你没有严格按照样例数据集的格式去整理

数据集的格式是一样的,使用你在视频中演示的配置文件可以训练,但是换到你提供的其他配置文件以及我自己写的配置文件就会出现以上问题,所以应该是配置文件的事情,数据及的类别、地址相关信息都是一样的

@Saillxl
Copy link

Saillxl commented Mar 13, 2024

请问如何解决的

@kingofpizza3
Copy link

这个问题我也遇到了,以下是我采取的解决步骤
1.jpg格式与JPG格式不是同一个格式,如果你的图片是jpg之外的任何格式,在ZihaoDataset.py(或你的同类文件中)将代码中增添形如以下形式的代码
def __init__(self,
img_suffix='.JPG', #或你的其他图片格式
**kwargs) -> None:
super().__init__(
img_suffix=img_suffix,
**kwargs)
2.在ZihaoDataset_PSPNet_20230818.py(或你的同类文件中)找到num_classes并改为你的标签类型的数量(注意,0,即背景也被认为是一类,除非在定义数据集时被排除),并确保所有data_root都指向了你的数据集所在地址
3.在mmseg/utils/class_names.py中加入自己定义的类别,例如以下形式
def ZihaoDataset_classes(): return [ '1', '2', ]
在我做完以上修改后能够正常运行,希望能对你有所帮助。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants