我是python新手。 我创建了一个代码来计算YOLO注释中包含了多少类,我遇到了这个错误
我真的不熟悉这个编码错误 我搜索了很多,但是对于“0xc4”没有解决方案
首先,我添加我的全部代码
mid_num = 4000
total_num = 13485 #총 이미지 개수
dir = '/media/aicar/Seagate Backup Plus Drive/최종_데이터셋_cone/labels/' #어노테이션이 있는 위치
# dir = '/home/aicar/labelImg-master/data/'
cone = 0
stick = 0
crossline = 0
stopline = 0
red_light = 0
yellow_light = 0
green_light = 0
str_and_left = 0
left_turn = 0
drum = 0
for idx in range(1, mid_num+1):
# filename = dir + str(idx) + '.txt'
filename = dir + 'corn_' + str(idx) + '.txt'
# f = open(filename, 'r')
col_2=[]
with open(filename) as f:
for line in f:
chars=[]
line=line.split(' ')
for char in line:
if char not in ['',' ']:
chars.append(char)
col_2.append(chars[0])
f.close()
# print(col_2)
if '0' in col_2:
cone = cone +1
if '1' in col_2:
stick = stick +1
if '2' in col_2:
crossline = crossline +1
if '3' in col_2:
stopline = stopline +1
if '4' in col_2:
red_light = red_light +1
if '5' in col_2:
yellow_light = yellow_light +1
if '6' in col_2:
green_light = green_light +1
if '7' in col_2:
str_and_left = str_and_left +1
if '8' in col_2:
left_turn = left_turn +1
if '9' in col_2:
drum = drum +1
print('cone : ' + str(cone))
print('stick : ' + str(stick))
print('crossline : ' + str(crossline))
print('stopline : ' + str(red_light))
print('red_light : ' + str(red_light))
print('yellow_light : ' + str(yellow_light))
print('green_light : ' + str(green_light))
print('str_and_left : ' + str(str_and_left))
print('left_turn : ' + str(left_turn))
print('drum : ' + str(drum))
我拥有的tin总数是13485,如第5行的“总数”所示
如果我在13485注释上运行这段代码,就会出现UnicodeDecodeError,如果我运行大约1000条注释,它就可以正常工作
下图是仅打开1000条注释时的终端窗口
我需要专家的帮助。 谢谢
目前没有回答
相关问题 更多 >
编程相关推荐