Skip to content
This repository was archived by the owner on Jun 27, 2025. It is now read-only.

Commit 607e16f

Browse files
committed
update to 0.2.1
1 parent 9b612e8 commit 607e16f

File tree

5 files changed

+36
-25
lines changed

5 files changed

+36
-25
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ Simple WIDERFACE data parser written in python
33

44
WIDERFACE is a database of face bounding boxes available on http://mmlab.ie.cuhk.edu.hk/projects/WIDERFace/.
55

6-
You can download the database via `python get_data.py`
7-
86
## Requirement
9-
h5py(v2.6.0)
7+
scipy(v0.19.0)
108

119
## Usage
1210
Please see `wider/examples/example.py` for usage
1311

1412
you also need opencv and matplotlib (v2.0.0) to run the example.
15-

requirement.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
h5py==2.6.0
1+
scipy==0.19.0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from distutils.core import setup
77

88
NAME = 'python-widerface'
9-
VERSION = '0.1.2'
9+
VERSION = '0.2.1'
1010

1111
# Compile the list of packages available, because distutils doesn't have
1212
# an easy way to do this.

wider/examples/example.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
import matplotlib.pyplot as plt
33
import cv2
44

5-
wider = WIDER('/home/tumh/python-wider/data/v1',
6-
'/home/tumh/python-wider/data/WIDER_train/images',
7-
'wider_face_train.mat')
5+
# arg1: path to label
6+
# arg2: path to images
7+
# arg3: label file name
8+
wider = WIDER('/home/tumh/wider_face_split',
9+
'/home/tumh/WIDER_val/images',
10+
'wider_face_val.mat')
811

912

1013
# press ctrl-C to stop the process

wider/loader.py

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import h5py
1+
import matplotlib.pyplot as plt
22
import os
3+
import scipy.io
34

45

56
class DATA(object):
@@ -9,33 +10,43 @@ def __init__(self, image_name, bboxes):
910

1011

1112
class WIDER(object):
13+
"""
14+
Build a wider parser
15+
16+
Parameters
17+
----------
18+
path_to_label : path of the label file
19+
path_to_image : path of the image files
20+
fname : name of the label file
21+
22+
Returns
23+
-------
24+
a wider parser
25+
"""
1226
def __init__(self, path_to_label, path_to_image, fname):
1327
self.path_to_label = path_to_label
1428
self.path_to_image = path_to_image
1529

16-
self.f = h5py.File(os.path.join(path_to_label, fname), 'r')
30+
self.f = scipy.io.loadmat(os.path.join(path_to_label, fname))
1731
self.event_list = self.f.get('event_list')
1832
self.file_list = self.f.get('file_list')
1933
self.face_bbx_list = self.f.get('face_bbx_list')
2034

2135
def next(self):
22-
23-
for event_idx, event in enumerate(self.event_list.value[0]):
24-
directory = self.f[event].value.tostring().decode('utf-16')
25-
for im_idx, im in enumerate(
26-
self.f[self.file_list.value[0][event_idx]].value[0]):
27-
28-
im_name = self.f[im].value.tostring().decode('utf-16')
29-
face_bbx = self.f[self.f[self.face_bbx_list.value
30-
[0][event_idx]].value[0][im_idx]].value
36+
for event_idx, event in enumerate(self.event_list):
37+
directory = event[0][0]
38+
for im_idx, im in enumerate(self.file_list[event_idx][0]):
39+
im_name = im[0][0]
40+
face_bbx = self.face_bbx_list[event_idx][0][im_idx][0]
41+
# print face_bbx.shape
3142

3243
bboxes = []
3344

34-
for i in range(face_bbx.shape[1]):
35-
xmin = int(face_bbx[0][i])
36-
ymin = int(face_bbx[1][i])
37-
xmax = int(face_bbx[0][i] + face_bbx[2][i])
38-
ymax = int(face_bbx[1][i] + face_bbx[3][i])
45+
for i in range(face_bbx.shape[0]):
46+
xmin = int(face_bbx[i][0])
47+
ymin = int(face_bbx[i][1])
48+
xmax = int(face_bbx[i][2]) + xmin
49+
ymax = int(face_bbx[i][3]) + ymin
3950
bboxes.append((xmin, ymin, xmax, ymax))
4051

4152
yield DATA(os.path.join(self.path_to_image, directory,

0 commit comments

Comments
 (0)