我想训练MRCNN使用预先训练的COCO权重来检测2个新类别(底部,碗状)。我在VGG图像注释器中已经掩盖了大约400张图像,无法加载。我认为我创建的类和多边形存在问题,但是因为有400多个图像,所以我真的不想从头开始。
基本上我是按物质端口使用代码 https://github.com/matterport/Mask_RCNN
在读取带有类和多边形的.json文件时,我遇到了错误:
Traceback (most recent call last):
File ".\Test.py", line 302, in <module>
train(model)
File ".\Test.py", line 170, in train
dataset_train.load_meooow(args.dataset, "train")
File ".\Test.py", line 115, in load_meooow
num_ids = [int(n['class']) for n in objects]
File ".\Test.py", line 115, in <listcomp>
num_ids = [int(n['class']) for n in objects]
ValueError: invalid literal for int() with base 10: 'bottom'
我了解到,脚本试图将'bottom'转换为int是非法的,这就是我遇到该错误的原因。
我想我的口罩有问题,但由于口罩很多,我希望对此可以做些...
对我来说,.json文件结构似乎有问题,但我看不出有什么问题。
其中一张图片(2个类别)的多边形下方
3D_3_14 (4).jpg2371607":{"fileref":"","size":2371607,"filename":"3D_3_14 (4).jpg","base64_img_data":"","file_attributes":{},"regions":{"0":{"shape_attributes":{"name":"polygon","all_points_x":[11,40,200,370,616,761,823,996,1268,1399,1565,1672,1818,1847,2078,2231,2379,2455,2468,2585,2583,7,11],"all_points_y":[1093,1053,984,942,929,916,1002,1022,1009,1058,1051,1049,969,909,918,949,973,1000,1033,1035,1940,1938,1093]},"region_attributes":{"class":"bottom"}},"1":{"shape_attributes":{"name":"polygon","all_points_x":[4,2590,2585,2463,2448,2319,2137,1982,1838,1849,1825,1818,1639,1428,1160,956,867,718,632,576,639,676,714,756,448,297,131,11,4],"all_points_y":[9,9,1035,1038,993,958,925,916,909,827,778,698,552,463,390,341,346,401,486,572,705,774,856,914,933,958,1009,1071,9]},"region_attributes":{"class":"bowl"}}}}
在蒙版过程中,有时我更改了班级顺序。我的意思是有时候下课是第一课,碗是第二课
1 bottom
2 bowl
有时碗是1类,底部是2类
1 bowl
2 bottom
当有东西覆盖在碗上时,我不得不将其分成2个多边形,但名称相同。所以我在VGG中有1个底,2个碗,3个碗。
1 bottom
2 bowl
3 bowl
可能是问题还是只要我对多边形贴上正确的标签就可以了吗?
我不能使用rcnn,mrcnn,mask-rcnn之类的标签,因为它至少需要1500信誉。.对不起...
答案 0 :(得分:0)
如果您不想将类名注释为整数字符串“ 1”,则可以像在我的案例中那样尝试以下代码:
classes_name = ['bottom', 'bowl']
num_ids = [classes_name.index(n['class']) + 1 for n in objects]
答案 1 :(得分:0)
好吧,该错误是由于在VGG中添加了类。就我而言,在注释时,我使用班级名称代替班级编号。 删除班级名称,然后将其替换为班级编号。在您的情况下,请更换 在VGG中进行插补时,底部为1的碗和底部为2的碗