# pdpd输入格式的txt pdfile = '../yuncong_train_9000.txt' # pytorch输入格式的txt ptfile = '../yuncong_train9000_pt.txt' f = open(pdfile, 'r') f_pt = open(ptfile, 'w') lines = f.readlines() i = 0 rect = 0 total = 0 while i0: 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)