使用mmyolo训练模型 的时候报错:ValueError: Key img_path is not in available keys.
Traceback (most recent call last):
File “tools/train.py”, line 123, in
main()
File “tools/train.py”, line 119, in main
runner.train()
File “/root/anaconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/runner/runner.py”, line 1777, in train
model = self.train_loop.run() # type: ignore
File “/root/anaconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/runner/loops.py”, line 96, in run
self.run_epoch()
File “/root/anaconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/runner/loops.py”, line 112, in run_epoch
for idx, data_batch in enumerate(self.dataloader):
File “/root/anaconda3/envs/mmyolo/lib/python3.8/site-packages/torch/utils/data/dataloader.py”, line 521, in next
data = self._next_data()
File “/root/anaconda3/envs/mmyolo/lib/python3.8/site-packages/torch/utils/data/dataloader.py”, line 1203, in _next_data
return self._process_data(data)
File “/root/anaconda3/envs/mmyolo/lib/python3.8/site-packages/torch/utils/data/dataloader.py”, line 1229, in _process_data
data.reraise()
File “/root/anaconda3/envs/mmyolo/lib/python3.8/site-packages/torch/_utils.py”, line 425, in reraise
raise self.exc_type(msg)
ValueError: Caught ValueError in DataLoader worker process 0.
Original Traceback (most recent call last):
File “/root/anaconda3/envs/mmyolo/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py”, line 287, in _worker_loop
data = fetcher.fetch(index)
File “/root/anaconda3/envs/mmyolo/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py”, line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File “/root/anaconda3/envs/mmyolo/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py”, line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File “/root/anaconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/dataset/base_dataset.py”, line 410, in getitem
data = self.prepare_data(idx)
File “/root/anaconda3/envs/mmyolo/lib/python3.8/site-packages/mmyolo/datasets/yolov5_coco.py”, line 53, in prepare_data
return self.pipeline(data_info)
File “/root/anaconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/dataset/base_dataset.py”, line 60, in call
data = t(data)
File “/root/anaconda3/envs/mmyolo/lib/python3.8/site-packages/mmcv/transforms/base.py”, line 12, in call
return self.transform(results)
File “/root/anaconda3/envs/mmyolo/lib/python3.8/site-packages/mmdet/structures/bbox/box_type.py”, line 267, in wrapper
return func(self, results)
File “/root/anaconda3/envs/mmyolo/lib/python3.8/site-packages/mmdet/datasets/transforms/transforms.py”, line 1507, in transform
results = self.aug(**results)
File “/root/anaconda3/envs/mmyolo/lib/python3.8/site-packages/albumentations/core/composition.py”, line 304, in call
self.preprocess(data)
File “/root/anaconda3/envs/mmyolo/lib/python3.8/site-packages/albumentations/core/composition.py”, line 331, in preprocess
raise ValueError(msg)
ValueError: Key img_path is not in available keys.
报错信息如下:
解决办法
执行:
pip install albumentations==1.3.1
因为我们默认安装的的albumentations可能是1.4.多,所以就会报这个错误。改成1.3.1版本就好了。
如图所示,替换为1.3.1版本: