1 Star 0 Fork 0

loic_wang/ZJUAI_PyramidBoxDetector

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
topytorch_all.py 1.20 KB
一键复制 编辑 原始数据 按行查看 历史
叶伟才 提交于 2019-03-19 11:45 . first commit
# pdpd输入格式的txt
pdfile = './final_all.txt'
# pytorch输入格式的txt
ptfile = './final_all_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)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/loic_wang/ZJUAI_PyramidBoxDetector.git
git@gitee.com:loic_wang/ZJUAI_PyramidBoxDetector.git
loic_wang
ZJUAI_PyramidBoxDetector
ZJUAI_PyramidBoxDetector
master

搜索帮助