无法加载图像以在自定义数据集上训练模型
Unable to Load Images to train model on Custom Datasets
我刚刚坚持图像实例分割有一段时间了。我正在尝试为我的自定义数据训练 Yolact 模型。这是我到目前为止所做的一些简要信息
- 我已经使用labelme标注工具标注了图片
- 我已经使用 labelme2coco -> train.json & test.json
为每个(训练和验证数据)转换了注释文件
- 我根据 yolact
的需要和预期在 cofig.py 文件中进行了更改
- 当我关注这个存储库时,我遇到了一个错误 Argument 'bb' has incorrect type 我已经用这个已关闭的问题
中所述的方法解决了这个错误
完成上述任务后,我遇到了以下问题。
Scaling parameters by 0.12 to account for a batch size of 1.
Per-GPU batch size is less than the recommended limit for batch norm. Disabling batch norm.
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
/usr/local/lib/python3.6/dist-packages/torch/jit/_recursive.py:165: UserWarning: 'lat_layers' was found in ScriptModule constants, but it is a non-constant submodule. Consider removing it.
" but it is a non-constant {}. Consider removing it.".format(name, hint))
/usr/local/lib/python3.6/dist-packages/torch/jit/_recursive.py:165: UserWarning: 'pred_layers' was found in ScriptModule constants, but it is a non-constant submodule. Consider removing it.
" but it is a non-constant {}. Consider removing it.".format(name, hint))
/usr/local/lib/python3.6/dist-packages/torch/jit/_recursive.py:165: UserWarning: 'downsample_layers' was found in ScriptModule constants, but it is a non-constant submodule. Consider removing it.
" but it is a non-constant {}. Consider removing it.".format(name, hint))
Initializing weights...
Begin training!
**_Traceback (most recent call last):_**
File "train.py", line 504, in <module>
train()
File "train.py", line 270, in train
for datum in data_loader:
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 363, in __next__
data = self._next_data()
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 989, in _next_data
return self._process_data(data)
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 1014, in _process_data
data.reraise()
File "/usr/local/lib/python3.6/dist-packages/torch/_utils.py", line 395, in reraise
raise self.exc_type(msg)
**AssertionError: Caught AssertionError in DataLoader worker process 0.**
Original Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/worker.py", line 185, in _worker_loop
data = fetcher.fetch(index)
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/content/yolact/data/coco.py", line 94, in __getitem__
im, gt, masks, h, w, num_crowds = self.pull_item(index)
File "/content/yolact/data/coco.py", line 141, in pull_item
assert osp.exists(path), 'Image path does not exist: {}'.format(path)
**AssertionError: Image path does not exist: data/YolaDataset/train/6.JPG**
注意:我已将测试和训练数据移至 yolact/data/YolactDataset(CWD 也是 /yolact/)
这是日志文件
Yolact Leather Defect Config.log
这里是config.py
的内容
yolact_leather_defect_dataset = Config({
'name': 'Yolact Leather Defect',
# Training images and annotations
'train_images': './data/YolaDataset/train/',
'train_info': './data/train.json',
# Validation images and annotations.
'valid_images': './data/YolaDataset/test/',
'valid_info': './data/test.json',
# Whether or not to load GT. If this is False, eval.py quantitative evaluation won't work.
'has_gt': True,
# A list of names for each of you classes.
'class_names': ("FC", "LF", "OC", "PM"),
# COCO class ids aren't sequential, so this is a bandage fix. If your ids aren't sequential,
# provide a map from category_id -> index in class_names + 1 (the +1 is there because it's 1-indexed).
# If not specified, this just assumes category ids start at 1 and increase sequentially.
'label_map': {
1:1, 2:2, 3:3, 4:4,
}
})
yolact_leather_defect_config = coco_base_config.copy({
'name': 'Yolact Leather Defect Config',
# Dataset stuff
'dataset': yolact_leather_defect_dataset,
'num_classes': len(yolact_leather_defect_dataset.class_names) + 1,
# Image Size
'max_size': 550,
# Training params
'lr_steps': (280000, 600000, 700000, 750000),
'max_iter': 800000,
# Backbone Settings
'backbone': resnet101_backbone.copy({
'selected_layers': list(range(1, 4)),
'use_pixel_scales': True,
'preapply_sqrt': False,
'use_square_anchors': True, # This is for backward compatability with a bug
'pred_aspect_ratios': [ [[1, 1/2, 2]] ]*5,
'pred_scales': [[24], [48], [96], [192], [384]],
}),
# FPN Settings
'fpn': fpn_base.copy({
'use_conv_downsample': True,
'num_downsample': 2,
}),
# Mask Settings
'mask_type': mask_type.lincomb,
'mask_alpha': 6.125,
'mask_proto_src': 0,
'mask_proto_net': [(256, 3, {'padding': 1})] * 3 + [(None, -2, {}), (256, 3, {'padding': 1})] + [(32, 1, {})],
'mask_proto_normalize_emulate_roi_pooling': True,
# Other stuff
'share_prediction_module': True,
'extra_head_net': [(256, 3, {'padding': 1})],
'positive_iou_threshold': 0.5,
'negative_iou_threshold': 0.4,
'crowd_iou_threshold': 0.7,
'use_semantic_segmentation_loss': True,
})
文件结构
https://drive.google.com/file/d/1GDaDNBayMsADnxKmbIn5OL9eU17SI6eV/view?usp=sharing
我已尽力解决问题。任何帮助将不胜感激。
谢谢!
[最初这个问题我已经发布在 yolact repo 上。]
您的文件夹名称拼写错误 :) YolaDataset 需要重命名为 YolactDataset
# Training images and annotations
'train_images': './data/YolaDataset/train/',
'train_info': './data/train.json',
# Validation images and annotations.
'valid_images': './data/YolaDataset/test/',
'valid_info': './data/test.json',
我刚刚坚持图像实例分割有一段时间了。我正在尝试为我的自定义数据训练 Yolact 模型。这是我到目前为止所做的一些简要信息
- 我已经使用labelme标注工具标注了图片
- 我已经使用 labelme2coco -> train.json & test.json 为每个(训练和验证数据)转换了注释文件
- 我根据 yolact 的需要和预期在 cofig.py 文件中进行了更改
- 当我关注这个存储库时,我遇到了一个错误 Argument 'bb' has incorrect type 我已经用这个已关闭的问题 中所述的方法解决了这个错误
完成上述任务后,我遇到了以下问题。
Scaling parameters by 0.12 to account for a batch size of 1.
Per-GPU batch size is less than the recommended limit for batch norm. Disabling batch norm.
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
/usr/local/lib/python3.6/dist-packages/torch/jit/_recursive.py:165: UserWarning: 'lat_layers' was found in ScriptModule constants, but it is a non-constant submodule. Consider removing it.
" but it is a non-constant {}. Consider removing it.".format(name, hint))
/usr/local/lib/python3.6/dist-packages/torch/jit/_recursive.py:165: UserWarning: 'pred_layers' was found in ScriptModule constants, but it is a non-constant submodule. Consider removing it.
" but it is a non-constant {}. Consider removing it.".format(name, hint))
/usr/local/lib/python3.6/dist-packages/torch/jit/_recursive.py:165: UserWarning: 'downsample_layers' was found in ScriptModule constants, but it is a non-constant submodule. Consider removing it.
" but it is a non-constant {}. Consider removing it.".format(name, hint))
Initializing weights...
Begin training!
**_Traceback (most recent call last):_**
File "train.py", line 504, in <module>
train()
File "train.py", line 270, in train
for datum in data_loader:
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 363, in __next__
data = self._next_data()
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 989, in _next_data
return self._process_data(data)
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 1014, in _process_data
data.reraise()
File "/usr/local/lib/python3.6/dist-packages/torch/_utils.py", line 395, in reraise
raise self.exc_type(msg)
**AssertionError: Caught AssertionError in DataLoader worker process 0.**
Original Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/worker.py", line 185, in _worker_loop
data = fetcher.fetch(index)
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/content/yolact/data/coco.py", line 94, in __getitem__
im, gt, masks, h, w, num_crowds = self.pull_item(index)
File "/content/yolact/data/coco.py", line 141, in pull_item
assert osp.exists(path), 'Image path does not exist: {}'.format(path)
**AssertionError: Image path does not exist: data/YolaDataset/train/6.JPG**
注意:我已将测试和训练数据移至 yolact/data/YolactDataset(CWD 也是 /yolact/)
这是日志文件 Yolact Leather Defect Config.log
这里是config.py
的内容yolact_leather_defect_dataset = Config({
'name': 'Yolact Leather Defect',
# Training images and annotations
'train_images': './data/YolaDataset/train/',
'train_info': './data/train.json',
# Validation images and annotations.
'valid_images': './data/YolaDataset/test/',
'valid_info': './data/test.json',
# Whether or not to load GT. If this is False, eval.py quantitative evaluation won't work.
'has_gt': True,
# A list of names for each of you classes.
'class_names': ("FC", "LF", "OC", "PM"),
# COCO class ids aren't sequential, so this is a bandage fix. If your ids aren't sequential,
# provide a map from category_id -> index in class_names + 1 (the +1 is there because it's 1-indexed).
# If not specified, this just assumes category ids start at 1 and increase sequentially.
'label_map': {
1:1, 2:2, 3:3, 4:4,
}
})
yolact_leather_defect_config = coco_base_config.copy({
'name': 'Yolact Leather Defect Config',
# Dataset stuff
'dataset': yolact_leather_defect_dataset,
'num_classes': len(yolact_leather_defect_dataset.class_names) + 1,
# Image Size
'max_size': 550,
# Training params
'lr_steps': (280000, 600000, 700000, 750000),
'max_iter': 800000,
# Backbone Settings
'backbone': resnet101_backbone.copy({
'selected_layers': list(range(1, 4)),
'use_pixel_scales': True,
'preapply_sqrt': False,
'use_square_anchors': True, # This is for backward compatability with a bug
'pred_aspect_ratios': [ [[1, 1/2, 2]] ]*5,
'pred_scales': [[24], [48], [96], [192], [384]],
}),
# FPN Settings
'fpn': fpn_base.copy({
'use_conv_downsample': True,
'num_downsample': 2,
}),
# Mask Settings
'mask_type': mask_type.lincomb,
'mask_alpha': 6.125,
'mask_proto_src': 0,
'mask_proto_net': [(256, 3, {'padding': 1})] * 3 + [(None, -2, {}), (256, 3, {'padding': 1})] + [(32, 1, {})],
'mask_proto_normalize_emulate_roi_pooling': True,
# Other stuff
'share_prediction_module': True,
'extra_head_net': [(256, 3, {'padding': 1})],
'positive_iou_threshold': 0.5,
'negative_iou_threshold': 0.4,
'crowd_iou_threshold': 0.7,
'use_semantic_segmentation_loss': True,
})
文件结构 https://drive.google.com/file/d/1GDaDNBayMsADnxKmbIn5OL9eU17SI6eV/view?usp=sharing
我已尽力解决问题。任何帮助将不胜感激。
谢谢!
[最初这个问题我已经发布在 yolact repo 上。]
您的文件夹名称拼写错误 :) YolaDataset 需要重命名为 YolactDataset
# Training images and annotations
'train_images': './data/YolaDataset/train/',
'train_info': './data/train.json',
# Validation images and annotations.
'valid_images': './data/YolaDataset/test/',
'valid_info': './data/test.json',