python删除coco数据库中的小人
程序员文章站
2022-06-04 11:14:18
...
import os
path='/home/lwd/data/obstacle/train-person/train'
files=os.listdir(path)
files.sort()
for f in files:
if f[-1]!='t':
continue
o=open('/home/lwd/data/obstacle/train-person/big/'+f,'w')
count=len(open(path+'/'+f,'rU').readlines())
cnt=0
for l in open(path+'/'+f):
if l[0]!='0':
o.write(l)
cnt+=1
if cnt!=count:
o.write('\n')
continue
str_list=l.split()
if float(str_list[-1])*float(str_list[-2]) > 0.05:
o.write(l)
cnt+=1
if cnt!=count:
o.write('\n')
o.close()
推荐阅读