add audio2mesh_ar
This commit is contained in:
1 parent
ded9b27f71
commit
e0f24982d1
46 files changed
+3917
-325
No files matched your search
+67
-20
@@ -486,42 +486,89 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 97,
|
||||
"execution_count": 112,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def interpolate_features(features, input_rate, output_rate, output_len=None):\n",
|
||||
" num_features = features.shape[1]\n",
|
||||
" input_len = features.shape[0]\n",
|
||||
" \n",
|
||||
" seq_len = input_len / float(input_rate)\n",
|
||||
" if output_len is None:\n",
|
||||
" output_len = int(seq_len * output_rate)\n",
|
||||
" \n",
|
||||
" input_timestamps = np.arange(input_len) / float(input_rate)\n",
|
||||
" output_timestamps = np.arange(output_len) / float(output_rate)\n",
|
||||
" output_features = np.zeros((output_len, num_features))\n",
|
||||
" \n",
|
||||
" for feat in range(num_features):\n",
|
||||
" output_features[:, feat] = np.interp(output_timestamps,\n",
|
||||
" input_timestamps,\n",
|
||||
" features[:, feat])\n",
|
||||
" return output_features\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"from scipy import interpolate\n",
|
||||
"def convert_fps(y, source_fps = 30, target_fps=25):\n",
|
||||
" \"\"\" \n",
|
||||
" y, (nframes x nc_feat) (with source_fps)\n",
|
||||
" \"\"\"\n",
|
||||
"\n",
|
||||
" nsteps = y.shape[0]\n",
|
||||
" x = np.arange(0, nsteps, 1)\n",
|
||||
" # print(\"x:\", x[::30], x[-10:])\n",
|
||||
" func = interpolate.interp1d(x, y=y, axis=0)\n",
|
||||
"\n",
|
||||
" x_new = np.arange(0, nsteps-1, 1.0*source_fps/target_fps)\n",
|
||||
" # print(\"x_new\", x_new[::30], x_new[-10:])\n",
|
||||
" y_new = func(x_new)\n",
|
||||
"\n",
|
||||
" if source_fps < target_fps:\n",
|
||||
" y_new = np.concatenate([y_new, y[-1:]])\n",
|
||||
"\n",
|
||||
" return y_new\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 119,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"{114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 65794, 65795, 65805, 65797, 65798, 65799, 65800, 65801, 65802, 65803, 65804, 65806, 65807, 65808, 65809, 65810, 65811, 65812, 65813, 65814, 65815, 65816, 65817, 65818, 65819, 65820, 65821, 65822, 65823, 65824, 65825, 65826, 65827, 65828, 65829, 65830, 65831, 65832, 65833, 65834, 65835, 65836, 65837, 65838, 65839, 65840, 65841, 65842, 65843, 65844, 65845, 65846, 65847, 65848, 65849, 65850, 65851, 65852, 65853, 65854, 65855, 65856, 65857, 65858, 65859, 65860, 65861, 65862, 65863, 65864, 65865, 65866, 65867, 65868, 65869, 65870, 65871, 65872, 65873, 65874, 65875, 65876, 65877, 65878, 65879, 65880, 65881, 65882, 65883, 65884, 65885, 65886, 65887, 65888, 65889, 65890, 65891, 65892, 65893, 65894, 65895, 65896, 65897, 65898, 65899, 65900, 65901, 65902, 65903, 65904, 65905, 65906, 65907, 65908, 65909, 65910, 65911, 65912, 65913, 65914, 65915, 65916, 65917, 65918, 65919, 65920, 65921, 65922, 65923, 65924, 65925, 65926, 65927, 65928, 65929, 65930, 65931, 65932, 65933, 65934, 65935, 65936, 65937, 65938, 65939, 65940, 65941, 65942, 65943, 65944, 65945, 65946, 65947, 65948, 65957, 65949, 65950, 65951, 65952, 65953, 65954, 65955, 65956, 65958, 65959, 65960, 66248, 66249, 66250, 66251, 66252, 66253, 66254, 66255, 66256, 66257, 66258, 66259, 66260, 66261, 66262, 66263, 66264, 66265, 66266, 66267, 66268, 66269, 66270, 66271, 66272, 66273, 66274, 66275, 66276, 66277, 66278, 66279, 66280, 66281, 66282, 66283, 66284, 66285, 66286, 66287, 66288, 66289, 66290, 66291, 66292, 66293, 66294, 66295, 66296, 66297, 66298, 66299, 66300, 66301, 66302, 66303, 66304, 66305, 66306, 66307, 66308, 66309, 66310, 66311, 66312, 66313, 66314, 66315, 66316, 66317, 66318, 66319, 66320, 66321, 66322, 66323, 66324, 66325, 66326, 66327, 66328, 66329, 66330, 66331, 66332, 66333, 66334, 66335, 66336, 66337, 66338, 66339, 66340, 66341, 66342, 66343, 66344, 66345, 66346, 66347, 66348, 66349, 66350, 66351, 66352, 66353, 66354, 66355, 66356, 66357, 66358, 66359, 66360, 66361, 66362, 66363, 66364, 66365, 66366, 66367, 66368, 66369, 66370, 66371, 66372, 66373, 66374, 66375, 66376, 66377, 66378, 66379, 66380, 66381, 66382, 66383, 66384, 66385, 66386, 66387, 66388, 66389, 66390, 66391, 66392, 66393, 66394, 66395, 66396, 66397, 66398, 66399, 66400, 26250, 26251, 26252, 26253, 26254, 26255, 26256, 26257, 26258, 26259, 26260, 26261, 26262, 26263, 26264, 26265, 26266, 26267, 26268, 66630, 66631, 66632, 66633, 66634, 66635, 66636, 66637, 66638, 66639, 66640, 66641, 66642, 66643, 66644, 66645, 66646, 66647, 66648, 66649, 66650, 66651, 66652, 66653, 66654, 66655, 66656, 66657, 66658, 66659, 66660, 66661, 66662, 66663, 66664, 66665, 66666, 66667, 66668, 66669, 66670, 66671, 66672, 66673, 66674, 66675, 66676, 66677, 66678, 66679, 66680, 66681, 66682, 66683, 66684, 66685, 66686, 66687, 66688, 66689, 66690, 66691, 66692, 66693, 66694, 66695, 66696, 66697, 66698, 66699, 66700, 66701, 66702, 66703, 66704, 66705, 66706, 66707, 66708, 66709, 66710, 66711, 66712, 66713, 66714, 66715, 66716, 66717, 66718, 66719, 66720, 66721, 66722, 66723, 66724, 66725, 66726, 66727, 66728, 66729, 66730, 66731, 66732, 66733, 66734, 66735, 66736, 66737, 66738, 66739, 66740, 66741, 66742, 66743, 66744, 66745, 66746, 66747, 66748, 66749, 66750, 66751, 66752, 66753, 66754, 66755, 66756, 66757, 66758, 66759, 66760, 66761, 66762, 66763, 66764, 66765, 66766, 66767, 66768, 66769, 66770, 66771, 66772, 66773, 66774, 66775, 66776, 66777, 66778, 66779, 66780, 66781, 66782, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1279, 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, 1366, 1367, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 138Line truncated
|
||||
"idx_filter len=24171/ total len=129700, percents = 18.636083269082498 %\n",
|
||||
"remain idx len=105529/ total len=129700, percents = 81.3639167309175 %\n"
|
||||
"(12800, 5023, 3)\n",
|
||||
"(7673, 5023, 3)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\n"
|
||||
"path_data1 = \"../experiments/audio2mesh/infer_audio2mesh_EN_20220208/20220303-14H18M22S/obama_train_infer_20220217-17H36M22S_epoch_115.npy\"\n",
|
||||
"path_data1_save = \"../experiments/audio2mesh/infer_audio2mesh_EN_20220208/20220303-14H18M22S/obama_train_infer_20220217-17H36M22S_epoch_115_29_97fps.npy\"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"data1 = np.load(path_data1)\n",
|
||||
"data1.shape\n",
|
||||
"\n",
|
||||
"data1 = data1.reshape(12800, 5023, 3)\n",
|
||||
"print(data1.shape)\n",
|
||||
"\n",
|
||||
"data2 = convert_fps(data1, source_fps=50, target_fps=29.97265625)\n",
|
||||
"print(data2.shape)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 45,
|
||||
"execution_count": 118,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"array([0.00266631, 0.00262837, 0.00337514, ..., 0.00482252, 0.00508082,\n",
|
||||
" 0.00521696], dtype=float32)"
|
||||
]
|
||||
},
|
||||
"execution_count": 45,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"data[:, 0] "
|
||||
"data2 = data2.reshape(1, 7673, 5023, 3)\n",
|
||||
"\n",
|
||||
"np.save(path_data1_save, data2)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user