MCPcopy Index your code
hub / github.com/tensorlayer/TensorLayer / save_joints

Function save_joints

tensorlayer/files/utils.py:1754–1833  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1752 img_test_list = []
1753
1754 def save_joints():
1755 # joint_data_fn = os.path.join(path, 'data.json')
1756 # fp = open(joint_data_fn, 'w')
1757 mat = sio.loadmat(os.path.join(path, extracted_filename, "mpii_human_pose_v1_u12_1.mat"))
1758
1759 for _, (anno, train_flag) in enumerate( # all images
1760 zip(mat['RELEASE']['annolist'][0, 0][0], mat['RELEASE']['img_train'][0, 0][0])):
1761
1762 img_fn = anno['image']['name'][0, 0][0]
1763 train_flag = int(train_flag)
1764
1765 # print(i, img_fn, train_flag) # DEBUG print all images
1766
1767 if train_flag:
1768 img_train_list.append(img_fn)
1769 ann_train_list.append([])
1770 else:
1771 img_test_list.append(img_fn)
1772 ann_test_list.append([])
1773
1774 head_rect = []
1775 if 'x1' in str(anno['annorect'].dtype):
1776 head_rect = zip(
1777 [x1[0, 0] for x1 in anno['annorect']['x1'][0]], [y1[0, 0] for y1 in anno['annorect']['y1'][0]],
1778 [x2[0, 0] for x2 in anno['annorect']['x2'][0]], [y2[0, 0] for y2 in anno['annorect']['y2'][0]]
1779 )
1780 else:
1781 head_rect = [] # TODO
1782
1783 if 'annopoints' in str(anno['annorect'].dtype):
1784 annopoints = anno['annorect']['annopoints'][0]
1785 head_x1s = anno['annorect']['x1'][0]
1786 head_y1s = anno['annorect']['y1'][0]
1787 head_x2s = anno['annorect']['x2'][0]
1788 head_y2s = anno['annorect']['y2'][0]
1789
1790 for annopoint, head_x1, head_y1, head_x2, head_y2 in zip(annopoints, head_x1s, head_y1s, head_x2s,
1791 head_y2s):
1792 # if annopoint != []:
1793 # if len(annopoint) != 0:
1794 if annopoint.size:
1795 head_rect = [
1796 float(head_x1[0, 0]),
1797 float(head_y1[0, 0]),
1798 float(head_x2[0, 0]),
1799 float(head_y2[0, 0])
1800 ]
1801
1802 # joint coordinates
1803 annopoint = annopoint['point'][0, 0]
1804 j_id = [str(j_i[0, 0]) for j_i in annopoint['id'][0]]
1805 x = [x[0, 0] for x in annopoint['x'][0]]
1806 y = [y[0, 0] for y in annopoint['y'][0]]
1807 joint_pos = {}
1808 for _j_id, (_x, _y) in zip(j_id, zip(x, y)):
1809 joint_pos[int(_j_id)] = [float(_x), float(_y)]
1810 # joint_pos = fix_wrong_joints(joint_pos)
1811

Callers 1

load_mpii_pose_datasetFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…