代码拉取完成,页面将自动刷新
import numpy as np
import os
import math
dir_txt = "model/ship_gt/labels_int/"
list_txt = os.listdir(dir_txt)
# labels from float to int
# print(list_txt)
# import pdb
# pdb.set_trace()
ratio_hw = {'1':0,'2':0,'3':0,'4':0,'5':0,'6':0,'7':0,'8':0,'9':0}
ratio_wh = {'1':0,'2':0,'3':0,'4':0,'5':0,'6':0,'7':0,'8':0,'9':0}
ratio_area = [0 for i in range(20)]
# for txt in list_txt:
# # print('{}{}'.format(dir_txt,txt))
# with open('{}{}'.format(dir_txt,txt), 'r') as fr:
# line = fr.readlines()[0]
# # print(line.split(','))
# data = line.split(',')
# w = float(data[4])-float(data[0])
# h = float(data[5])-float(data[1])
# if h/w > 1:
# ratio_hw[str(int(math.floor(h/w)))]+=1
# if w/h > 1:
# ratio_wh[str(int(math.floor(w/h)))]+=1
# # print(int(w*h/1000))
# ratio_area[int(w*h/10000) if int(w*h/10000)<20 else 19 ]+=1
# import pdb
# pdb.set_trace()
print('ratio_hw')
for key in ratio_hw.keys():
print('{}:{}'.format(key,ratio_hw[key]))
print('ratio_wh')
for key in ratio_wh.keys():
print('{}:{}'.format(key,ratio_wh[key]))
print('area')
for index in range(len(ratio_area)):
print('{}:{}'.format(index,ratio_area[index]))
for txt in list_txt:
# print('{}{}'.format(dir_txt,txt))
# import pdb
# pdb.set_trace()
if txt.split('_')[0]=='DDG':
with open('{}{}'.format(dir_txt,txt), 'r') as fr:
line = fr.readlines()[0]
# print(line.split(','))
data = line.split(',')
w = float(data[4])-float(data[0])
h = float(data[5])-float(data[1])
if h/w > 1:
ratio_hw[str(int(math.floor(h/w)))]+=1
if w/h > 1:
ratio_wh[str(int(math.floor(w/h)))]+=1
# print(int(w*h/1000))
ratio_area[int(w*h/1000) if int(w*h/1000)<20 else 19 ]+=1
print('\nddg')
print('ratio_hw')
for key in ratio_hw.keys():
print('{}:{}'.format(key,ratio_hw[key]))
print('ratio_wh')
for key in ratio_wh.keys():
print('{}:{}'.format(key,ratio_wh[key]))
print('area')
for index in range(len(ratio_area)):
print('{}:{}'.format(index,ratio_area[index]))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。