wangyuxin87 / ContourNet

A PyTorch implementation of "ContourNet: Taking a Further Step toward Accurate Arbitrary-shaped Scene Text Detection" (CVPR2020)
Other
227 stars 46 forks source link

target.resize报错 #4

Closed shine-lcy closed 4 years ago

shine-lcy commented 4 years ago

非常感谢您开源代码,由于是国人我就用中文写issue了。 环境配置好后,跑test_contour.sh时报错:

File "/home/licaiyuan/ocr/ContourNet/maskrcnn_benchmark/data/transforms/transforms.py", line 81, in <listcomp>
    target = [t.resize(image.size) for t in target]
AttributeError: 'dict' object has no attribute 'resize'

此时target输出来如下这么一个list

[{'image_id': 3, 'segmentation': [[831, 115, 1003, 72, 1012, 171, 835, 195]], 'match_type': 10, 'bbox': [831, 72, 182, 124], 'area': 22568, 'category_id': 1, 'iscrowd': 0, 'id': 31, 'keypoints': [920.25, 138.25, 2, 875.625, 138.25, 2, 877.625, 138.25, 2, 961.625, 138.25, 2, 966.125, 138.25, 2, 920.25, 105.125, 2, 920.25, 126.625, 2, 920.25, 154.625, 2, 920.25, 166.625, 2, 910, 139, 2]}, {'image_id': 3, 'segmentation': [[410, 187, 451, 192, 447, 207, 406, 203]], 'match_type': 13, 'bbox': [406, 187, 46, 21], 'area': 966, 'category_id': 1, 'iscrowd': 0, 'id': 32, 'keypoints': [428.5, 197.25, 2, 417.25, 197.25, 2, 419.25, 197.25, 2, 437.75, 197.25, 2, 439.75, 197.25, 2, 428.5, 192.125, 2, 428.5, 194.625, 2, 428.5, 200.125, 2, 428.5, 202.125, 2, 429, 197, 2]}, {'image_id': 3, 'segmentation': [[451, 191, 485, 194, 484, 208, 450, 205]], 'match_type': 13, 'bbox': [450, 191, 36, 18], 'area': 648, 'category_id': 1, 'iscrowd': 0, 'id': 33, 'keypoints': [467.5, 199.5, 2, 458.75, 199.5, 2, 459.25, 199.5, 2, 475.75, 199.5, 2, 476.25, 199.5, 2, 467.5, 195.25, 2, 467.5, 196.75, 2, 467.5, 202.25, 2, 467.5, 203.75, 2, 467, 199, 2]}]

每一个元素t格式为

{'image_id': 3, 'segmentation': [[831, 115, 1003, 72, 1012, 171, 835, 195]], 'match_type': 10, 'bbox': [831, 72, 182, 124], 'area': 22568, 'category_id': 1, 'iscrowd': 0, 'id': 31, 'keypoints': [920.25, 138.25, 2, 875.625, 138.25, 2, 877.625, 138.25, 2, 961.625, 138.25, 2, 966.125, 138.25, 2, 920.25, 105.125, 2, 920.25, 126.625, 2, 920.25, 154.625, 2, 920.25, 166.625, 2, 910, 139, 2]}

是一个包含很多信息的dict, 在resize时会报错。

数据集是下载的您提供的coco format ic15。

shine-lcy commented 4 years ago

好像解决了,可能是我coco版本有问题还是怎么着,在跑到word_dataset.py line 64

img, anno = super(WordDataset, self).__getitem__(idx)

时,进入coco.py line 118-119

if self.transforms is not None:
    img, target = self.transforms(img, target)

即在target还不是BoxList格式时已经在过tranforms,把这两句注释掉就好了。 因为在word_dataset.py里,target转化为BoxList格式后还要过transforms

S130111 commented 3 years ago

按您说的方法没有解决 我也出现了 这个错误

abdur75648 commented 2 years ago

Use torchvision==0.2.1 This solved my problem