From e33baa2b7c016d9a927408c3e542c6f030fd73f0 Mon Sep 17 00:00:00 2001 From: wangshipeng01 Date: Thu, 16 Apr 2020 06:19:31 +0000 Subject: [PATCH] add generate lable list script --- dataset/generate_flower_list.py | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 dataset/generate_flower_list.py diff --git a/dataset/generate_flower_list.py b/dataset/generate_flower_list.py new file mode 100644 index 000000000..549651625 --- /dev/null +++ b/dataset/generate_flower_list.py @@ -0,0 +1,39 @@ +import scipy.io +import numpy as np +import os +import sys + +""" +Usage: python generate_flower_list.py ./jpg train > train_list.txt + python generate_flower_list.py ./jpg valid > val_list.txt +""" + + +data_path = sys.argv[1] +imagelabels_path='./imagelabels.mat' +setid_path='./setid.mat' + +""" +imagelabel.mat +jpg_name 1 2 3 ... +label 32 12 66 ... +""" +labels = scipy.io.loadmat(imagelabels_path) +labels = np.array(labels['labels'][0]) +setid = scipy.io.loadmat(setid_path) + +d = {} +d['train'] = np.array(setid['trnid'][0]) +d['valid'] = np.array(setid['valid'][0]) +d['test']=np.array(setid['tstid'][0]) + +""" +setid.mat +jpg_name 24 6 100 65 32 ... +label 4 ... +""" + + +for id in d[sys.argv[2]]: + message = str(data_path)+"/image_"+str(id).zfill(5)+" "+str(labels[id-1]) + print(message)