背景:在Test数据集中划分Query和Gallery时,会发现有的id的数量比较少,按比例划分的时候Gallery里有而Query里没有,因此就要找出哪些id在Gallery中有而Query没有。所以先把相同id的图片放到同一个文件夹中,对Query和Gallery都遍历一遍,然后发现Query有438个id而Gallery有544个id,所以把差集找出来然后补全到Query,同时从同文件夹的Gallery抽一张图片到Query
import os
import random
import shutil
from shutil import copy2
from IPython import embed
"""如果不存在文件夹,就建一个文件夹"""
def mkDir(path,id):
isExists = os.path.exists(os.path.join(path, id))
if not isExists: #判断如果文件不存在,则创建
os.makedirs(os.path