Replies: 7 comments
-
As indicated, |
Beta Was this translation helpful? Give feedback.
-
是的,检查了数据集配置,并没有丢失字段,不明白报错的原因。
…---- Replied Message ----
| From | Tong ***@***.***> |
| Date | 03/30/2023 11:38 |
| To | ***@***.***> |
| Cc | ***@***.***>***@***.***> |
| Subject | Re: [open-mmlab/mmocr] AttributeError: 'tuple' object has no attribute 'train' (Discussion #1823) |
As indicated, type field should not be missing from the your dataset config.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
You can print out the full config and maybe paste it here for a double-check. TBH I don't think the program would make any mistake. from mmengine.config import Config
print(Config.fromfile('path/to/config').pretty_text) |
Beta Was this translation helpful? Give feedback.
-
在train.py文字中加入print(cfg.data)结果如下,cfg.data.train cfg.data.test都会报错
'tuple' object has no attribute 'train'
({'samples_per_gpu': 8, 'workers_per_gpu': 4, 'val_dataloader': {'samples_per_gpu': 1}, 'test_dataloader': {'samples_per_gpu': 1}, 'train': {'type': 'UniformConcatDataset', 'datasets': [{'type': 'IcdarDataset', 'ann_file': 'data/totaltext/instances_training.json', 'img_prefix': 'data/totaltext/imgs', 'pipeline': None}], 'pipeline': [{'type': 'LoadImageFromFile', 'color_type': 'color_ignore_orientation'}, {'type': 'LoadTextAnnotations', 'with_bbox': True, 'with_mask': True, 'poly2mask': False}, {'type': 'FixInvalidPolygon', 'min_poly_points': 4}, {'type': 'ColorJitter', 'brightness': 0.12549019607843137, 'saturation': 0.5}, {'type': 'Normalize', 'mean': [122.67891434, 116.66876762, 104.00698793], 'std': [58.395, 57.12, 57.375], 'to_rgb': True}, {'type': 'ImgAug', 'args': [['Fliplr', 0.5], {'cls': 'Affine', 'rotate': [-10, 10]}, ['Resize', [0.5, 3.0]]]}, {'type': 'EastRandomCrop', 'target_size': (640, 640)}, {'type': 'DBNetTargets', 'shrink_ratio': 0.4}, {'type': 'Pad', 'size_divisor': 32}, {'type': 'CustomFormatBundle', 'keys': ['gt_shrink', 'gt_shrink_mask', 'gt_thr', 'gt_thr_mask'], 'visualize': {'flag': False, 'boundary_key': 'gt_shrink'}}, {'type': 'Collect', 'keys': ['img', 'gt_shrink', 'gt_shrink_mask', 'gt_thr', 'gt_thr_mask']}]}, 'val': {'type': 'UniformConcatDataset', 'datasets': [{'type': 'IcdarDataset', 'ann_file': 'data/totaltext/instances_test.json', 'img_prefix': 'data/totaltext/imgs', 'pipeline': None}], 'pipeline': [{'type': 'LoadImageFromFile', 'color_type': 'color_ignore_orientation'}, {'type': 'FixInvalidPolygon', 'min_poly_points': 4}, {'type': 'MultiScaleFlipAug', 'img_scale': (4068, 1024), 'flip': False, 'transforms': [{'type': 'Resize', 'keep_ratio': True}, {'type': 'Normalize', 'mean': [122.67891434, 116.66876762, 104.00698793], 'std': [58.395, 57.12, 57.375], 'to_rgb': True}, {'type': 'Pad', 'size_divisor': 32}, {'type': 'ImageToTensor', 'keys': ['img']}, {'type': 'Collect', 'keys': ['img']}]}]}, 'test': {'type': 'UniformConcatDataset', 'datasets': [{'type': 'IcdarDataset', 'ann_file': 'data/totaltext/instances_test.json', 'img_prefix': 'data/totaltext/imgs', 'pipeline': None}], 'pipeline': [{'type': 'LoadImageFromFile', 'color_type': 'color_ignore_orientation'}, {'type': 'FixInvalidPolygon', 'min_poly_points': 4}, {'type': 'MultiScaleFlipAug', 'img_scale': (4068, 1024), 'flip': False, 'transforms': [{'type': 'Resize', 'keep_ratio': True}, {'type': 'Normalize', 'mean': [122.67891434, 116.66876762, 104.00698793], 'std': [58.395, 57.12, 57.375], 'to_rgb': True}, {'type': 'Pad', 'size_divisor': 32}, {'type': 'ImageToTensor', 'keys': ['img']}, {'type': 'Collect', 'keys': ['img']}]}]}},)
…---- Replied Message ----
| From | Tong ***@***.***> |
| Date | 03/30/2023 12:47 |
| To | ***@***.***> |
| Cc | ***@***.***>***@***.***> |
| Subject | Re: [open-mmlab/mmocr] AttributeError: 'tuple' object has no attribute 'train' (Discussion #1823) |
You can print out the full config and maybe paste it here for a double-check. TBH I don't think the program would make any mistake.
frommmengine.configimportConfigprint(Config.fromfile('path/to/config').pretty_text)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I think you are trying to use MMOCR 0.x config in MMOCR 1.0, which unfortunately cannot be supported.
Read https://mmocr.readthedocs.io/en/dev-1.x/migration/overview.html for more details. |
Beta Was this translation helpful? Give feedback.
-
实际上,我使用的代码与环境都是mmocr0.x:
TorchVision: 0.9.1+cu111OpenCV: 4.6.0MMCV: 1.4.0MMCV Compiler: GCC 7.3MMCV CUDA Compiler: 11.1MMOCR: 0.6.1+
但是我会继续尝试mmocr1.x,感谢您的回复。
…---- Replied Message ----
| From | Tong ***@***.***> |
| Date | 03/30/2023 14:54 |
| To | ***@***.***> |
| Cc | ***@***.***>***@***.***> |
| Subject | Re: [open-mmlab/mmocr] AttributeError: 'tuple' object has no attribute 'train' (Discussion #1823) |
I think you are trying to use MMOCR 0.x config in MMOCR 1.0, which unfortunately cannot be supported.
MMOCR 1.0 depends on the new foundational library for training deep learning models MMEngine, and therefore has an entirely different dependency chain compared with MMOCR 0.x. Even if you have a well-rounded MMOCR 0.x environment before, you still need to create a new python environment for MMOCR 1.0. We provide a detailed installation guide for reference.
Read https://mmocr.readthedocs.io/en/dev-1.x/migration/overview.html for more details.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I don't think so. For your first post:
Apparently, the environment has mmengine. It's important to separate environments for 0.x and 1.x. |
Beta Was this translation helpful? Give feedback.
-
datasets = [build_dataset(cfg.data.train)]
train文件运行到这一句报错 datasets = [build_dataset(cfg.data.train)]
如果去掉train,则会报错找不到type类型
Traceback (most recent call last):
File "tools/train.py", line 230, in
main()
File "tools/train.py", line 192, in main
datasets = [build_dataset(cfg.data)]
File "/root/mmocr-main/mmocr/datasets/builder.py", line 26, in build_dataset
dataset = ConcatDataset([build_dataset(c, default_args) for c in cfg])
File "/root/mmocr-main/mmocr/datasets/builder.py", line 26, in
dataset = ConcatDataset([build_dataset(c, default_args) for c in cfg])
File "/root/mmocr-main/mmocr/datasets/builder.py", line 27, in build_dataset
elif cfg['type'] == 'ConcatDataset':
File "/root/miniconda3/lib/python3.8/site-packages/mmengine/config/config.py", line 47, in missing
raise KeyError(name)
KeyError: 'type'
请问该如何解决这个报错?
Beta Was this translation helpful? Give feedback.
All reactions