Skip to content

Commit 8052c75

Browse files
authored
Merge pull request #485 from tensorlayer/api-rename
rename APIs of obj detection and pose
2 parents c55bfc4 + 8e93a48 commit 8052c75

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

docs/modules/prepro.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,12 @@ Some of the code in this package are borrowed from Keras.
8181
parse_darknet_ann_str_to_list
8282
parse_darknet_ann_list_to_cls_box
8383

84-
obj_box_left_right_flip
84+
obj_box_horizontal_flip
8585
obj_box_imresize
8686
obj_box_crop
8787
obj_box_shift
8888
obj_box_zoom
8989

90-
91-
9290
pad_sequences
9391
remove_pad_sequences
9492
process_sequences
@@ -270,7 +268,7 @@ Hi, here is an example for image augmentation on VOC dataset.
270268
ann_list[idx][1], [], classes, True, save_name='_im_original.png')
271269
272270
# left right flip
273-
im_flip, coords = tl.prepro.obj_box_left_right_flip(image,
271+
im_flip, coords = tl.prepro.obj_box_horizontal_flip(image,
274272
ann_list[idx][1], is_rescale=True, is_center=True, is_random=False)
275273
tl.vis.draw_boxes_and_labels_to_image(im_flip, ann_list[idx][0],
276274
coords, [], classes, True, save_name='_im_flip.png')
@@ -321,7 +319,7 @@ In practice, you may want to use threading method to process a batch of images a
321319
im = tl.prepro.illumination(im, gamma=(0.5, 1.5),
322320
contrast=(0.5, 1.5), saturation=(0.5, 1.5), is_random=True)
323321
## flip randomly
324-
im, coords = tl.prepro.obj_box_left_right_flip(im, coords,
322+
im, coords = tl.prepro.obj_box_horizontal_flip(im, coords,
325323
is_rescale=True, is_center=True, is_random=True)
326324
## randomly resize and crop image, it can have same effect as random zoom
327325
tmp0 = random.randint(1, int(im_size[0]*jitter))
@@ -400,7 +398,7 @@ Darknet format split class and coordinate
400398

401399
Image Aug - Flip
402400
^^^^^^^^^^^^^^^^^^^^^^^^^
403-
.. autofunction:: obj_box_left_right_flip
401+
.. autofunction:: obj_box_horizontal_flip
404402

405403
Image Aug - Resize
406404
^^^^^^^^^^^^^^^^^^^^^^^^^

docs/modules/visualize.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ to visualize the model, activations etc. Here we provide more functions for data
1313
save_image
1414
save_images
1515
draw_boxes_and_labels_to_image
16-
draw_mpii_people_to_image
16+
draw_mpii_pose_to_image
1717
draw_weights
1818
CNN2d
1919
frame
@@ -47,7 +47,7 @@ Save image for object detection
4747

4848
Save image for pose estimation (MPII)
4949
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
50-
.. autofunction:: draw_mpii_people_to_image
50+
.. autofunction:: draw_mpii_pose_to_image
5151

5252
Visualize model parameters
5353
------------------------------

tensorlayer/prepro.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2277,7 +2277,7 @@ def parse_darknet_ann_list_to_cls_box(annotations):
22772277
return class_list, bbox_list
22782278

22792279

2280-
def obj_box_left_right_flip(im, coords=None, is_rescale=False, is_center=False, is_random=False):
2280+
def obj_box_horizontal_flip(im, coords=None, is_rescale=False, is_center=False, is_random=False):
22812281
"""Left-right flip the image and coordinates for object detection.
22822282
22832283
Parameters
@@ -2354,6 +2354,8 @@ def _flip(im, coords):
23542354
return _flip(im, coords)
23552355

23562356

2357+
obj_box_left_right_flip = obj_box_horizontal_flip
2358+
23572359
# im = np.zeros([80, 100]) # as an image with shape width=100, height=80
23582360
# im, coords = obj_box_left_right_flip(im, coords=[[0.2, 0.4, 0.3, 0.3], [0.1, 0.5, 0.2, 0.3]], is_rescale=True, is_center=True, is_random=False)
23592361
# logging.info(coords)

tensorlayer/visualize.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def draw_boxes_and_labels_to_image(image, classes, coords, scores, classes_list,
222222
return image
223223

224224

225-
def draw_mpii_people_to_image(image, peoples, save_name='image.png'):
225+
def draw_mpii_pose_to_image(image, poses, save_name='image.png'):
226226
"""Draw people(s) into image using MPII dataset format as input, return or save the result image.
227227
228228
This is an experimental API, can be changed in the future.
@@ -231,7 +231,7 @@ def draw_mpii_people_to_image(image, peoples, save_name='image.png'):
231231
-----------
232232
image : numpy.array
233233
The RGB image [height, width, channel].
234-
people : list of dict
234+
poses : list of dict
235235
The people(s) annotation in MPII format, see ``tl.files.load_mpii_pose_dataset``.
236236
save_name : None or str
237237
The name of image file (i.e. image.png), if None, not to save image.
@@ -267,7 +267,7 @@ def draw_mpii_people_to_image(image, peoples, save_name='image.png'):
267267
if image.max() < 1:
268268
image = image * 255
269269

270-
for people in peoples:
270+
for people in poses:
271271
### Pose Keyponts
272272
joint_pos = people['joint_pos']
273273
# draw sketch
@@ -340,6 +340,9 @@ def draw_mpii_people_to_image(image, peoples, save_name='image.png'):
340340
return image
341341

342342

343+
draw_mpii_people_to_image = draw_mpii_pose_to_image
344+
345+
343346
def frame(I=None, second=5, saveable=True, name='frame', cmap=None, fig_idx=12836):
344347
"""Display a frame(image). Make sure OpenAI Gym render() is disable before using it.
345348

0 commit comments

Comments
 (0)