gen_split_file.ipynb

g e n − s p l i − f i l e . i p y n b gen-spli-file.ipynb gensplifile.ipynb

split 文件的模版样本

  • 101_ObjectCategories/metronome/image_0004.jpg 0
import pandas as pd
import numpy as np
import glob
import os
path_file = '/data/nextcloud/dbc2017/files/jupyter/PyRetri/main/split_file/caltech_split.txt'
gallery_lst = glob.glob('/data/nextcloud/dbc2017/files/jupyter/test_data_A/gallery/*.jpg')
query_lst = glob.glob('/data/nextcloud/dbc2017/files/jupyter/test_data_A/query/*.jpg')
gallery_path = ['101_ObjectCategories/allimg/'+os.path.basename(i) for i in gallery_lst]
query_lst = ['101_ObjectCategories/allimg/'+os.path.basename(i) for i in query_lst]
print(len(query_lst))
print(len(gallery_lst))

在这里插入图片描述

if os.path.exists(path_file):
    os.remove(path_file)
with open(path_file,'w') as f:
    for i in gallery_path:
        f.write('{0} {1}\n'.format(i,1))
    for index,i in enumerate(query_lst):
        if index != len(query_lst)-1:
            f.write('{0} {1}\n'.format(i,0))
        else:
            f.write('{0} {1}'.format(i,0))

猜你喜欢

转载自blog.csdn.net/qq_41375318/article/details/108550004
gen