未验证 提交 534860f1 编写于 作者: C cuicheng01 提交者: GitHub

Update generate_flower_list.py

上级 554ed96c
import scipy.io
import numpy as np
import os
import sys
""".mat files data format
"""
.mat files data format
imagelabel.mat
jpg_name 1 2 3 ...
label 32 12 66 ...
......@@ -14,14 +10,19 @@ label 4 ...
"""
"""
Usage:
python generate_flower_list.py prefix_folder mode
python generate_flower_list.py jpg train > train_list.txt
python generate_flower_list.py jpg valid > val_list.txt
python generate_flower_list.py prefix_folder mode
python generate_flower_list.py jpg train > train_list.txt
python generate_flower_list.py jpg valid > val_list.txt
"""
import scipy.io
import numpy as np
import os
import sys
data_path = sys.argv[1]
imagelabels_path='./imagelabels.mat'
setid_path='./setid.mat'
imagelabels_path = './imagelabels.mat'
setid_path = './setid.mat'
labels = scipy.io.loadmat(imagelabels_path)
labels = np.array(labels['labels'][0])
......@@ -30,8 +31,8 @@ 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])
d['test'] = np.array(setid['tstid'][0])
for id in d[sys.argv[2]]:
message = str(data_path)+"/image_"+str(id).zfill(5)+".jpg "+str(labels[id-1])
message = str(data_path) + "/image_" + str(id).zfill(5) + ".jpg " + str(labels[id - 1] - 1)
print(message)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册