From 97a3abc6543c847cd0e64541916250104ffef504 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Mon, 20 Sep 2021 09:42:34 -0400 Subject: [PATCH] enhanced automated test coverage --- CHANGELOG.md | 3 +- demo/facematch/faces.json | 4 +- package.json | 2 +- src/human.ts | 2 +- src/image/image.ts | 12 +++-- src/segmentation/segmentation.ts | 26 +++++------ test/test-main.js | 75 ++++++++++++++++++++++++++++++-- test/test-node-wasm.js | 2 +- test/test.js | 5 ++- 9 files changed, 102 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f649295..e6d3a256 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,9 @@ ## Changelog -### **HEAD -> main** 2021/09/18 mandic00@live.com +### **HEAD -> main** 2021/09/19 mandic00@live.com +- added configuration validation - prevent validation failed on some model combinations - webgl exception handling diff --git a/demo/facematch/faces.json b/demo/facematch/faces.json index de046d3d..3f0153ac 100644 --- a/demo/facematch/faces.json +++ b/demo/facematch/faces.json @@ -1,6 +1,6 @@ [ - {"name":"sample ai","source":"/samples/ai-face.jpg","embedding":[0.1232,0,0.0067,0.0198,0.0845,0.0875,0.4951,0,0,0,1.0145,0.3449,0.7097,1.1171,0.2059,0.7577,0.0785,0.0068,0.339,0.0051,0,0.5667,0.3367,0.9547,0,0,0.4303,0.0073,0.0789,0.9271,0.1529,0.3483,0.2102,0.4867,0.7644,0.1418,0,0.1495,0.9777,0.1739,0.1213,0.0069,0.04,0.396,1.0272,0,0.222,0.0415,0,0.0158,0.7524,0,0.4029,0.0236,0.8142,0.0878,0,0.2158,0,0,0,0.1887,0.1183,0,1.0864,0.3259,0,0.0629,0.1044,0.0412,0,0,0.0255,0.682,0.0641,1.1505,0.0438,0.031,0,0.0734,0.1236,0.9703,0,0.773,0.2065,0.3095,0.0161,0.2689,0.0052,0,0.0784,0.8499,0,0.8815,0,0,0.4367,0,0.5452,1.9337,0.0256,1.3663,0.3909,0.0749,0.3943,0.127,0.0319,0,0,0.0478,0,0.1323,0.2307,0.2001,0.2887,0.0352,0.3442,0.6434,0.2862,0,0,0.4045,0,0,0.0218,0,0.3484,0.0999,0.1921,0,0.2446,0,0.5872,0,0.0461,0.4727,0,0.1456,0.2456,0,0.555,0,0,0.1637,0.3174,0.0164,0.6562,0.2371,0,0.0451,0.1585,1.1707,0,0,0.6289,0,0.2976,0.0914,0,0.321,0.2409,0,0.0461,0,0.7502,0.1054,0,0.6575,0,1.2196,0.5556,0.6198,0,0.0049,0.5241,0.3105,0.0917,1.0896,0.3881,0,0.1909,0,1.3099,0.4001,0.9213,0.4734,0,0,0.0299,0,0.3392,0.1196,0.0175,0.0264,0.4004,0,0.2435,0.1789,0.0748,0.0376,0.8955,0.0042,0,0.0096,0.6747,0.0299,0,0.0641,0.4249,0.3807,0.0787,0.3487,0.0692,0.5218,0,0,0.9451,0.0165,0.1336,0.6064,0,0,0,0.2,0.3052,0.6205,0.0052,0,0.1563,0.1376,0.2529,0.0024,0,0,0,0.0356,0.2252,0.8726,0.0018,0.0023,0.8642,0.0375,0.2863,0.0826,0.1819,0,0.2113,0,0.0643,0.3732,0.5289,0.031,0.2561,0,0.3689,0,0.2594,1.2816,0,0.7563,0.7785,0.0252,0.0998,0.0575,0.0341,0.9232,0.0025,0.3996,0.6835,0,0.0109,0.4062,0.0521,0.0026,0,0.0322,0,0.0649,0,0,0.0523,0.0614,0,0.5244,0,0.306,0.2011,0,0.2563,0.2435,0.2991,0.1874,0.3121,0.7873,0.3175,0,0,0.2382,0.2946,0.2138,0.7619,0.0136,0,0.0546,0.1012,0.5906,0.4763,0.133,0.2623,0.0483,0.1419,0.1447,0,0.7862,0,0.4227,0.0352,0.0846,0.5083,0.2501,0,0.1535,0.1411,1.1401,0.0769,0.039,0,0.0191,0.1877,0.0585,0,0.0737,0,0.5423,0,0,0.274,0.0948,0.01,0.0032,0.0169,0,0.0074,0,0,0.5672,0.4112,0.0725,0.0549,0.0312,0,0.0203,0.6477,0,0.554,0.6807,0,0,0.0646,0,0.8765,0,0.0894,0,0.1006,0,0.0028,0.4271,0.2321,0,0.5871,1.2252,0.2147,0,1.1365,0.0027,0.0593,0,0.0148,0.7159,0,0.3951,0.6284,0.0238,0.0482,0.7847,0.3772,0.4747,0.0323,0.0036,0,0,0.2403,0.2206,0,0.1906,0,0.5917,0.5052,0,0.5083,0.3452,0.061,0.2724,0.5038,0,0.1775,0.8562,0.0003,0.1522,0.4456,0.0203,0.4387,0.0138,0.0178,0,0,0.111,0.1458,0,0.7519,0,0.0006,0.0045,0.8159,0.3804,0,0.0464,0.0954,0.2774,0.0128,0,0.3133,0,0,0,1.0064,0,0.4473,0,0.0198,0,0,0.3305,1.0207,0.8744,0.3664,0,0.7085,0.1148,0,0,0.2125,2.0086,0.0503,0.8763,0.0183,0.0169,0,0.7785,0.5294,0,0.3554,0.0028,0,0.3945,0.3227,0,0,0.4842,0,0.3307,0.075,0.1649,0.0099,0.8472,0.0118,0.9508,0.0287,0.4813,0.1394,0.1791,1.1116,0.052,0.576,0.022,0.0233,0.0162,0.0315,0.008,0.0803,0.2867,0.1974,0.0308,0,0.1392,0,0.0212,0,0,0.7451,0,0,0,0.1115,0.0534,0,0.079,0,0.3542,0,0,0.4928,0,0.1715,0.0531,0.1165,0.0415,1.7836,0,0,0.6996,0.0237,0.0282,0,0.3381,0,0,1.0686,0,0,0.6337,0.2821,0.6426,0.008,0.0031,0.2687,0.0063,0.0033,0.1806,0.1714,0,0.0354,0,0.2697,0.048,0.0394,0.4011,0.4401,0,0.3369,0,0.1785,0,0.2092,0.0776,0,0,0,0.3646,0,0,0,0,0.335,0.0732,0.041,0.664,0.159,0.0567,0.0664,0.0055,0.4999,0,0.0551,0.5779,0.0577,0.0187,0.0802,0.0911,0.0293,0,0.269,0.1465,0,0.5426,0.2235,0.006,0.1027,0.1726,0.1712,0.1234,0,0.3701,0.1596,0.3858,1.3867,0.0527,0.4665,0.1931,0.1315,0,0.2081,0.358,0.2276,0.0877,0.1719,0.0402,0.1926,0,0.0666,1.0669,0,0,1.327,0,0.2317,0,0.2234,0,0.14,0.0158,0.9595,0,0.0225,0.584,0,1.0107,0.5236,0.0593,0.0455,0.295,0.0183,0.0383,0,0.0756,0,0,0,0.0006,0.0549,0.3545,0.5742,0.1951,0.1728,0.5436,0.1703,0.4542,0,0.2062,1.3331,0.0258,0.0309,0.028,1.3694,0.8425,0.0587,0.0789,0.0693,0.4894,0.0913,0.4555,0.1454,0,0.0894,0.0025,0,0.0353,0,0.2568,0.0883,0,0,0.0636,1.4631,0.4569,0.1548,1.1196,0.1712,0.1088,0.6217,0.0799,0.0094,0.0087,1.06,0.0333,0.0206,0.3872,0.1297,0.219,0.0199,0,0.079,0,0.71,0.0619,0.0453,0.1972,0.1304,0.341,0.1694,0.1819,0.0041,0.8453,0.0809,0.781,0.2105,0.0128,0.8613,0.3314,0.4865,0.1617,0,0,0,0,0,0.0422,0,0,0.0549,0.5138,0.6911,0,0.1216,0.4698,0.4418,0.1725,0.6141,0.8057,1.098,0.2095,0.4863,0,0.8769,0.0761,0.3716,1.0523,0.4506,0.161,0.0163,0.5064,0,0.0503,0.7198,1.2274,1.9704,0.0332,0,0.1064,0,0.0961,0.208,0.0851,0.1571,0.139,0,0.2894,1.0112,1.196,0.0054,0.014,0.0179,0.1025,0,0,0,0.0042,0,1.3378,0.8352,0.0321,0,0,0.1758,0,0,0,0.2028,0.0062,0.1089,0.0743,0.8095,0.728,0,0.2977,0,0.1248,0,0.0818,0,0,0,0,0.5188,0.0567,0.0335,0,0.1582,0,0.1166,0.8837,0,0,0,0,0.1544,0.6083,0.2241,0.4519,0.9429,0.1645,0.2327,0.3576,0,0,0.0067,0.6996,0.0392,0.0217,0,0,0,0,0,1.1516,0,0.9789,0.0966,0.2598,1.3692,0,0.8535,0,0.1086,0.244,0.2732,0.0562,0.6065,0.4084,0.6495,0.3556,0.2461,0.5271,0.1125,0.0495,0.019,0,0.0165,0.1747,0.0448,0.6345,0.059,0.0928,0,0.036,0,0.0079,1.0454,0.0037,0.3119,0,0.0091,0.533,0,0.056,0.68,0.252,0.0116,0.1294,0,0.18,0.5371,0,0.092,0,0.0382,0.6656,0,0.0683,0.0077,0.3351,0.4723,0,0.0378,0.0307,0.5272,0.3074,0.1518,0.2458,0,0.7162,0.098,0.2511,0.0341,0.1999,0.3761,0.2089,0.1508,0,0,0.0287,0.7286,0.3315,0.9907,0.5994,0,0,0.0125,0.2273,0.0342,0.043,1.6058,0.1256,0.0032,0.1311,0.2422,0.5739,0.9659,0.1234,0,0,0.2218,0.0321,0.4684,0.3458,0.3533,0.0887,0.017,0.1735,0.2145,0,0.0596,0.2447,0.6419,0,1.0469,0.0212,0.0126,0.1069,0.9629,0.0248,0.1593,0.0002,0.2906,0,0,0.3113,0.686,0.1133,0.4475,0.3005,0.0153,0.6213,0,0.1014,0.2095,0,0,0.3902,0.8519,1.6587,0.4534,0.1347,0.0491,0.8076,0.1046,0.0308,0.2399,0.1184,1.0538,0.2909,0.1381,0.0366,0.7223,0.0033,0.0831,0,0,0,0.0323,0.2726,0.426,0.0054,0.0865,0.3789,0,0,0.0428,0.2061,0.2246,0.1496,0,0.0903,0.0364,0.2332,0,0.2954,0.0822,0.2169,0.0661,0,0.851,0.2137,0.4075,0,0.1645,0,0.1044,0,0,0.1143,0.3507,0,0.9408,0.5404,0,0.5454,0.014,0,0.009,0,0.5092,0]}, - {"name":"sample ai","source":"/assets/human-sample-upper.jpg","embedding":[0.0418,0,0.0075,0.6018,0,0.5454,0.6623,0,0.0079,0.045,1.0518,0.2292,0.3333,1.1736,0.1061,0.5161,0,0.0458,0.7855,0.0665,0.0091,0.6724,0.7904,0,0.1882,0.0453,0.7279,0.0205,0.2697,1.0447,1.2109,0.3526,0.3633,0,0.0816,0.0521,0.7363,0.3425,0.94,0.0247,0,0,0.3558,0.1845,1.2559,0,0.2069,0.2147,0,0.0521,0.4046,0,0.1458,0.0696,0.9321,0,0.3113,0,0.0211,0.1485,0,0.1167,0.4359,0.0316,0.1238,0.0284,0,0.011,0.0797,0.0286,0,0.0287,0.373,0.7456,0,0.3027,0.3605,0.1064,0.0184,0.1395,0,0.7769,0.0374,0.002,1.2215,0.2521,0,0.2148,0,0.0445,0.0851,0.3042,0.0377,0.6262,0.2836,0.163,0.637,0.0262,0.9336,1.5181,0.0767,0.7505,0.2964,0.1721,0.592,0.0735,0,0,0,0.1836,0.0168,0.2565,0,0.0196,0.0108,0.1568,0.3433,0,0.6033,0.0198,1.1622,0.3164,0.7968,0,0.099,0.3857,0.503,0,0.612,0.1272,0,0,0.6284,0,0.0329,0.1135,0,0.044,0.0867,0,0.5703,0.2013,0.0138,0,0.2335,0,0.3328,0.9021,0,0.3339,0.0852,1.1603,0,0.8079,1.0685,0.0054,0.1954,0.0283,0,0.0467,0.0936,0,0.1391,0,0.3792,0.1837,0.0242,0.0551,0,1.1769,0.1387,0.0285,0.0214,0.3451,0.3874,0.2578,0.1288,0.9794,0.3918,0.9239,0.2356,0,0.8922,0.0124,0.1622,0.4644,0.0055,0.6735,0.6984,0.1172,0,0.6142,0.2451,0.017,0.3198,0.136,0.8079,0.4069,0.0401,0,0.5723,0.1401,0.0859,0,0.3721,0.1158,0.1452,0.0296,0.6646,0.192,0.264,0.2495,0.0074,0.6793,0,0,0.9708,0.0116,0.143,0.096,0.0089,0,0,0.0263,0.4417,0.2595,0.0811,0.031,0.2131,0.0788,0.1222,0,0,0,0,0.9002,0.0893,0.7089,0.0166,0,0,0.6362,0.4967,0.0583,0.0018,0,0.0513,0,1.1015,0.831,0.0649,0,0.3981,0,0.9148,0,0.0929,1.5711,0.0282,0.8361,0.2036,0.0146,0.119,0.2971,0.0398,0.293,0.0115,0.0141,0,0,0,1.224,0.8074,0.7403,0,0.0053,0,0.2178,0,0,0.0241,0.0531,0,0.8846,0.0109,1.5731,0.1896,0.2504,0.0017,0,1.0819,0.0249,0.2171,0.8273,0.159,0,0.02,0.0086,0.5386,0.7299,1.1452,0.2377,0,0.2723,0.5199,1.4716,0.4039,0.11,0.1207,0.7023,0.1004,0.0461,0.262,0.1032,0,0.9283,0.1029,0.0144,0,0.1382,0,0.0913,0.0716,1.2993,0.8548,0.0847,0,0.4677,0,0,0,0.163,0.2593,0.1449,0.0159,0.1123,0,0.2982,0,0.0199,0,0,0,0,0.0412,0.5682,0.8792,0.1706,0.1664,0.0095,0,0.0702,0.7808,0.1518,0.5347,1.0775,0.0206,0,0.2921,0,0.7571,0,0.2254,0.9782,0.3306,0.3552,0,0.2917,0.396,0.288,0.1264,0.1901,0.7313,0.0404,1.1899,0.1925,0.3654,0.0368,0,0.7661,0.2258,0.5498,0.5322,0.3047,0,0.5226,0.0493,0.1469,0.8649,0,0,0.1611,0.3853,0.557,0.0216,0.6417,0,0.5621,0.4227,0.021,0.3302,0.0017,0.1249,0.3256,0.1794,0,0.0121,0.134,0.117,1.1586,1.068,0.0133,0.5231,0.0171,0.0774,0.0721,0,0.1401,0.1205,0,0.8531,0.0626,0,0,0.6907,0.0269,0,0.1687,0.0287,0,0,0.1964,0.5739,0.0552,0,0.1846,0.2587,0,0.6338,0.0276,0.0693,0,0.0972,0.9299,1.0222,0.2315,0.0241,0.0408,0.5103,0,0.0898,0.062,0.4078,1.6166,0,0.9688,0.2871,0.3079,0.1383,0.1831,0.1588,0,0.1655,0.1502,0.5924,0.0169,0.4218,0.0773,0,0.6191,0.111,0.2118,0,0.0567,0.073,0.7142,0.1967,0.2213,0.2567,0.2205,0.0892,0.3746,0.018,0.0098,0.2873,0.7299,0,0,0.5845,0.1578,0.0179,0.3469,0.5665,0,0.119,0,0,0.0341,0,0,0,0,0,0.067,0.3523,0,0.1351,0.6054,0,0.1063,0.0195,0.0156,0.8261,0,0.0764,0,0,0.1916,1.3688,0.0061,0.1344,0.6518,0,0.7028,0.0054,0.0226,0,0,0.3753,0,0.2805,0.8828,0.1765,0.4803,1.1388,0.1473,0.1323,0.0251,0.0063,0.3609,0,0,0.0451,0.0465,0.0678,0.6554,0.0779,1.5214,0,0,1.1221,0,0,0.1548,0.042,0.0837,0.4158,0,0.1569,0,0,0,0,0,0.3066,0.2838,0,0.2375,0,1.214,0.0192,0.7629,0.7148,0,0,0.444,0.0532,0.1005,0.1781,0.06,0.057,0.121,0.0006,0.0033,0.0163,0.9755,0.3192,0.0145,0,0,0.4531,0.4713,0,0.0821,0.0366,0.0514,0.2337,0.01,0.1251,0,0.0947,0.5961,0.1115,0,0.9395,0,0,0.3166,0,0,0.4309,0.5704,0.1265,0,1.6836,0,0.0849,0,0,0,0.6469,0,1.2293,0,0.3255,0.9763,0.3478,0.9181,0.7594,0,0.0268,0.0091,0,0.0074,0.0568,0,0.1474,0,0,0.1406,0,0.6573,0.4791,0.8472,0.2531,0.0609,0.0403,0.3974,0.2559,0.0194,0.8766,0.102,0,0.0044,1.9812,1.1258,0.0616,0,1.0604,0.2785,0.0163,0.2186,0.1881,0,0.3477,0,0,0,0.0424,0.0973,0.0673,0,0.0392,0.353,1.208,0.3138,0.0121,0.226,0.1924,0.1133,0.3758,0.2259,0.0323,0,0.4129,0.4589,0.2536,0.0956,0.1384,0.2736,0.2391,0.0599,0.3228,0.2917,0.0597,0.2112,0.5118,0.6282,0.5638,0.0579,0.1038,0,0.4234,0.8339,0.0106,0.2447,0.4461,0.1293,0.2948,0.412,1.1189,0.6185,0.0781,0,0.0307,0,0.0616,0,0.0672,0,0.1262,0.1627,0.5216,0.013,1.3841,0.4802,0.0345,0.004,0.0654,0.264,0.3382,0.2803,0.3032,0,0.7716,0.0256,1.826,0.4813,0.8102,0.5102,0.6781,0.001,0,0,1.3655,1.0991,2.0032,0.6016,0,0.3383,0.0257,0.1327,0.7323,0.2627,0.3239,0,0.0533,0.5702,1.2228,1.2359,0,0,0.148,1.0803,0,0,0,0.0513,0,0.2974,0.5358,0,0.0118,0,0.0081,0.0271,0,0,0.3073,0,0.9204,0.0609,0,0.9168,0.1708,0.2127,0,0.5675,0.6731,0.0384,0.1874,0,0,0,0.3865,0.0983,0.5258,0.3812,0.0531,0,0.0501,0.3409,0,0,0,0,0,0.8978,0,0.3281,1.0533,1.3875,0.1639,0.4686,0.0706,0,0,0.088,0,0,0,0.0386,0.0286,0.0081,0,1.038,0,0.2606,0.3755,0,1.1312,0.2099,0.3215,0,0.1935,0.635,1.1675,0.0264,0.451,0.4965,0.3784,0.4202,0.0636,0.2997,0.0521,0.0431,0,0,0,0.4933,0.0614,0.8659,0.0086,0.5909,0,0.0282,0,0.7378,1.2317,0,0.2558,0,0.1542,1.0283,0,0.0362,0.8276,0.5798,0.0732,0,0.0618,0.6329,0.4209,0,0.0198,0.2755,0.1428,0.4897,0,0,0,0.2895,1.1246,0.0967,0.2449,0.06,0.0761,0.3715,0,0,0.2409,0.8595,0,0.214,0.0201,0.4205,0.3541,0,0.0553,0,0.223,0.1135,0.799,0.703,0.4238,0.5715,0,0.0141,0.0102,0.6389,0.0918,0.205,1.4504,0,0.0186,0.1578,0.329,0.4732,0.1929,0.901,0,0,0.4346,0.0413,0.003,0,0.8283,1.1398,0.4381,0.1928,0.3487,0,0,0.573,0.2299,0,0.6056,0.093,0,0.3394,0.4664,0,0.4005,0.762,0.2199,0,0,0.3051,0.6654,0,0,0.0452,0.5967,0.7311,0,0.1532,0,0.001,0.048,1.0351,0.5673,1,0.1138,0.1257,0,0.0661,0.3799,0.5711,0.0038,0.4196,0.9754,0.0082,0,0.1282,0.5481,0.1465,0.535,0,0,0.2846,0,0.003,0.2338,0,0.6401,0,0.1257,0,0.0867,0.3942,0.002,0.0012,0.2059,0,1.0926,0.2825,0,0,0.0509,0.2412,0.1364,0,0.4856,0,1.4203,0,0.396,0,0,0,0.0143,0.0472,0.5021,0.0315,0.2756,0.4384,0,0.035,0.8925,0.1531,0,0,0.4004,0.0604]}, + {"name":"ai face","source":"/samples/ai-face.jpg","embedding":[0.1232,0,0.0067,0.0198,0.0845,0.0875,0.4951,0,0,0,1.0145,0.3449,0.7097,1.1171,0.2059,0.7577,0.0785,0.0068,0.339,0.0051,0,0.5667,0.3367,0.9547,0,0,0.4303,0.0073,0.0789,0.9271,0.1529,0.3483,0.2102,0.4867,0.7644,0.1418,0,0.1495,0.9777,0.1739,0.1213,0.0069,0.04,0.396,1.0272,0,0.222,0.0415,0,0.0158,0.7524,0,0.4029,0.0236,0.8142,0.0878,0,0.2158,0,0,0,0.1887,0.1183,0,1.0864,0.3259,0,0.0629,0.1044,0.0412,0,0,0.0255,0.682,0.0641,1.1505,0.0438,0.031,0,0.0734,0.1236,0.9703,0,0.773,0.2065,0.3095,0.0161,0.2689,0.0052,0,0.0784,0.8499,0,0.8815,0,0,0.4367,0,0.5452,1.9337,0.0256,1.3663,0.3909,0.0749,0.3943,0.127,0.0319,0,0,0.0478,0,0.1323,0.2307,0.2001,0.2887,0.0352,0.3442,0.6434,0.2862,0,0,0.4045,0,0,0.0218,0,0.3484,0.0999,0.1921,0,0.2446,0,0.5872,0,0.0461,0.4727,0,0.1456,0.2456,0,0.555,0,0,0.1637,0.3174,0.0164,0.6562,0.2371,0,0.0451,0.1585,1.1707,0,0,0.6289,0,0.2976,0.0914,0,0.321,0.2409,0,0.0461,0,0.7502,0.1054,0,0.6575,0,1.2196,0.5556,0.6198,0,0.0049,0.5241,0.3105,0.0917,1.0896,0.3881,0,0.1909,0,1.3099,0.4001,0.9213,0.4734,0,0,0.0299,0,0.3392,0.1196,0.0175,0.0264,0.4004,0,0.2435,0.1789,0.0748,0.0376,0.8955,0.0042,0,0.0096,0.6747,0.0299,0,0.0641,0.4249,0.3807,0.0787,0.3487,0.0692,0.5218,0,0,0.9451,0.0165,0.1336,0.6064,0,0,0,0.2,0.3052,0.6205,0.0052,0,0.1563,0.1376,0.2529,0.0024,0,0,0,0.0356,0.2252,0.8726,0.0018,0.0023,0.8642,0.0375,0.2863,0.0826,0.1819,0,0.2113,0,0.0643,0.3732,0.5289,0.031,0.2561,0,0.3689,0,0.2594,1.2816,0,0.7563,0.7785,0.0252,0.0998,0.0575,0.0341,0.9232,0.0025,0.3996,0.6835,0,0.0109,0.4062,0.0521,0.0026,0,0.0322,0,0.0649,0,0,0.0523,0.0614,0,0.5244,0,0.306,0.2011,0,0.2563,0.2435,0.2991,0.1874,0.3121,0.7873,0.3175,0,0,0.2382,0.2946,0.2138,0.7619,0.0136,0,0.0546,0.1012,0.5906,0.4763,0.133,0.2623,0.0483,0.1419,0.1447,0,0.7862,0,0.4227,0.0352,0.0846,0.5083,0.2501,0,0.1535,0.1411,1.1401,0.0769,0.039,0,0.0191,0.1877,0.0585,0,0.0737,0,0.5423,0,0,0.274,0.0948,0.01,0.0032,0.0169,0,0.0074,0,0,0.5672,0.4112,0.0725,0.0549,0.0312,0,0.0203,0.6477,0,0.554,0.6807,0,0,0.0646,0,0.8765,0,0.0894,0,0.1006,0,0.0028,0.4271,0.2321,0,0.5871,1.2252,0.2147,0,1.1365,0.0027,0.0593,0,0.0148,0.7159,0,0.3951,0.6284,0.0238,0.0482,0.7847,0.3772,0.4747,0.0323,0.0036,0,0,0.2403,0.2206,0,0.1906,0,0.5917,0.5052,0,0.5083,0.3452,0.061,0.2724,0.5038,0,0.1775,0.8562,0.0003,0.1522,0.4456,0.0203,0.4387,0.0138,0.0178,0,0,0.111,0.1458,0,0.7519,0,0.0006,0.0045,0.8159,0.3804,0,0.0464,0.0954,0.2774,0.0128,0,0.3133,0,0,0,1.0064,0,0.4473,0,0.0198,0,0,0.3305,1.0207,0.8744,0.3664,0,0.7085,0.1148,0,0,0.2125,2.0086,0.0503,0.8763,0.0183,0.0169,0,0.7785,0.5294,0,0.3554,0.0028,0,0.3945,0.3227,0,0,0.4842,0,0.3307,0.075,0.1649,0.0099,0.8472,0.0118,0.9508,0.0287,0.4813,0.1394,0.1791,1.1116,0.052,0.576,0.022,0.0233,0.0162,0.0315,0.008,0.0803,0.2867,0.1974,0.0308,0,0.1392,0,0.0212,0,0,0.7451,0,0,0,0.1115,0.0534,0,0.079,0,0.3542,0,0,0.4928,0,0.1715,0.0531,0.1165,0.0415,1.7836,0,0,0.6996,0.0237,0.0282,0,0.3381,0,0,1.0686,0,0,0.6337,0.2821,0.6426,0.008,0.0031,0.2687,0.0063,0.0033,0.1806,0.1714,0,0.0354,0,0.2697,0.048,0.0394,0.4011,0.4401,0,0.3369,0,0.1785,0,0.2092,0.0776,0,0,0,0.3646,0,0,0,0,0.335,0.0732,0.041,0.664,0.159,0.0567,0.0664,0.0055,0.4999,0,0.0551,0.5779,0.0577,0.0187,0.0802,0.0911,0.0293,0,0.269,0.1465,0,0.5426,0.2235,0.006,0.1027,0.1726,0.1712,0.1234,0,0.3701,0.1596,0.3858,1.3867,0.0527,0.4665,0.1931,0.1315,0,0.2081,0.358,0.2276,0.0877,0.1719,0.0402,0.1926,0,0.0666,1.0669,0,0,1.327,0,0.2317,0,0.2234,0,0.14,0.0158,0.9595,0,0.0225,0.584,0,1.0107,0.5236,0.0593,0.0455,0.295,0.0183,0.0383,0,0.0756,0,0,0,0.0006,0.0549,0.3545,0.5742,0.1951,0.1728,0.5436,0.1703,0.4542,0,0.2062,1.3331,0.0258,0.0309,0.028,1.3694,0.8425,0.0587,0.0789,0.0693,0.4894,0.0913,0.4555,0.1454,0,0.0894,0.0025,0,0.0353,0,0.2568,0.0883,0,0,0.0636,1.4631,0.4569,0.1548,1.1196,0.1712,0.1088,0.6217,0.0799,0.0094,0.0087,1.06,0.0333,0.0206,0.3872,0.1297,0.219,0.0199,0,0.079,0,0.71,0.0619,0.0453,0.1972,0.1304,0.341,0.1694,0.1819,0.0041,0.8453,0.0809,0.781,0.2105,0.0128,0.8613,0.3314,0.4865,0.1617,0,0,0,0,0,0.0422,0,0,0.0549,0.5138,0.6911,0,0.1216,0.4698,0.4418,0.1725,0.6141,0.8057,1.098,0.2095,0.4863,0,0.8769,0.0761,0.3716,1.0523,0.4506,0.161,0.0163,0.5064,0,0.0503,0.7198,1.2274,1.9704,0.0332,0,0.1064,0,0.0961,0.208,0.0851,0.1571,0.139,0,0.2894,1.0112,1.196,0.0054,0.014,0.0179,0.1025,0,0,0,0.0042,0,1.3378,0.8352,0.0321,0,0,0.1758,0,0,0,0.2028,0.0062,0.1089,0.0743,0.8095,0.728,0,0.2977,0,0.1248,0,0.0818,0,0,0,0,0.5188,0.0567,0.0335,0,0.1582,0,0.1166,0.8837,0,0,0,0,0.1544,0.6083,0.2241,0.4519,0.9429,0.1645,0.2327,0.3576,0,0,0.0067,0.6996,0.0392,0.0217,0,0,0,0,0,1.1516,0,0.9789,0.0966,0.2598,1.3692,0,0.8535,0,0.1086,0.244,0.2732,0.0562,0.6065,0.4084,0.6495,0.3556,0.2461,0.5271,0.1125,0.0495,0.019,0,0.0165,0.1747,0.0448,0.6345,0.059,0.0928,0,0.036,0,0.0079,1.0454,0.0037,0.3119,0,0.0091,0.533,0,0.056,0.68,0.252,0.0116,0.1294,0,0.18,0.5371,0,0.092,0,0.0382,0.6656,0,0.0683,0.0077,0.3351,0.4723,0,0.0378,0.0307,0.5272,0.3074,0.1518,0.2458,0,0.7162,0.098,0.2511,0.0341,0.1999,0.3761,0.2089,0.1508,0,0,0.0287,0.7286,0.3315,0.9907,0.5994,0,0,0.0125,0.2273,0.0342,0.043,1.6058,0.1256,0.0032,0.1311,0.2422,0.5739,0.9659,0.1234,0,0,0.2218,0.0321,0.4684,0.3458,0.3533,0.0887,0.017,0.1735,0.2145,0,0.0596,0.2447,0.6419,0,1.0469,0.0212,0.0126,0.1069,0.9629,0.0248,0.1593,0.0002,0.2906,0,0,0.3113,0.686,0.1133,0.4475,0.3005,0.0153,0.6213,0,0.1014,0.2095,0,0,0.3902,0.8519,1.6587,0.4534,0.1347,0.0491,0.8076,0.1046,0.0308,0.2399,0.1184,1.0538,0.2909,0.1381,0.0366,0.7223,0.0033,0.0831,0,0,0,0.0323,0.2726,0.426,0.0054,0.0865,0.3789,0,0,0.0428,0.2061,0.2246,0.1496,0,0.0903,0.0364,0.2332,0,0.2954,0.0822,0.2169,0.0661,0,0.851,0.2137,0.4075,0,0.1645,0,0.1044,0,0,0.1143,0.3507,0,0.9408,0.5404,0,0.5454,0.014,0,0.009,0,0.5092,0]}, + {"name":"ai upper","source":"/assets/human-sample-upper.jpg","embedding":[0.0418,0,0.0075,0.6018,0,0.5454,0.6623,0,0.0079,0.045,1.0518,0.2292,0.3333,1.1736,0.1061,0.5161,0,0.0458,0.7855,0.0665,0.0091,0.6724,0.7904,0,0.1882,0.0453,0.7279,0.0205,0.2697,1.0447,1.2109,0.3526,0.3633,0,0.0816,0.0521,0.7363,0.3425,0.94,0.0247,0,0,0.3558,0.1845,1.2559,0,0.2069,0.2147,0,0.0521,0.4046,0,0.1458,0.0696,0.9321,0,0.3113,0,0.0211,0.1485,0,0.1167,0.4359,0.0316,0.1238,0.0284,0,0.011,0.0797,0.0286,0,0.0287,0.373,0.7456,0,0.3027,0.3605,0.1064,0.0184,0.1395,0,0.7769,0.0374,0.002,1.2215,0.2521,0,0.2148,0,0.0445,0.0851,0.3042,0.0377,0.6262,0.2836,0.163,0.637,0.0262,0.9336,1.5181,0.0767,0.7505,0.2964,0.1721,0.592,0.0735,0,0,0,0.1836,0.0168,0.2565,0,0.0196,0.0108,0.1568,0.3433,0,0.6033,0.0198,1.1622,0.3164,0.7968,0,0.099,0.3857,0.503,0,0.612,0.1272,0,0,0.6284,0,0.0329,0.1135,0,0.044,0.0867,0,0.5703,0.2013,0.0138,0,0.2335,0,0.3328,0.9021,0,0.3339,0.0852,1.1603,0,0.8079,1.0685,0.0054,0.1954,0.0283,0,0.0467,0.0936,0,0.1391,0,0.3792,0.1837,0.0242,0.0551,0,1.1769,0.1387,0.0285,0.0214,0.3451,0.3874,0.2578,0.1288,0.9794,0.3918,0.9239,0.2356,0,0.8922,0.0124,0.1622,0.4644,0.0055,0.6735,0.6984,0.1172,0,0.6142,0.2451,0.017,0.3198,0.136,0.8079,0.4069,0.0401,0,0.5723,0.1401,0.0859,0,0.3721,0.1158,0.1452,0.0296,0.6646,0.192,0.264,0.2495,0.0074,0.6793,0,0,0.9708,0.0116,0.143,0.096,0.0089,0,0,0.0263,0.4417,0.2595,0.0811,0.031,0.2131,0.0788,0.1222,0,0,0,0,0.9002,0.0893,0.7089,0.0166,0,0,0.6362,0.4967,0.0583,0.0018,0,0.0513,0,1.1015,0.831,0.0649,0,0.3981,0,0.9148,0,0.0929,1.5711,0.0282,0.8361,0.2036,0.0146,0.119,0.2971,0.0398,0.293,0.0115,0.0141,0,0,0,1.224,0.8074,0.7403,0,0.0053,0,0.2178,0,0,0.0241,0.0531,0,0.8846,0.0109,1.5731,0.1896,0.2504,0.0017,0,1.0819,0.0249,0.2171,0.8273,0.159,0,0.02,0.0086,0.5386,0.7299,1.1452,0.2377,0,0.2723,0.5199,1.4716,0.4039,0.11,0.1207,0.7023,0.1004,0.0461,0.262,0.1032,0,0.9283,0.1029,0.0144,0,0.1382,0,0.0913,0.0716,1.2993,0.8548,0.0847,0,0.4677,0,0,0,0.163,0.2593,0.1449,0.0159,0.1123,0,0.2982,0,0.0199,0,0,0,0,0.0412,0.5682,0.8792,0.1706,0.1664,0.0095,0,0.0702,0.7808,0.1518,0.5347,1.0775,0.0206,0,0.2921,0,0.7571,0,0.2254,0.9782,0.3306,0.3552,0,0.2917,0.396,0.288,0.1264,0.1901,0.7313,0.0404,1.1899,0.1925,0.3654,0.0368,0,0.7661,0.2258,0.5498,0.5322,0.3047,0,0.5226,0.0493,0.1469,0.8649,0,0,0.1611,0.3853,0.557,0.0216,0.6417,0,0.5621,0.4227,0.021,0.3302,0.0017,0.1249,0.3256,0.1794,0,0.0121,0.134,0.117,1.1586,1.068,0.0133,0.5231,0.0171,0.0774,0.0721,0,0.1401,0.1205,0,0.8531,0.0626,0,0,0.6907,0.0269,0,0.1687,0.0287,0,0,0.1964,0.5739,0.0552,0,0.1846,0.2587,0,0.6338,0.0276,0.0693,0,0.0972,0.9299,1.0222,0.2315,0.0241,0.0408,0.5103,0,0.0898,0.062,0.4078,1.6166,0,0.9688,0.2871,0.3079,0.1383,0.1831,0.1588,0,0.1655,0.1502,0.5924,0.0169,0.4218,0.0773,0,0.6191,0.111,0.2118,0,0.0567,0.073,0.7142,0.1967,0.2213,0.2567,0.2205,0.0892,0.3746,0.018,0.0098,0.2873,0.7299,0,0,0.5845,0.1578,0.0179,0.3469,0.5665,0,0.119,0,0,0.0341,0,0,0,0,0,0.067,0.3523,0,0.1351,0.6054,0,0.1063,0.0195,0.0156,0.8261,0,0.0764,0,0,0.1916,1.3688,0.0061,0.1344,0.6518,0,0.7028,0.0054,0.0226,0,0,0.3753,0,0.2805,0.8828,0.1765,0.4803,1.1388,0.1473,0.1323,0.0251,0.0063,0.3609,0,0,0.0451,0.0465,0.0678,0.6554,0.0779,1.5214,0,0,1.1221,0,0,0.1548,0.042,0.0837,0.4158,0,0.1569,0,0,0,0,0,0.3066,0.2838,0,0.2375,0,1.214,0.0192,0.7629,0.7148,0,0,0.444,0.0532,0.1005,0.1781,0.06,0.057,0.121,0.0006,0.0033,0.0163,0.9755,0.3192,0.0145,0,0,0.4531,0.4713,0,0.0821,0.0366,0.0514,0.2337,0.01,0.1251,0,0.0947,0.5961,0.1115,0,0.9395,0,0,0.3166,0,0,0.4309,0.5704,0.1265,0,1.6836,0,0.0849,0,0,0,0.6469,0,1.2293,0,0.3255,0.9763,0.3478,0.9181,0.7594,0,0.0268,0.0091,0,0.0074,0.0568,0,0.1474,0,0,0.1406,0,0.6573,0.4791,0.8472,0.2531,0.0609,0.0403,0.3974,0.2559,0.0194,0.8766,0.102,0,0.0044,1.9812,1.1258,0.0616,0,1.0604,0.2785,0.0163,0.2186,0.1881,0,0.3477,0,0,0,0.0424,0.0973,0.0673,0,0.0392,0.353,1.208,0.3138,0.0121,0.226,0.1924,0.1133,0.3758,0.2259,0.0323,0,0.4129,0.4589,0.2536,0.0956,0.1384,0.2736,0.2391,0.0599,0.3228,0.2917,0.0597,0.2112,0.5118,0.6282,0.5638,0.0579,0.1038,0,0.4234,0.8339,0.0106,0.2447,0.4461,0.1293,0.2948,0.412,1.1189,0.6185,0.0781,0,0.0307,0,0.0616,0,0.0672,0,0.1262,0.1627,0.5216,0.013,1.3841,0.4802,0.0345,0.004,0.0654,0.264,0.3382,0.2803,0.3032,0,0.7716,0.0256,1.826,0.4813,0.8102,0.5102,0.6781,0.001,0,0,1.3655,1.0991,2.0032,0.6016,0,0.3383,0.0257,0.1327,0.7323,0.2627,0.3239,0,0.0533,0.5702,1.2228,1.2359,0,0,0.148,1.0803,0,0,0,0.0513,0,0.2974,0.5358,0,0.0118,0,0.0081,0.0271,0,0,0.3073,0,0.9204,0.0609,0,0.9168,0.1708,0.2127,0,0.5675,0.6731,0.0384,0.1874,0,0,0,0.3865,0.0983,0.5258,0.3812,0.0531,0,0.0501,0.3409,0,0,0,0,0,0.8978,0,0.3281,1.0533,1.3875,0.1639,0.4686,0.0706,0,0,0.088,0,0,0,0.0386,0.0286,0.0081,0,1.038,0,0.2606,0.3755,0,1.1312,0.2099,0.3215,0,0.1935,0.635,1.1675,0.0264,0.451,0.4965,0.3784,0.4202,0.0636,0.2997,0.0521,0.0431,0,0,0,0.4933,0.0614,0.8659,0.0086,0.5909,0,0.0282,0,0.7378,1.2317,0,0.2558,0,0.1542,1.0283,0,0.0362,0.8276,0.5798,0.0732,0,0.0618,0.6329,0.4209,0,0.0198,0.2755,0.1428,0.4897,0,0,0,0.2895,1.1246,0.0967,0.2449,0.06,0.0761,0.3715,0,0,0.2409,0.8595,0,0.214,0.0201,0.4205,0.3541,0,0.0553,0,0.223,0.1135,0.799,0.703,0.4238,0.5715,0,0.0141,0.0102,0.6389,0.0918,0.205,1.4504,0,0.0186,0.1578,0.329,0.4732,0.1929,0.901,0,0,0.4346,0.0413,0.003,0,0.8283,1.1398,0.4381,0.1928,0.3487,0,0,0.573,0.2299,0,0.6056,0.093,0,0.3394,0.4664,0,0.4005,0.762,0.2199,0,0,0.3051,0.6654,0,0,0.0452,0.5967,0.7311,0,0.1532,0,0.001,0.048,1.0351,0.5673,1,0.1138,0.1257,0,0.0661,0.3799,0.5711,0.0038,0.4196,0.9754,0.0082,0,0.1282,0.5481,0.1465,0.535,0,0,0.2846,0,0.003,0.2338,0,0.6401,0,0.1257,0,0.0867,0.3942,0.002,0.0012,0.2059,0,1.0926,0.2825,0,0,0.0509,0.2412,0.1364,0,0.4856,0,1.4203,0,0.396,0,0,0,0.0143,0.0472,0.5021,0.0315,0.2756,0.4384,0,0.035,0.8925,0.1531,0,0,0.4004,0.0604]}, {"name":"vlado","source":"/private/me/me (10).jpg","embedding":[0.455,0,0,0.0931,0,0.0399,0.3274,0.5365,1.2691,0.2401,0,0,0.0505,1.6733,0.0279,0.7667,0.0357,0.02,0,0,0,0,0.6241,0,0,0.2275,0.3596,0.6699,0.2811,0.1022,0.3623,1.4376,0,1.88,0.5612,0.0525,0.0844,0,0.0144,0,0,0.1265,0.1981,0,0,0,0,0.1272,0.0632,0.9906,0.1008,0,0.8085,1.3667,0.1423,0.2263,0.5865,0.9136,0.0308,0.0254,1.267,0.1186,0.067,0.1985,0.2141,0,0.0239,0,0.003,0.6623,1.3433,1.1957,0.1652,0,0,0.0017,1.3538,0.0242,0.0264,0,0,0.2496,0,0,0.0717,0,0.1043,0.268,0,1.1607,0.0125,0,0.2408,0.818,0.0633,0,0.0791,0.2402,1.1437,0.0861,0,1.56,0.0145,0,0.579,0,0.3362,0.0065,0.0656,0.5799,0.0048,0,0.2186,0,0.2458,0.0033,0.4707,0,0.0417,0.4356,0.2969,0.8756,0.7765,1.4471,0.3919,0.0129,0.995,0,0,0.3044,0,0.4376,0.1407,0,0.669,0.0578,0,0,0,0.0005,0.0235,0.0515,0.095,0.8966,0.0212,1.0887,0,0.8837,0.0153,0,0,0.2183,0,0,1.1183,0,0,0.3173,0,0,0.0143,0,0.4285,0,0.2455,0.3936,0,0.3703,0,0.0292,0.1868,0,0.0248,0.9135,0,0.2146,0.4596,0.3417,0.1181,0.0903,0,0.6513,0.296,1.1603,0.26,0.2064,0,0.8945,0.0788,0.1498,0,2.0299,0.0537,0,1.7853,0,0.058,0.0613,0.5624,0.0279,0,0,0,0.5017,0.1595,1.0133,0.6654,0.6869,0.9146,0.1626,0.0762,0.0731,0.1093,0.4599,0,0.3941,0.0178,0.0855,1.1356,0.0125,0.2345,0,0.0358,0,0.2525,0.0967,0.604,0.3094,0.369,0.6858,0,0.1094,0,0.2917,0.0456,0.4897,0.1136,0.3169,0.1975,0,0.6087,0,0.0121,0.1513,0.0142,0.1049,0,0,0.5454,0.5776,0.218,0,0,0,0.0735,0.0907,0.7229,0.6814,0.3519,0.4123,0.0054,0.5209,0.1246,0.0422,0.4078,0,0.2343,0,0,0.3069,0,0,0.6745,0,0.2384,0.6892,0,0,0.9483,0.6687,0.7269,0,0,0.0008,0.0134,1.2916,0.3646,0,0,0.0098,1.3571,0.8973,0,0.1983,0.061,0.3598,0.5887,0.4014,0.0349,0.0899,0.6801,0,0.1277,0.0002,1.3881,0.8472,1.1111,0.0015,0,0.4564,0.1983,0,0,0.3447,0,0,0.4239,0.6237,0.0162,0.0448,0.0869,0,0,0,0,1.0586,0,0,0.6869,0.8213,0,0,0.8749,0,0.5186,0.0162,0,0,0,0.0236,0.0496,0,0.2057,0.2763,0,1.2287,0,0.6946,0.9016,0.3079,0.2111,0.0383,0,0.9625,0.6642,1.1574,0,0.0158,0,0.7267,0,0.0047,0,1.1282,0.2532,0.7829,0.0777,0.6075,0.4579,0.2679,0.0204,0.3137,0,0.4506,1.5154,0.835,0.5072,0.4026,0.0892,0.1157,0,0,1.0628,0.2837,0.2495,1.0632,0.034,0.2443,0.9619,0.8549,0,0.0347,0.0468,1.1878,0.3054,0.042,0.0739,0.3077,0.5493,0,0,0.3006,0.1114,0.2979,0.0038,0,0.1098,0,0.0469,0.7594,0.3215,0.3934,0.9636,1.0896,0.0173,0,0,0,0.6717,0.9488,0.0494,0.4862,0.0505,0.2692,0.1316,0.5335,0,0.9822,0.981,0,0,0.0588,0.0269,0.2294,0.468,0.1832,0.0111,0.8852,0.6201,0.4007,0.0702,0,0.2652,0,1.7103,0,0,0.1406,0.0439,0,0.1251,0.1074,0.0582,0.8744,0.0018,0.0022,0.2546,1.858,1.0366,0,0,0.6882,0.0115,1.5567,0.0097,0,0.9629,0.0087,0.2686,0.0896,0.2263,1.0871,0.1876,0,0.2554,0.1655,0.0498,0.0404,0,0.0154,0,0.1946,0,0.0047,0.0122,0.4804,1.7244,0.0265,0.0578,0.1609,0,0.0477,0,0.7624,0,0,0.2846,0,0,0,0.7464,0.1954,0,1.2885,0.0011,0.8367,0.872,0.2612,0.2504,0.2463,0.0352,0.036,0.0166,0.0713,0.0263,0.017,0.0197,0.1537,0,0.7666,0.0746,0.2642,1.4006,0.4573,0.7003,0.2925,0,0.5209,0.0636,0.0313,0.4363,0.3668,0.1254,0.9085,1.0639,0,0,0,0.3845,0,0,0,0,0.1745,1.3316,0.1285,1.0453,0.1979,0,0.5996,1.1258,0,0.1204,0.0267,0.458,0,0.1592,1.1604,0,0.0346,0.2534,0,0.317,0.4017,0,0.6949,0.0492,0.4213,0,0.0305,0,1.2164,0.017,0.3843,0.1177,0.078,0.3394,0.1095,0.0956,0.4965,0,0.0547,0.3391,0.0176,0,1.7427,1.22,0.6558,0.6123,0.0335,1.2369,0.3319,0,0.0087,0,0,0,0,1.0594,0,0,0.4867,0,0,0.4255,0,1.0369,0,0.1446,0.9099,0.4825,0.0554,0.3655,0,0.0061,0.0307,0.1099,0,0,0,0.7989,0.0189,0.0139,0.1363,0.5755,0.0145,0.8923,0.0117,0.0003,0.4876,0,0.0405,0,0.1238,0.8355,0.1189,1.3903,0,0.0274,0,0.5297,1.0592,0.0676,0.2433,1.2116,0.7,0.072,0.6373,0,0,0.1834,0,0.0934,0,0.0242,0.0303,0.1498,0.0103,1.5799,0.414,0,0,0.1941,0,1.2931,0.285,0.0502,0,0.722,0,0.0726,0.0093,0.1611,0.2031,0.4733,1.0392,0,0,0.7431,0.9329,0.0216,0,0,0.4156,0,0.3016,1.8117,0.4578,0.0155,0,0.1965,0,0.4619,0.0074,0,0,1.4873,0.6204,0.3365,0.2369,0.0467,0,0.2357,1.8343,1.0051,0,0,0,0.0122,0.0397,0.0674,0.5857,0,0,0.4951,0.6032,0.0613,1.0268,0.2178,0,0.1914,0.2446,0,0.712,0.7943,0.8803,0.1292,0.1546,0.4756,0.204,0.0118,0.5587,0.3136,0.0113,0.2808,0.1605,0,0.562,0.1741,0.0786,0.5101,0.6371,0.0654,0,1.2674,0.6651,0.0576,0.1075,0.0025,0.0469,0.7567,0.0094,0.0825,0.0254,0.8258,0.4404,1.3501,0.0085,1.1433,0,0,0.0011,0.1295,1.1122,0.0443,0,0,0,0.1041,0.0561,0.392,0.3143,0,0.0611,1.0396,0.0555,0.0124,0,0.0276,0.0145,0.573,0.0446,0.0296,1.1501,0.0223,0,0,0,0.3099,0,0,0.4244,0.1243,0.6678,0.174,0,0.4637,0.9266,0.135,0,0.696,0,0,0,1.4319,0,0.2315,0.434,0.1744,0.1379,0.0099,0.0045,0.0892,0,0.0011,0,0,0.024,0.8935,0.0659,0,0.1232,0.682,0.6559,0.587,0.3642,0,0.2504,0.0344,0.3601,0,0.3634,0,0.2359,0,0.2466,0.4798,1.1948,0.2275,0.8481,0,0.0733,0.0218,0,0.4437,0,0,0.0709,0,1.1313,0.9783,0.3301,0.3288,0.4656,0,0.0768,0.0099,1.2024,1.3946,0.0318,1.4747,0,0,0.8406,0,0.0417,0.0058,1.2849,0.2114,0.0322,0.2147,0,0,1.0151,0.0152,0.106,0.0713,0,0.3323,0.6707,1.502,0.1196,1.0723,0.7325,0.1583,1.102,0,0.0975,0.2732,0,0.0315,0.0828,0.0154,0.0838,0.5027,1.0843,0.1605,0,0.4095,0.1911,1.6444,0,0.0687,0.1207,0,0.2317,0,0.0206,0,0.354,0.0083,0,0.0016,0.0486,0.7611,1.4935,0.8539,0.0036,0.0447,0.8938,0.0476,0.1176,0,0,0.0533,0.0117,0.6544,0.0197,0.7518,0.6565,0.129,0.0402,0,0.2305,0.4312,0,0.0067,0,0,0.0972,0.3136,0.4254,0.2538,0.4317,0,0,0,0.1388,0.5016,0.629,0,0.2404,0.6102,0.031,0,0,0,0,0,0.3361,0,0,0,0.1846,0.1421,0,0.1046,1.4505,0.0382,0.6455,1.3525,0.3856,0,0.0632,0.4487,0.8815,0.1761,0.0222,0.0651,1.0937,0,0.1768,0.0015,0.0254,0.1528,0.1832,0.0566,1.0029,0.8725,0.1045,0,0,0,0,1.4618,0.0125,0.0084,0,0,0.1069,0.1833,0,0,0,1.1689,0.271,0.1496,0,0,0,1.0816,0.9834,0.0346,0.2114,0.6592,0.033,0.1916,0,0.1119,0.6905,0.0225,0.0632,0,0]}, {"name":"vlado","source":"/private/onedrive/Ana/20191018_141344.jpg","embedding":[0,0.4763,0,0,0,0,0,0.2673,0.4449,0.1633,0,0.0029,0,0.1602,0.1198,0,0.0081,0.2419,0.349,0,0.5051,0,0,0,0.048,0,0,0.0019,0.0022,0.0212,0.2734,0,0.0984,0.189,0.0959,0.0221,0,0.6567,0,0,0.1004,0.1008,0,0,0,0,0.1644,0,0.2715,0.1878,0,0.0099,0.1603,0,0,0,0.0302,0,0,0.0108,0.3925,0.0551,0,0,0,0,0,0,0.7768,0,0.0648,0,0,0,0,0,0,0.0456,0,0,0,0,0.2634,0,0.0405,0,0,0.0078,0.0088,0,0,0,0,0,0,0,0.0579,0,0,0,0.3782,0,0.0002,0.013,0,0,0.0101,0.028,0.0106,0,0.0282,0.08,0,0.3618,0.1676,0,0.0175,0.0148,0,0.0546,0.0142,0,0,0.1538,0.471,0,0.0131,0,0.12,0.3864,0,0,0.5615,0.1354,0,0,0.0824,0.0028,0,0,0.0133,0,0.034,0.0251,0,0.2436,0.0127,0.2134,0,0,0,0,0.1796,0,0.1434,0.2646,0,0.0139,0,0,0.0489,0,0.0775,0,0,0.105,0,0,0,0,0.1592,0.3031,0.1606,0.0589,0,0,0,0.1009,0,0,0,0,0,0.0513,0,0,0,0,0,0,0,0.3306,0,0.0026,0,0.0574,0,0.1836,0,0,0,0,0.0171,0.3397,0,0,0.0023,0.2599,0,0.1198,0.026,0,0.0005,0,0,0.222,0.0155,0,0,0.0055,0,0,0,0.0001,0,0.8113,0,0.1926,0,0,0,0,0.1049,0.2033,0,0.0139,0.0074,0.3371,0.421,0.0323,0.0168,0.0067,0,0,0.011,0.0613,0,0,0.017,0,0,0,0,0,0.1293,0,0.0049,0,0.0569,0.0029,0,0,0.0223,0.0691,0,0,0.0133,0.1423,0,0,0,0,0.0034,0.2896,0.01,0,0,0.197,0,0.0591,0,0,0,0.0502,0.0344,0.008,0.0385,0.0109,0,0.3712,0.0075,0.1682,0,0,0,0,0.0108,0,0.004,0.1126,0.0034,0,0,0.0042,0.0432,0.0038,0,0,0,0.0025,0,0.0157,0,0.0034,0,0,0,0.1702,0,0,0.006,0.261,0.0118,0,0.0199,0,0.1179,0,0.2986,0.1145,0.0336,0,0,0,0.1325,0,0,0,0,0,0.3642,0,0,0,0,0,0.1802,0.2936,0.077,0.062,0.1271,0,0.0426,0,0.0263,0,0,0,0,0.3582,0.309,0.0512,0,0,0,0,0.0052,0.0958,0,0.0548,0,0,0,0,0,0,0.2836,0,0.0973,0,0,0,0.0259,0,0.173,0.051,0.1075,0.0914,0.0563,0,0,0.1986,0,0,0,0,0,0.1177,0.0481,0,0,0.1554,0.4423,0.5005,0,0.1502,0,0,0.0674,0.0322,0,0.0546,0.0343,0,0,0.3772,0.0017,0.0357,0,0,0.0569,0.0337,0.0372,0.079,0.5141,0.0855,0.1595,0.2282,0,0.1225,0.0136,0.002,0,0,0,0,0.0109,0,0.0453,0.066,0.0143,0,0.6645,0,0.0018,0.119,0,0,0,0,0,0.4294,0,0,0,0.3227,0.2225,0.3698,0.0321,0.3064,0.1198,0,0,0.2125,0,0,0.0054,0,0,0.0798,0.0111,0.3665,0,0,0.0692,0.1909,0,0,0.0095,0.3938,0,0,0,0,0.017,0,0,0.0102,0,0,0,0,0.0046,0,0,0.8315,0,0.0201,0,0,0,0.0405,0.0485,0.0247,0,0,0,0,0,0,0,0.2475,0.0015,0,0,0.0659,0,0.0391,0,0,0.0996,0.082,0,0,0,0.1795,0,0.1474,0,0.1452,0,0,0.2901,0.5099,0,0,0,0,0,0.0024,0,0,0,0.2052,0.0022,0,0.0038,0,0.0488,0,0,0.2317,0.0551,0,0,0,0,0.0412,0,0.0008,0,0,0.0441,0.1205,0,0,0.0311,0.0007,0,0.1364,0.0055,0.3631,0,0,0,0,0.0518,0.0612,0,0.5136,0,0.0052,0.1299,0.0466,0.3557,0,0,0.3747,0,0.0016,0,0,0,0.2188,0.1544,0.0783,0,0.0995,0,0.0481,0.0238,0.0147,0,0.009,0,0,0,0.0023,0,0,0.0252,0.0518,0,0,0.0227,0,0,0,0.0776,0,0.2083,0,0.0849,0,0.03,0.0301,0,0.0809,0.0512,0,0,0,0,0.0202,0.0194,0,0,0,0,0.0202,0,0,0,0,0,0.2055,0,0,0,0.2862,0,0,0.0275,0,0,0,0.1739,0,0.0163,0.0531,0.0069,0.1815,0.0426,0.0076,0.0589,0.003,0.0053,0.0202,0,0,0,0.0228,0,0.4311,0.0258,0,0.2686,0,0.0913,0.0883,0,0.0067,0.0905,0.0254,0,0.4094,0,0,0.1692,0,0.0338,0,0.0749,0,0,0.0561,0,0,0.1642,0.0453,0.1247,0,0.0235,0.2903,0,0,0,0.077,0.1032,0,0,0,0.0461,0,0,0,0.0164,0,0,0.0844,0.181,0,0,0,0,0.014,0.0301,0,0.4428,0.022,0.1792,0.1803,0,0,0.372,0,0.054,0,0.1352,0.0087,0,0,0,0,0.022,0.0599,0,0.1808,0.5207,0.0061,0.0941,0,0,0,0.0164,0,0.0792,0.0793,0.159,0.0151,0.0051,0.0605,0.1863,0.0834,0,0,0,0,0.0094,0,0,0,0.0117,0,0.0156,0.0589,0,0,0.2971,0,0,0,0,0,0,0.6946,0.0761,0,0.4666,0,0.0674,0,0,0.296,0,0,0.0238,0.2527,0.339,0.0006,0.1479,0.0638,0.038,0,0.0781,0,0,0,0.0014,0.1579,0.0168,0.1195,0,0.0202,0,0,0,0.0009,0,0,0,0.222,0,0.0545,0,0,0,0.0357,0,0.3129,0.0851,0.2193,0.0221,0.1222,0,0,0.0546,0.0185,0,0.255,0.3806,0,0.0937,0.0061,0,0,0,0.0315,0,0.109,0,0.0571,0,0.1035,0,0.0041,0.3888,0.5457,0.3478,0,0.0948,0.0648,0,0,0.293,0,0.3995,0,0.1014,0.0153,0,0.4279,0,0,0.321,0,0,0.0217,0.1271,0.0173,0.0167,0.027,0,0,0.438,0.0216,0,0.0177,0.0044,0,0.2,0,0,0.2147,0,0.8678,0.0587,0,0,0,0.1052,0,0,0,0.0233,0.7659,0.0269,0,0,0,0,0,0,0.0288,0.2415,0.3423,0.0193,0.3649,0.0112,0.3225,0.1096,0.2672,0,0,0,0.15,0.1396,0.5056,0.0117,0.0055,0.0534,0.0713,0.0134,0,0.1234,0.6298,0,0.0364,0,0.0815,0,0.0867,0,0,0,0,0.4668,0,0.1956,0,0.092,0,0,0.0894,0,0,0,0,0,0,0,0,0.0206,0,0,0,0.0198,0,0,0,0.0195,0.0216,0.4057,0,0,0.0096,0,0.3122,0.0611,0.0975,0,0.3123,0.0019,0,0,0.1188,0,0.3126,0.0897,0,0,0,0,0.1028,0.0056,0.0782,0,0,0,0.0342,0,0,0.0119,0.0083,0.0094,0,0,0.1368,0.4512,0,0,0.6124,0.0126,0,0.2854,0,0.3883,0,0,0.1753,0.0168,0,0,0]}, {"name":"vlado","source":"/private/onedrive/Vlado/20151017_015042.jpg","embedding":[0.9177,0.0229,0.047,0.0085,0,0,0.2929,1.4321,1.3301,0.7504,0,0,0,0.2336,0,0.0023,0.1488,0.0059,0,0.0951,0.9221,0,0.9552,0,0,0.0897,1.0313,0.8811,0.123,0.052,0.2522,0,0,1.4964,0.9555,0.0176,0.0319,0.1023,0,0,0,0,0.1204,0,0,0,0.0329,0.2029,0,0.7021,0.0419,0.0572,0.2346,1.5578,0.142,0.1667,0.6617,0.2517,0.6487,0.0923,1.187,0,0,0.256,0.0247,0,0.0287,0.2636,0.3157,1.0971,0.2535,0.7727,0.0997,0.0336,0.0271,0.1035,1.7438,0.6366,0,0.0222,0,0.1956,0.0063,0.0124,0.1336,0.0251,0.0722,0,0,1.6137,0,0,0.2963,0.5824,0.1939,0,0.0318,0.1041,0.3766,0.0773,0,1.4251,0.6618,0.3203,0.5397,0,0,0.089,0,0.7355,0.1505,0.032,0.9615,0,0.2973,0,0.1709,0,0.038,0.1612,0.2981,0.7121,1.3203,1.0871,0.5519,0,0.6556,0.0013,0.139,0.7174,0,0.3743,1.8856,0,0.4807,0.7909,0,0,0,0,0,0.0352,0.0266,0.558,0,0.42,0,0.0258,0.0439,0,0,0.0268,0,0,1.1663,0.0178,0.0776,0.2332,0,0,0.0469,0.3568,1.4373,0,1.0237,0.2393,0,1.5853,0,0.0474,0,0,0.4383,1.0846,0.0057,0,0.605,0.0213,0.7991,0.5296,0.1551,0.3933,0.4513,0.1697,0.0231,0.033,0.2776,0.3086,1.1753,0.5873,0,1.9,0.2665,0,1.451,0.0193,1.2368,0,0.194,0.2233,0,0,0.2872,1.3182,0.0455,0.5266,0.1205,0.7994,0.5211,0,0,0.0007,0.0529,0.8064,0.1296,0.6561,1.0804,0.0563,1.3115,0.1662,0.7761,0.0063,0.0019,0,0.2453,0.0759,0.0158,0,0.1201,0.3958,0.0284,0.1975,0,0,0.004,1.1759,0.0341,0.1415,0.2094,0,0.2679,0,0,0.0334,0,0.1014,0,0,0,0.142,0.4909,0,0,0,0.0177,0.129,0.4237,0.1902,0.1319,0.0767,0,0.5288,0.2309,0,0.4662,0,0,0.3158,0,0.1364,0,0.2661,0.9613,0.0007,0.4472,0.0777,0.0432,0,0.92,0.5818,1.277,0.1528,0.0489,0,0.8708,1.3082,0.0315,0.0035,0,0.0615,1.8405,0.0374,0,0.2228,0,0,0.4882,0.2102,0,0.4656,0.8244,0,0.0315,0.1292,0.2837,0.7683,0.579,0.5182,0.0438,0.5474,0.0236,0.0507,0,0,0.0997,0.1364,1.7435,0.7157,0,0.4113,0.1853,0.8822,0.3679,0.1705,0,0.2424,0,0,1.0002,0.0214,0.0051,0,1.206,0.0036,0.0319,0,0,0,0,0.0111,0.019,0.1485,0.0294,0,0.0289,1.3772,0,1.3103,0.3603,0.3063,0.3519,0.0142,0.2783,0.3218,0.6032,0,0,0.4313,0.0276,0.9224,1.11,0,0,1.3638,0.3228,0.8518,0.0671,0.1166,0.4048,0.1644,0.0345,0,0,0.0605,0.688,0.1006,0.1037,0.9487,0.0596,0,0,0,0.3458,0.0619,0.0611,0.8125,0.0168,0.2909,1.9528,0.8394,0,0.1222,0.0357,0.4458,0,0,0,0.3217,0.8478,0,0.1515,0.8568,0.3547,0.645,0,0,1.0103,0.0315,0,2.1566,0,0.0409,0.9435,0.8613,0.1509,0.0534,0,0,0,1.2618,0.0264,0.3334,0.0023,0.2576,0.6866,0,0,0.6862,0.1289,0,0,0,0.1189,0.0058,0.1352,0,0.117,0.3432,0.0583,0.1433,0.0937,0,0.1672,0,1.0618,0,0,0.2235,0.0002,0.0695,0.3818,0.0945,0.7371,0.1681,0,0.796,1.4609,0.9462,0.5326,0,0,0.5054,0,0.2205,0.1598,0,0.5108,0.0544,0.2715,0.1004,0.1355,1.4454,0,0.2138,1.1041,1.0386,0.0725,0.0323,0.0338,0.2655,0.1552,0.0693,0,1.4611,0.0158,0.195,0.2226,0,0.1391,0.3573,0,0.0779,0,0.4117,0,0,0,0.1883,0,0,0.1625,0.3131,0,1.0503,0,0.4243,0.2762,0.0332,0.4751,1.019,0.0204,0,0.1434,0,0.1147,0.002,0.0397,0.0548,0,0.0108,0.0014,0.0586,1.6671,0,0.2265,0.8923,0,0.2691,0,0.0652,0.0401,0.3378,0,0.2475,0.6204,0,0,0,0.0941,0,0,0.7026,0.0075,0.7508,1.4817,0,0.8772,0.0718,0,0.2029,0.2613,0,0.0537,0.1964,0.6654,0,0,1.9525,0.1841,0.1131,0.1149,0,0.1571,0,0,1.1968,0.0747,0.1707,0,0.1755,0.003,1.1288,0,0.6602,0,0.0004,2.4591,0.3164,0.172,0.0402,0,0,0.5647,0.0142,0,0.7073,1.5478,1.1732,0.0423,0,0.8444,0.7948,0,0.304,0.0844,0,0,0.328,0.3886,0.0467,0,0.2764,0.4354,0,0.0535,0,0.9645,0.0926,0.0118,0.4978,0,0.2561,0.6668,0.1117,0.0325,0.0062,0,0,0.0686,0.0474,0.0133,0.3647,0.085,0.0979,0.8139,0.5664,0.9774,0,0,0.2287,0,0.0149,0,0.1531,0.0659,0,0.8204,0.1775,0.0482,0,0.9014,0.2939,0.5666,0.0295,0.5552,0.2178,0.0325,0,0.5443,0,0.0995,0,0,0,0.001,0.1944,0,0.0321,0.4061,0.4883,0,0,0.1833,0.1493,0.9483,0.3454,0,0.012,0.3983,0,0.0017,0.1344,0.1009,0.4554,0.1735,0.5106,0.1304,0.0049,0.4909,0,0.4792,0,0,0.244,0,1.1203,0.8883,0.0299,0,0,0.104,0,0.0663,0.0489,0,0.1235,0.9216,0,1.3607,0.1543,0,0,0.1573,1.2771,0.3408,0,0,0.0209,0,0.4031,0.1557,0.0297,0.3676,0.0107,0.1976,0.9068,0,0.5587,0.0486,0,0,0,0,0,0.7458,0.7984,0,0.8054,0.65,0,1.3127,0,0.1231,0.3047,1.9114,0,0,0.2556,0.1163,0.4041,0.0834,0.2736,0,0,0.4485,0,0.4245,1.2107,0,0.2877,1.0794,0,0.0454,0,0,0,0.0788,0.1957,1.5137,0,0,0,0,0.5499,0.0513,0,0.0126,0.0562,0.0002,0.0145,0.0465,0.0196,0.0754,0.2021,1.7501,0.2037,0.0808,0.2726,0,0.0359,0.7824,0.1067,0,1.0193,0.5033,0.0804,0,0.0733,1.4131,0,0.0113,0.1404,0.5775,0.1531,0,0.0693,0,0.8885,0,0.0574,0.7847,0,0.0219,0.0493,1.0157,0,0,0.3127,0.0247,0.0948,0,0,0.2544,0,0,0,0,0.413,0.8424,0.0198,0,0.4731,0.858,0.8177,0,0.0273,0,0.0046,0.0238,0.0342,0.1658,0.4642,0.0707,0.6947,0,0.511,0.0895,0.7339,0.0364,1.329,0.0089,0,0,0.0086,0.1519,0,0,0,0.0015,1.1381,1.0228,0.0868,0.1464,0.7821,0,0.034,0.1049,2.1388,0.8665,0.308,0.3578,0,0,0.2297,0,0.1222,0.2882,0.5173,0.0748,0,0.0164,0.1987,0.0663,0.1356,0,0.0139,0.1197,0,0.8499,0.5448,0.7993,0,1.5697,0.0901,0.0201,1.2587,0,0.3782,0.0519,0.0554,0,0,0.0175,0.0427,0.1445,1.1907,0.0801,0,0,0,1.7608,0,0.002,0,0.0054,0.0841,0,0.1595,0.2563,0,0.052,0,0,0,1.358,0.9231,0.8903,0.24,0,1.3882,0.1817,0,0.0466,0,0,0,0.2356,0.499,0.3658,1.6177,0,0.0501,0,1.0359,1.3173,0.06,0,0.0937,0,0.4451,0.3077,0,0,0.0041,0,0,0,1.4261,0.1121,0,0.1755,0.0268,0.1915,0.1798,0.0035,0,0,0,0,0.4052,0,0.1882,0.7986,0.235,0,0,0,1.2267,0.0416,0.9146,0.8223,0.1561,0.4221,0.0519,0.1055,0.0515,0,0,0,0.3123,0,0.1518,0.0365,0.0556,0,0,0.0114,0.8106,1.572,0.1214,0,0.0566,0,0,2.027,0.0722,0,0,0,0.0871,0.2255,0,0.0977,0,0.8336,0.2655,0.1768,0,0,0,0.598,1.4716,1.4172,0.4221,0.8698,0.0162,0.2419,0,0,0.9411,0.238,0.0782,0,0]}, diff --git a/package.json b/package.json index 266c3068..56be961e 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@tensorflow/tfjs-layers": "^3.9.0", "@tensorflow/tfjs-node": "^3.9.0", "@tensorflow/tfjs-node-gpu": "^3.9.0", - "@types/node": "^16.9.3", + "@types/node": "^16.9.4", "@typescript-eslint/eslint-plugin": "^4.31.1", "@typescript-eslint/parser": "^4.31.1", "@vladmandic/build": "^0.5.2", diff --git a/src/human.ts b/src/human.ts index 63d2e948..e73213f9 100644 --- a/src/human.ts +++ b/src/human.ts @@ -442,7 +442,7 @@ export class Human { } if (!img.tensor) { - log('could not convert input to tensor'); + if (this.config.debug) log('could not convert input to tensor'); resolve({ error: 'could not convert input to tensor' }); return; } diff --git a/src/image/image.ts b/src/image/image.ts index 428a06db..08e35867 100644 --- a/src/image/image.ts +++ b/src/image/image.ts @@ -39,9 +39,13 @@ export function canvas(width, height): HTMLCanvasElement | OffscreenCanvas { // process input image and return tensor // input can be tensor, imagedata, htmlimageelement, htmlvideoelement // input is resized and run through imagefx filter -export function process(input: Input, config: Config): { tensor: Tensor | null, canvas: OffscreenCanvas | HTMLCanvasElement } { +export function process(input: Input, config: Config): { tensor: Tensor | null, canvas: OffscreenCanvas | HTMLCanvasElement | null } { let tensor; - if (!input) throw new Error('input is missing'); + if (!input) { + // throw new Error('input is missing'); + if (config.debug) log('input is missing'); + return { tensor: null, canvas: null }; // video may become temporarily unavailable due to onresize + } // sanity checks since different browsers do not implement all dom elements if ( !(input instanceof tf.Tensor) @@ -64,13 +68,13 @@ export function process(input: Input, config: Config): { tensor: Tensor | null, } else { // check if resizing will be needed if (typeof input['readyState'] !== 'undefined' && input['readyState'] <= 2) { - log('input stream is not ready'); + if (config.debug) log('input stream is not ready'); return { tensor: null, canvas: inCanvas }; // video may become temporarily unavailable due to onresize } const originalWidth = input['naturalWidth'] || input['videoWidth'] || input['width'] || (input['shape'] && (input['shape'][1] > 0)); const originalHeight = input['naturalHeight'] || input['videoHeight'] || input['height'] || (input['shape'] && (input['shape'][2] > 0)); if (!originalWidth || !originalHeight) { - log('cannot determine input dimensions'); + if (config.debug) log('cannot determine input dimensions'); return { tensor: null, canvas: inCanvas }; // video may become temporarily unavailable due to onresize } let targetWidth = originalWidth; diff --git a/src/segmentation/segmentation.ts b/src/segmentation/segmentation.ts index 8e90aec0..abea1537 100644 --- a/src/segmentation/segmentation.ts +++ b/src/segmentation/segmentation.ts @@ -67,25 +67,19 @@ export async function predict(input: { tensor: Tensor | null, canvas: OffscreenC return data; // we're running in nodejs so return alpha array as-is } - const overlay = (typeof OffscreenCanvas !== 'undefined') ? new OffscreenCanvas(width, height) : document.createElement('canvas'); - overlay.width = width; - overlay.height = height; + const overlay = image.canvas(width, height); if (tf.browser) await tf.browser.toPixels(resizeOutput, overlay); tf.dispose(resizeOutput); // get alpha channel data - const alphaCanvas = (typeof OffscreenCanvas !== 'undefined') ? new OffscreenCanvas(width, height) : document.createElement('canvas'); // need one more copy since input may already have gl context so 2d context fails - alphaCanvas.width = width; - alphaCanvas.height = height; + const alphaCanvas = image.canvas(width, height); const ctxAlpha = alphaCanvas.getContext('2d') as CanvasRenderingContext2D; ctxAlpha.filter = 'blur(8px'; await ctxAlpha.drawImage(overlay, 0, 0); const alpha = ctxAlpha.getImageData(0, 0, width, height).data; // get original canvas merged with overlay - const original = (typeof OffscreenCanvas !== 'undefined') ? new OffscreenCanvas(width, height) : document.createElement('canvas'); // need one more copy since input may already have gl context so 2d context fails - original.width = width; - original.height = height; + const original = image.canvas(width, height); const ctx = original.getContext('2d') as CanvasRenderingContext2D; if (input.canvas) await ctx.drawImage(input.canvas, 0, 0); // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation // best options are: darken, color-burn, multiply @@ -105,19 +99,21 @@ export async function process(input: Input, background: Input | undefined, confi busy = true; if (!model) await load(config); const img = image.process(input, config); + const tmp = image.process(background, config); + if (!img.canvas || !tmp.canvas) { + if (config.debug) log('segmentation cannot process input or background'); + return null; + } const alpha = await predict(img); tf.dispose(img.tensor); if (background && alpha) { - const tmp = image.process(background, config); - const bg = tmp.canvas; + const bg = tmp.canvas as HTMLCanvasElement; tf.dispose(tmp.tensor); - const fg = img.canvas; + const fg = img.canvas as HTMLCanvasElement; const fgData = fg.getContext('2d')?.getImageData(0, 0, fg.width, fg.height).data as Uint8ClampedArray; - const c = (typeof OffscreenCanvas !== 'undefined') ? new OffscreenCanvas(fg.width, fg.height) : document.createElement('canvas'); - c.width = fg.width; - c.height = fg.height; + const c = image.canvas(fg.width, fg.height); const ctx = c.getContext('2d') as CanvasRenderingContext2D; ctx.globalCompositeOperation = 'copy'; // reset diff --git a/test/test-main.js b/test/test-main.js index 681738c3..e27b3c4f 100644 --- a/test/test-main.js +++ b/test/test-main.js @@ -1,3 +1,4 @@ +const fs = require('fs'); const process = require('process'); const canvasJS = require('canvas'); @@ -165,6 +166,13 @@ async function test(Human, inputConfig) { else log('error', 'failed: configuration default validation', invalid); delete config.invalid; + // test model loading + await human.load(); + const models = Object.keys(human.models).map((model) => ({ name: model, loaded: (human.models[model] !== null) })); + const loaded = models.filter((model) => model.loaded); + if (models.length === 14 && loaded.length === 7) log('state', 'passed: models loaded', models.length, loaded.length); + else log('error', 'failed: models loaded', models.length, loaded.length); + // test warmup sequences await testInstance(human); config.warmup = 'none'; @@ -175,28 +183,73 @@ async function test(Human, inputConfig) { res = await testWarmup(human, 'default'); if (!res || res?.face?.length !== 1 || res?.body?.length !== 1 || res?.hand?.length !== 0 || res?.gesture?.length !== 3) log('error', 'failed: warmup face result mismatch', res?.face?.length, res?.body?.length, res?.hand?.length, res?.gesture?.length); else log('state', 'passed: warmup face result match'); - config.warmup = 'body'; res = await testWarmup(human, 'default'); if (!res || res?.face?.length !== 1 || res?.body?.length !== 1 || res?.hand?.length !== 0 || res?.gesture?.length !== 3) log('error', 'failed: warmup body result mismatch', res?.face?.length, res?.body?.length, res?.hand?.length, res?.gesture?.length); else log('state', 'passed: warmup body result match'); - // test default config + // test default config async log('info', 'test default'); human.reset(); + config.async = true; config.cacheSensitivity = 0; res = await testDetect(human, 'samples/ai-body.jpg', 'default'); if (!res || res?.face?.length !== 1 || res?.face[0].gender !== 'female') log('error', 'failed: default result face mismatch', res?.face?.length, res?.body?.length, res?.hand?.length, res?.gesture?.length); else log('state', 'passed: default result face match'); - // test default config + // test default config sync log('info', 'test sync'); human.reset(); config.async = false; + config.cacheSensitivity = 0; res = await testDetect(human, 'samples/ai-body.jpg', 'default'); if (!res || res?.face?.length !== 1 || res?.face[0].gender !== 'female') log('error', 'failed: default sync', res?.face?.length, res?.body?.length, res?.hand?.length, res?.gesture?.length); else log('state', 'passed: default sync'); + // test image processing + const img1 = await human.image(null); + const img2 = await human.image(await getImage(human, 'samples/ai-face.jpg')); + if (!img1 || !img2 || img1.tensor !== null || img2.tensor?.shape?.length !== 4) log('error', 'failed: image input', img1?.tensor?.shape, img2?.tensor?.shape); + else log('state', 'passed: image input', img1?.tensor?.shape, img2?.tensor?.shape); + + // test null input + res = await human.detect(null); + if (!res || !res.error) log('error', 'failed: invalid input', res); + else log('state', 'passed: invalid input', res); + + // test face similarity + log('info', 'test face similarity'); + human.reset(); + config.async = false; + config.cacheSensitivity = 0; + let res1 = await testDetect(human, 'samples/ai-face.jpg', 'default'); + let res2 = await testDetect(human, 'samples/ai-body.jpg', 'default'); + let res3 = await testDetect(human, 'samples/ai-upper.jpg', 'default'); + const desc1 = res1 && res1.face && res1.face[0] && res1.face[0].embedding ? [...res1.face[0].embedding] : null; + const desc2 = res2 && res2.face && res2.face[0] && res2.face[0].embedding ? [...res2.face[0].embedding] : null; + const desc3 = res3 && res3.face && res3.face[0] && res3.face[0].embedding ? [...res3.face[0].embedding] : null; + if (!desc1 || !desc2 || !desc3 || desc1.length !== 1024 || desc2.length !== 1024 || desc3.length !== 1024) log('error', 'failed: face descriptor', desc1?.length, desc2?.length, desc3?.length); + else log('state', 'passed: face descriptor'); + res1 = Math.round(100 * human.similarity(desc1, desc2)); + res2 = Math.round(100 * human.similarity(desc1, desc3)); + res3 = Math.round(100 * human.similarity(desc2, desc3)); + if (res1 !== 51 || res2 !== 49 || res3 !== 53) log('error', 'failed: face match ', res1, res2, res3); + else log('state', 'passed: face match'); + + // test face matching + log('info', 'test face matching'); + let db = []; + try { + db = JSON.parse(fs.readFileSync('demo/facematch/faces.json').toString()); + } catch { /***/ } + if (db.length < 100) log('error', 'failed: face database ', db.length); + else log('state', 'passed: face database', db.length); + res1 = human.match(desc1, db); + res2 = human.match(desc2, db); + res3 = human.match(desc3, db); + if (!res1 || !res1['name'] || !res2 || !res2['name'] || !res3 || !res3['name']) log('error', 'failed: face match ', res1); + else log('state', 'passed: face match', { first: { name: res1.name, similarity: res1.similarity } }, { second: { name: res2.name, similarity: res2.similarity } }, { third: { name: res3.name, similarity: res3.similarity } }); + // test object detection log('info', 'test object'); human.reset(); @@ -273,6 +326,22 @@ async function test(Human, inputConfig) { testDetect(second, 'samples/ai-upper.jpg', 'default'), ]); + // test monkey-patch + human.env.Canvas = canvasJS.Canvas; // monkey-patch human to use external canvas library + const inputImage = await canvasJS.loadImage('samples/ai-face.jpg'); // load image using canvas library + const inputCanvas = new canvasJS.Canvas(inputImage.width, inputImage.height); // create canvas + const ctx = inputCanvas.getContext('2d'); + ctx.drawImage(inputImage, 0, 0); // draw input image onto canvas + res = await human.detect(inputCanvas); + if (!res || res?.face?.length !== 1) log('error', 'failed: monkey patch'); + else log('state', 'passed: monkey patch'); + + // test segmentation + res = await human.segmentation(inputCanvas, inputCanvas); + if (!res || !res.width || !res.height) log('error', 'failed: segmentation', res); + else log('state', 'passed: segmentation', [res.width, res.height]); + human.env.Canvas = undefined; + // tests end const t1 = process.hrtime.bigint(); diff --git a/test/test-node-wasm.js b/test/test-node-wasm.js index 6c63614f..06e92afb 100644 --- a/test/test-node-wasm.js +++ b/test/test-node-wasm.js @@ -27,7 +27,7 @@ const config = { }, hand: { enabled: true, rotation: false }, body: { enabled: true }, - object: { enabled: false }, + object: { enabled: true }, segmentation: { enabled: true }, filter: { enabled: false }, }; diff --git a/test/test.js b/test/test.js index 49a445e0..1fb4f3d5 100644 --- a/test/test.js +++ b/test/test.js @@ -60,6 +60,7 @@ function logStdIO(ok, test, buffer) { } } +// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars async function runTest(test) { log.info(); log.info(test, 'start'); @@ -73,6 +74,7 @@ async function runTest(test) { }); } +// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars async function runDemo(demo) { log.info(); log.info(demo, 'start'); @@ -94,7 +96,8 @@ async function testAll() { process.on('unhandledRejection', (data) => log.error('nodejs unhandled rejection', data)); process.on('uncaughtException', (data) => log.error('nodejs unhandled exception', data)); log.info('tests:', tests); - for (const demo of demos) await runDemo(demo); + log.info('demos:', demos); + // for (const demo of demos) await runDemo(demo); for (const test of tests) await runTest(test); log.info(); log.info('status:', status);