Skip to content

Instantly share code, notes, and snippets.

@twmht
Last active January 8, 2017 01:21
Show Gist options
  • Save twmht/f74fe4dfdd1694f6b1293a531ac7f8cf to your computer and use it in GitHub Desktop.
Save twmht/f74fe4dfdd1694f6b1293a531ac7f8cf to your computer and use it in GitHub Desktop.
h5py for wider
import numpy as np, h5py
from collections import defaultdict
import os
f = h5py.File('wider_face_train.mat','r')
event_list = f.get('event_list')
print f[event_list.value[0][0]].value.tostring()
# for i in range(0, 61):
# print f[event_list.value[0][i]].value.tostring()
file_list = f.get('file_list')
print f[f[file_list.value[0][0]].value[0][0]].value.tostring()
print f[file_list.value[0][0]].value[0]
face_bbx_list = f.get('face_bbx_list')
print f[f[face_bbx_list.value[0][0]].value[0][0]].value
coord = []
for event_idx, event in enumerate(event_list.value[0]):
directory = f[event].value.tostring()
for im_idx, im in enumerate(f[file_list.value[0][event_idx]].value[0]):
# loop each image's name
im_name = f[im].value.tostring()
print os.path.join(directory, im_name)
bbox = f[f[face_bbx_list.value[0][event_idx]].value[0][im_idx]].value
print bbox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment