我想在 mmdetection 中训练 4 通道图像。但我不知道如何修改代码。
我该怎么做?
首先,我尝试修改 mmdetection/mmdet/datasets/pipelines/loading.py 中 LoadImageFromFile 类中的 call 函数,但出现错误。
def __call__(self, results):
......
results['filename'] = filename
results['ori_filename'] = results['img_info']['filename']
results['img'] = img
results['img_shape'] = img.shape
results['ori_shape'] = img.shape
results['img_fields'] = ['img']
return results
其次,我尝试修改 mmdetection/mmdet/datasets/custom.py 中 CustomDatset 类中的 getitem
函数 if self.test_mode:
return self.prepare_test_img(idx)
while True:
data = self.prepare_train_img(idx)
if data is None:
idx = self._rand_another(idx)
continue
return data
我将 data['img'] 修改为自定义图像,但失败了。
我认为最简单的方法是为多通道图像编写自己的加载函数/类。您可以在此处添加加载函数 mmdetection/mmdet/datasets/pipelines/loading.py 类似于 LoadImageFromFile 类。