整理300W数据集landmark的脚本

68点数据集300W的网址:http://ibug.doc.ic.ac.uk/resources/300-W_IMAVIS/

该数据集原本是每张照片对应有一个.pts格式的标注信息,而.pts不方便读取。

我的工作是:

1.用批处理文件把 .pts 改为 .txt

 2. 编写脚本,整合标注信息到一个txt上面

import math
import os


def make_txt(totol_num):
    temp_index = 1
    while temp_index <= totol_num:
        if temp_index < 10:
            index = '00' + str(temp_index)
        elif temp_index < 100:
            index = '0' + str(temp_index)
        else:
            index = str(temp_index)
        make_one_txt(index)
        temp_index = temp_index + 1


def make_one_txt(index):
    num_of_line = 1
    input_path = '02_Outdoor/outdoor_%s.txt' % index
    image_path = '02_Outdoor/outdoor_%s.png' % index
    print('input_path:', input_path)
    with open(input_path, 'r') as f:
        while True:
            line = f.readline()
            print(line)
            if num_of_line == 1:
                write_txt(image_path)
                write_txt('\n')
            elif num_of_line > 3 and num_of_line < 72:
                write_txt(line)
            elif num_of_line >= 72:
                break
            num_of_line = num_of_line + 1


def write_txt(line):
    output_file = '300w.txt'
    with open(output_file, 'a') as f:
        f.write(line)


if __name__ == '__main__':
    print('lala')
    totol_num = 300
    make_txt(totol_num)

文件见我的github:https://github.com/Watebear/Annotation-file-for-300w-/

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值