Skip to content

Commit 99de7af

Browse files
committed
Change convert_old.py(no need to specify the feature size in advance, we can directly use the loaded array size to create dataset);
remove prepro_process_script.sh
1 parent 6b8a740 commit 99de7af

File tree

2 files changed

+8
-26
lines changed

2 files changed

+8
-26
lines changed

scripts/convert_old.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,19 @@ def main(params):
1818
with h5py.File(os.path.join(params['fc_output_dir'], 'feats_fc.h5')) as file_fc,\
1919
h5py.File(os.path.join(params['att_output_dir'], 'feats_att.h5')) as file_att:
2020
for i, img in enumerate(imgs):
21-
d_set_fc = file_fc.create_dataset(
22-
str(img['cocoid']), (2048,), dtype="float")
23-
d_set_att = file_att.create_dataset(
24-
str(img['cocoid']),
25-
(params['att_size'], params['att_size'], 2048), dtype="float")
26-
2721
npy_fc_path = os.path.join(
28-
params['fc_input_dir'][:-1],
22+
params['fc_input_dir'],
2923
str(img['cocoid']) + '.npy')
3024
npy_att_path = os.path.join(
31-
params['att_input_dir'][:-1],
25+
params['att_input_dir'],
3226
str(img['cocoid']) + '.npz')
3327

34-
d_set_fc[...] = np.load(npy_fc_path)
35-
d_set_att[...] = np.load(npy_att_path)['feat']
28+
d_set_fc = file_fc.create_dataset(
29+
str(img['cocoid']), data=np.load(npy_fc_path))
30+
d_set_att = file_att.create_dataset(
31+
str(img['cocoid']),
32+
data=np.load(npy_att_path)['feat'])
33+
3634
if i % 1000 == 0:
3735
print('processing %d/%d (%.2f%% done)' % (i, N, i * 100.0 / N))
3836
file_fc.close()
@@ -48,7 +46,6 @@ def main(params):
4846
parser.add_argument('--att_output_dir', default='data', help='output directory for att')
4947
parser.add_argument('--fc_input_dir', default='data', help='input directory for numpy fc files')
5048
parser.add_argument('--att_input_dir', default='data', help='input directory for numpy att files')
51-
parser.add_argument('--att_size', default=14, type=int, help='14x14 or 7x7')
5249

5350
args = parser.parse_args()
5451
params = vars(args) # convert to ordinary dict

scripts/pre_process_script.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)