新数据的GT列表

制作新数据集时需要重新制作train_GT,test_GT

代码:

dic = {}
with open('/home/bnrc/all_image_GT.txt','r') as file:
    for line in file:
        line_title = line.split('.jpg')[0]+'.jpg'
        # print line_title
        # print line
        dic.update({line_title:line})

with open('/home/bnrc/Dataset_new/new_train/train.txt','r') as file1:
    with open('/home/bnrc/train_GT.txt','a') as fil1:
        for line in file1:
            line = line[:-1]
            line_new = dic.get(line)
            fil1.write(line_new)

with open('/home/bnrc/Dataset_new/new_test/test.txt','r') as file2:
    with open('/home/bnrc/test_GT.txt','a') as fil2:
        for line in file2:
            line = line[:-1]
            line_new = dic.get(line)
            fil2.write(line_new)

 

posted @ 2017-08-20 23:25  有梦就要去实现他  阅读(300)  评论(0编辑  收藏  举报