代码拉取完成,页面将自动刷新
# pdpd输入格式的txt
pdfile = './final_our.txt'
# pytorch输入格式的txt
ptfile = './final_our_pt.txt'
f = open(pdfile, 'r')
f_pt = open(ptfile, 'w')
lines = f.readlines()
i = 0
rect = 0
total = 0
while i < len(lines):
if 'jpg' in lines[i]:
im_id = lines[i].rstrip()
# print(im_id)
num = int(lines[i + 1].rstrip())
#
i = i + 2
box = []
bad = 0
for j in range(num):
x1, y1, w, h = map(int, lines[i].rstrip().split(' ')[0:4])
if w != h:
print(im_id)
print(w, h)
rect += 1
if w == 0 or h == 0:
# print(im_id)
bad += 1
i = i + 1
continue
else:
box.append([x1, y1, w, h])
i = i + 1
num = num - bad
total += num
if num > 0:
f_pt.write(im_id)
f_pt.write(' {0}'.format(num))
for [x1, y1, w, h] in box:
f_pt.write(' {0} {1} {2} {3}'.format(x1, y1, w, h))
f_pt.write('\n')
else:
pass
else:
i = i + 1
f_pt.close()
f.close()
print(rect)
print(total)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。