错误注释:x = 0, y = 0, < 0 or > 1 with YOLO

Wrong annotation: x = 0, y = 0, < 0 or > 1 with YOLO

当我使用 yolo 训练我的数据集时出现此错误,我理解这意味着标签不在图像的边界内,而是来自打开图像的数据。我对每个文件都收到此错误。

Wrong annotation: x = 0, y = 0, < 0 or > 1, file: data/obj/3149c61b7407b0c5.txt

转换标签时,class 最初全部为 101,这给了我一个错误,所以我使用此

将它们全部转换为 0
import glob


for filepath in glob.iglob('./**/*.txt', recursive=True):
    with open(filepath) as file:
        s = file.read()
    s = s.replace('101 ', '0 ')
    with open(filepath, "w") as file:
        file.write(s)

这是一个文件“3149c61b7407b0c5.txt”的内容,它也给出了这个错误。

0 1085.6260855566406 1254.4786898033353 2.9297560546874593 102.1827418215693
0 1086.0899527441406 607.6991307711304 3.857441406250018 1176.3009893473438
0 1137.8566324316407 1307.114119795808 91.84562460937491 5.3656234452045295
0 1186.680802158203 607.1194858238297 3.8867578125000364 1175.290322583892
0 1187.6573546972656 1361.4528185098725 3.8672361230469505 101.16129032792523
0 1234.0440929785157 1195.3281309872493 92.75390625 3.2795265516661787
0 1234.0284875097657 604.9840441022702 90.90814453124995 1177.3440653795917
0 1235.4991806640626 1360.3872916281202 91.875 101.11822602580656
0 1236.9639953222656 17.328152487227214 92.75390625 4.290258067785163
0 1283.3262900390625 7.146366677539043 3.8965437597655637 14.01077505600043
0 1431.255040830078 1251.7474424893667 94.71674785156256 101.12901075597932
0 1430.7726089941407 1630.7969258238081 91.77738281250004 5.3978934344627785
0 1477.198360751953 1626.5442385087865 4.86328125 5.365623446172403
0 1528.974786533203 1789.3657435657651 90.85930644531254 103.20425816668744
0 1579.2491416015625 1898.0120122775286 3.828125 99.01077386239739
0 1625.6456455078126 1519.5280764679483 92.73437579101551 4.344172047279395
0 1627.1007041015625 1467.355033670012 91.875 100.0859898946889
0 1674.4591220703126 1358.7162488302274 4.853545517578141 102.13981699359162
0 1772.593927158203 1950.1948291506785 3.876963085937632 5.35483871502201
0 1871.709142001953 2003.349592810873 4.863222255859455 101.10751591723597
0 1871.2404211035157 1843.6894421635711 3.9062204980468778 5.33334387530102

Yolo 标签按图像的比例完成 width/height。这样即使调整图像大小,标签也能保持真实。标签格式为:

<class id> <x> <y> <width> <height>

例如,标签上写着

0 150 50 450 100

在 600x200 的图片上

0 .25 .25 .75 .5