photoprism/internal/entity/markers_test.go
Michael Mayer 884dea17de Security: Use individual preview tokens for each user account #98
Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-10-13 22:11:02 +02:00

198 lines
27 KiB
Go

package entity
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/photoprism/photoprism/internal/crop"
"github.com/photoprism/photoprism/internal/face"
)
var cropArea1 = crop.Area{Name: "face", X: 0.308333, Y: 0.206944, W: 0.355556, H: 0.355556}
var cropArea2 = crop.Area{Name: "face", X: 0.208313, Y: 0.156914, W: 0.655556, H: 0.655556}
var cropArea3 = crop.Area{Name: "face", X: 0.998133, Y: 0.816944, W: 0.0001, H: 0.0001}
var cropArea4 = crop.Area{Name: "face", X: 0.298133, Y: 0.216944, W: 0.255556, H: 0.155556}
var testEmbeddings = face.Embeddings{
face.Embedding{-0.037731018, -0.005501065, 0.04339579, 0.050818004, -0.059338734, 0.033849984, -0.006599584, -0.0017643301, 0.049746443, -0.103716515, 0.037138782, -0.0064612515, 0.071909964, 0.013218528, -0.065359734, 0.11057091, 0.031195551, 0.025612833, 0.0075477255, -0.034973715, -0.013490629, -0.08104751, -0.022038054, -0.05304818, 0.008366317, -0.056096837, -0.008484318, 0.049539477, 0.019540254, 0.067417614, -0.027856546, -0.008532138, -0.017063588, -0.00016265438, -0.106199585, 0.03904082, 0.030587498, 0.043008707, -0.015111545, -0.022849092, 0.0025588698, -0.012814152, 0.037556626, -0.0086288145, 0.05265788, 0.011832273, 0.00015048613, -0.0081366515, 0.0013409692, 0.028389124, 0.022627315, -0.015008434, -0.0007749727, 0.013927345, -0.012275729, -0.0090859635, 0.019502806, -0.011900984, 0.016286656, 0.08094661, 0.000306613, -0.06327904, 0.018552454, 0.08885108, -0.07583091, 0.09275318, -0.018484656, 0.074180886, -0.039385945, -0.08063905, -0.05360434, -0.037074074, 0.09909196, 0.025063906, -0.009406389, -0.029612983, -0.018644262, 0.08433939, -0.04466277, -0.07118042, -0.0053266245, -0.07471344, 0.06739151, -0.05399609, 0.03125197, -0.00007781149, -0.04214992, -0.044316035, 0.025013437, 0.031466946, 0.0023496088, 0.042693187, -0.046198968, 0.026152546, -0.017578958, 0.023763098, 0.027511515, -0.05229892, -0.005204117, 0.035853546, -0.031919815, -0.027175877, -0.033706605, 0.018576957, -0.0010251165, -0.006808904, 0.009910016, -0.046926413, -0.02833718, 0.0132687995, -0.033933964, 0.06434295, 0.046245363, 0.044698197, 0.041076522, 0.04224362, -0.050834127, 0.0037004466, 0.061506275, -0.018232772, 0.067569405, 0.048701495, 0.042266034, -0.11045008, 0.03627151, -0.07259142, -0.0027725939, 0.040572345, 0.010365194, -0.018683784, 0.004533848, 0.037213936, -0.050944775, 0.07134523, 0.004012727, 0.036228556, -0.013853831, -0.06910639, -0.011394227, -0.012075533, 0.036311198, -0.02587341, -0.04086224, -0.024498813, -0.019423751, -0.022674281, 0.052483488, 0.026303312, -0.051178075, 0.008410645, 0.039851066, -0.028721321, -0.027934253, -0.029567441, 0.054549955, 0.07423011, -0.07211806, 0.015979288, 0.002092099, 0.049062036, 0.025120452, 0.045975365, 0.025024865, -0.04019101, 0.0013054911, -0.0049644294, 0.0065203104, -0.03237452, -0.020704443, 0.028736785, -0.027353559, 0.07551169, 0.0842262, 0.019992182, 0.11138123, -0.028617613, 0.06700691, -0.048681036, -0.008201593, -0.058066163, 0.027867565, 0.07693089, -0.033642102, -0.05855467, -0.08575646, -0.019721355, 0.018443357, -0.0037373751, 0.032450553, -0.0074002664, -0.028135147, 0.046631414, 0.0192969, -0.0071076434, -0.004898368, 0.011896125, -0.026020564, 0.074016415, -0.033884488, -0.07919758, 0.021606326, -0.0142197255, 0.0807476, 0.03722956, -0.0015949347, 0.008076167, -0.009640628, 0.02341143, 0.015375526, -0.059428506, 0.051759534, 0.028049389, 0.07790443, 0.0478649, 0.09191913, -0.055882096, -0.026637457, 0.01236174, -0.0033003334, 0.008522798, 0.027216703, -0.033221588, -0.028086975, -0.11505473, -0.044336796, 0.013873659, 0.03982099, 0.060988583, -0.07439005, 0.01333661, -0.004818605, 0.02561305, -0.059055943, 0.0081638545, -0.032278564, 0.046092775, 0.025316834, -0.046857174, -0.0341012, 0.04379944, -0.029710777, 0.09238533, 0.009769442, 0.018552538, -0.02632421, 0.033739865, -0.022547472, 0.016400741, -0.05336998, -0.012623122, -0.08303054, -0.010368709, 0.01690871, 0.0014627968, -0.050720602, 0.038742293, -0.065664165, -0.10676187, -0.013403239, 0.075702645, -0.055623896, -0.03871971, -0.042371742, 0.03794916, -0.0590573, -0.002583715, -0.029995736, -0.08144537, -0.043295015, -0.034286328, -0.026538746, 0.01953962, 0.08203153, 0.036415525, 0.045531306, 0.004713152, 0.026550433, -0.0055336948, -0.031087596, -0.01923592, -0.1047651, 0.051826596, -0.009522955, 0.0023846119, -0.030824797, 0.0011774554, 0.03384506, 0.010090165, -0.033521466, -0.052155476, 0.0032979914, -0.004305921, -0.08622774, 0.03262125, 0.06332183, 0.00067599304, 0.01989574, 0.04406689, 0.019945903, -0.003796719, 0.00025200442, -0.010055775, 0.04070448, -0.004082432, -0.026942603, 0.110138796, -0.029453337, 0.015611174, 0.08778206, -0.027199872, -0.014513782, 0.021546016, 0.01706933, -0.01365763, 0.026393317, -0.029974515, 0.0050973813, 0.00732006, 0.034644503, 0.03125295, -0.01563078, -0.041023903, -0.04566191, -0.00013489528, 0.04253813, 0.045907266, -0.011943533, 0.031480506, -0.0034109016, -0.035025172, 0.028193155, -0.06832476, -0.0019371725, -0.049427234, -0.0061696135, 0.051213425, 0.07832765, -0.01894849, 0.0290217, 0.031639505, -0.045830216, -0.048976466, 0.052241277, -0.026111973, 0.037248738, -0.07693719, -0.00020981894, 0.030037824, -0.041687537, -0.015251262, 0.041234106, 0.031005232, 0.024838371, 0.0020733695, -0.038252156, -0.026375879, 0.03495583, 0.018539391, -0.07203285, 0.006305707, -0.004792029, -0.05153865, 0.0072443904, -0.017075827, 0.013596034, -0.0054885144, -0.052320853, -0.033805914, -0.038080305, -0.010182737, 0.012953395, 0.014565793, -0.023107765, 0.030313661, 0.011124675, 0.018100796, 0.1074551, -0.074430406, -0.04017658, -0.002058053, -0.07340946, 0.0033503077, 0.04565434, -0.033483636, -0.029218825, -0.05245377, -0.059680052, 0.017752757, -0.05493096, -0.10746678, 0.08623605, 0.014577705, 0.0044184765, -0.025559181, -0.015846781, -0.006661373, 0.09459266, 0.036481388, 0.030402042, -0.0152169075, 0.0037343376, 0.024195764, -0.01859682, -0.0022416788, 0.0056786016, -0.06771737, 0.02364697, 0.021247962, 0.05002757, 0.083975114, 0.011197936, 0.0035017033, -0.0014220127, -0.024415374, 0.023921741, -0.0108229555, -0.06622103, -0.00024976654, 0.06549428, -0.004968772, -0.011665843, 0.03409593, 0.028397659, -0.086434126, -0.074232705, 0.041721817, -0.034767248, -0.014432104, 0.006313255, 0.04040112, -0.0050085387, -0.0023618732, -0.02225774, 0.02383989, 0.061036374, 0.058602326, 0.04343989, -0.029145751, 0.0369256, -0.054843802, -0.017078603, 0.047091234, 0.050245833, -0.04615808, -0.02404996, 0.02584908, -0.006215116, -0.016719814, 0.052097827, 0.01908364, -0.07564805, -0.11024787, -0.036854018, -0.0056766514, -0.007618422, 0.034403287, 0.056957226, -0.03565076, -0.0365251, 0.040833052, 0.008173664, -0.04300709, 0.0028465139, -0.020792698, 0.020321466, -0.002447697, 0.019681728, -0.08843341, -0.042670425, 0.014576458, 0.009701015, -0.12435015, -0.025056241, 0.03084893, -0.031128377, 0.006784327, 0.052201632, 0.06773422, 0.015289244, 0.009421969, 0.0725144, -0.07110377, -0.05183192, -0.008816121, -0.11178569, 0.079700254, -0.0110752955, 0.0046521816, -0.07299747, 0.10732809, -0.06012486, 0.057736155, -0.02227576, -0.063017495, 0.085292354, 0.037407015, -0.07368719, 0.033426613, 0.062104296, -0.016089993, -0.023178348, -0.064638525, 0.028132388, -0.049967688, 0.053581465, 0.031400185, 0.0712773, -0.012665878, 0.0760322, 0.030081542, -0.022147592, 0.009422989},
face.Embedding{-0.00067741907, -0.0473858, -0.055704225, 0.066581585, 0.005290037, 0.03822874, -0.05082791, 0.049087, 0.018308854, -0.01478969, -0.0017964382, 0.057903986, -0.02245441, -0.033446193, -0.0071987803, -0.03150515, 0.017724376, 0.019948162, 0.056362633, -0.11701946, -0.09725581, 0.013104323, 0.07357148, -0.020104313, -0.014956488, -0.017257847, -0.020743687, -0.046340823, -0.021527996, 0.057039287, -0.051751148, -0.00595411, 0.011733857, -0.04644382, -0.028774152, 0.038308877, -0.015685631, 0.0038190065, -0.094677314, 0.07005245, -0.003068884, 0.050274804, -0.018143218, 0.012056174, 0.019058047, -0.00077958487, 0.030408988, 0.0885491, -0.11106459, -0.019910613, 0.01465938, 0.032499526, 0.04720623, 0.03163276, -0.079508044, 0.07914293, 0.03724754, 0.05636608, -0.016979787, -0.04298359, -0.03599786, 0.058342796, -0.024069536, -0.03200436, 0.015390179, 0.07293075, -0.0013783299, -0.01605161, -0.0045498423, -0.016551308, 0.060823392, 0.073548146, -0.021239666, -0.036749583, 0.00028047478, -0.025989566, -0.05310693, -0.009845653, -0.012862101, 0.058108855, 0.06915682, 0.021099294, 0.001225616, 0.033261415, 0.042154703, 0.05271609, -0.030613305, 0.041209485, 0.0019353209, -0.0019135632, 0.080911145, 0.011060149, 0.05281461, -0.10160427, 0.053647887, 0.01762615, -0.018661015, 0.02777136, -0.056023918, 0.057687696, 0.06513923, -0.069180146, -0.015231091, 0.03774808, 0.012945786, 0.090585396, 0.019942591, -0.015280875, -0.0011742035, -0.042135417, 0.05812486, 0.05519544, -0.06453465, -0.04014237, -0.03199121, 0.009241696, 0.043912023, 0.015467731, 0.0020673021, 0.08763925, -0.08974939, -0.05304043, 0.016309343, -0.04766073, -0.0046682972, -0.040477246, 0.012679025, 0.005960806, -0.03256039, -0.07089416, -0.02648642, -0.062463485, 0.08295411, -0.037147924, -0.074104264, 0.077417135, -0.042383663, 0.002088579, 0.07709948, 0.06521331, -0.07541816, 0.057679284, -0.0038482754, 0.055191133, 0.058614884, -0.018541405, -0.012277692, 0.057926673, -0.01724738, 0.020869015, 0.046103075, -0.0319926, -0.0671411, 0.02629761, 0.044356663, 0.036788594, 0.028035736, 0.06419986, 0.045972086, -0.044160895, 0.09784713, 0.00953585, -0.06252615, 0.025597766, 0.029688764, 0.027506752, -0.055384982, -0.028262418, -0.057812758, 0.042470966, -0.05840525, -0.03801629, 0.0043816785, -0.015086851, 0.022297874, 0.054110903, 0.07420415, -0.040949743, -0.08912868, -0.060081407, -0.046966024, -0.04826231, -0.031198893, 0.06643161, 0.01347482, 0.029003717, 0.047974125, 0.07580259, 0.0364837, 0.012980756, 0.020622224, -0.022555852, 0.10519882, -0.03425076, 0.03889103, -0.007944982, 0.060116176, 0.038143042, -0.043681793, 0.05316621, 0.0016697546, -0.0033659195, 0.020053076, -0.07204762, 0.009732797, 0.03862544, 0.03913928, -0.009832126, 0.06401315, 0.044209804, -0.051490918, 0.014780334, -0.025438532, -0.01395564, -0.038089562, -0.009803314, -0.04146325, 0.03357636, -0.009009651, 0.04373462, -0.05627207, -0.072068065, -0.007331119, -0.04238925, -0.021102922, -0.021610938, -0.063095644, -0.05075978, -0.07491732, 0.0113026835, 0.04940704, 0.084163934, -0.01636119, -0.06292533, -0.014526007, -0.007826649, 0.07212185, 0.004734863, -0.062791124, -0.016170232, -0.016590146, -0.024280416, -0.019522576, 0.01579864, 0.002749153, 0.053687476, -0.016495354, 0.03662209, -0.018870195, 0.039446633, 0.04715818, 0.013310755, 0.028033575, 0.067203104, -0.005826697, 0.042239364, -0.020745477, 0.0015561507, 0.065384425, 0.09041862, 0.01788624, -0.010026493, 0.0639752, -0.0041079777, -0.058741663, 0.034099422, 0.016963305, -0.0052649197, -0.07403116, -0.0029912698, -0.07583906, 0.001012409, -0.029492352, -0.04166984, -0.048218843, -0.06306306, -0.0033243645, -0.02919451, 0.0039520795, -0.037993237, 0.044352133, 0.03976749, -0.030565975, -0.076377496, -0.06569797, 0.01630497, 0.017201763, 0.028935125, 0.004058029, -0.09946857, 0.036038112, -0.06792709, 0.04493338, 0.035801385, -0.048764315, -0.06326099, 0.037968885, 0.038012274, 0.038041856, 0.04288072, 0.01531972, 0.032477308, 0.043926656, -0.0077148937, 0.056322563, -0.03451439, -0.0083661955, 0.0015379508, -0.007879496, 0.01986026, -0.019533899, 0.0405012, 0.015047856, 0.04601962, 0.080275685, 0.017424034, -0.032671392, 0.024088044, -0.021807125, 0.010775311, 0.094901696, 0.0048406925, 0.013086048, 0.04339756, -0.0069915624, 0.019183818, 0.0624931, 0.019509323, 0.07727781, 0.071851335, 0.046544127, 0.040363774, -0.027118236, 0.06800823, -0.01851149, 0.039025713, -0.037301723, 0.05617681, 0.027737545, -0.0011841523, 0.034742635, 0.006083848, 0.033872508, 0.012025738, -0.02354928, -0.07461171, 0.0027702893, 0.04646551, 0.06590462, -0.00794524, -0.011096932, 0.031695057, -0.06732352, -0.051879242, -0.0773121, -0.000517982, 0.08113213, -0.015312499, 0.018544769, -0.023654874, -0.01689197, 0.026425209, -0.08191027, 0.03139842, -0.011997609, 0.059896134, 0.07505033, -0.012907369, 0.008597082, 0.007715897, -0.07062183, -0.027084265, 0.0028182073, 0.03769887, 0.034299187, 0.046780333, -0.007847023, -0.051446356, 0.007982996, -0.034917314, -0.0038174198, -0.05954771, -0.044208106, 0.04685703, -0.0199229, -0.0032713648, 0.009684984, -0.050678924, 0.007356914, -0.06628045, 0.042982273, 0.0055478252, 0.011330174, -0.082057334, 0.026437566, -0.015942575, 0.048285805, -0.003856138, 0.04399534, 0.01741405, -0.059217025, 0.056499016, -0.03459506, 0.030366927, 0.016147505, -0.021027595, -0.013333387, -0.035330992, 0.0445699, -0.03483558, 0.02072434, -0.019552084, -0.0043943045, -0.03957101, 0.0041682394, 0.006047565, 0.03504845, 0.04675005, -0.021805461, -0.0033183587, -0.0017508261, 0.033419013, 0.008266579, 0.067113, -0.026226636, -0.020189233, 0.029219048, 0.031028047, 0.021648621, -0.055164326, -0.008505359, 0.05173594, 0.016450783, -0.017234024, -0.10492493, -0.04954522, 0.024168914, -0.008840458, -0.078473605, -0.042714797, -0.040692057, -0.05446264, 0.0148880705, 0.057658363, 0.005458192, 0.02171352, -0.04556389, 0.017333247, -0.10342444, -0.06159851, -0.03170678, 0.08064648, 0.024460033, -0.07185376, -0.0019515441, -0.026248276, 0.034460787, 0.08695437, 0.06363327, 0.012909266, 0.00093975884, 0.03682474, -0.041370448, -0.0070990156, 0.058603138, -0.038166087, -0.039693672, 0.025385896, 0.0035452761, -0.015794974, 0.019059189, -0.028707229, 0.038948998, -0.032039847, -0.07992934, -0.05482927, 0.048767164, -0.03186542, 0.059099294, 0.063702375, 0.01810526, -0.019284561, 0.036313917, 0.0006970895, 0.020730797, 0.08630282, -0.10650717, 0.0017196184, 0.023258938, -0.021214833, 0.015206377, -0.027243242, -0.021319263, -0.054438062, 0.066603355, -0.047786396, 0.018822387, -0.031346995, -0.0049103773, -0.020732613, -0.0841506, 0.00707288, -0.0033278253, 0.068160556, -0.011127404, 0.05533654, 0.0046188673, 0.039132893, 0.008633137, -0.057081457, -0.030337824, -0.0721918},
face.Embedding{0.05743743, 0.06322246, 0.04731233, -0.01582013, -0.014022472, 0.028749773, -0.079572044, 0.010417165, 0.012425559, -0.013655686, -0.05018789, 0.026249807, 0.037449032, 0.051438555, -0.055292394, 0.018136416, 0.035481997, 0.021924775, 0.0449153, -0.046709806, 0.025960712, -0.063309774, 0.037570722, 0.0053055496, 0.07164356, -0.058082405, 0.0017537506, 0.05310737, 0.008366767, 0.001858572, -0.0444527, -0.04880738, -0.033274952, -0.08379612, -0.018964237, -0.0029277618, -0.021386296, 0.0375952, -0.034034044, -0.060141306, -0.0727236, 0.05060482, -0.082235344, 0.04422095, 0.074947104, 0.020209799, 0.0017703519, -0.015411033, 0.012017898, 0.02179871, -0.013231191, -0.08483583, 0.0057485234, -0.019012775, -0.04857383, 0.084329374, 0.009039854, 0.040807534, -0.01692938, 0.0017201875, 0.036594935, -0.08844029, -0.00285713, 0.054565318, -0.047155175, 0.017556412, 0.009818504, 0.113506615, -0.009222306, -0.0004704829, -0.0005908021, 0.023356704, 0.015126567, 0.035651624, 0.025497274, -0.10676789, -0.06828348, 0.112095155, 0.08150907, 0.0007053766, -0.008199173, -0.03852071, 0.029535439, -0.030568745, -0.08978221, -0.004848515, -0.03737906, 0.036448833, 0.004548617, 0.08181337, -0.0087715015, 0.02876368, -0.0060202847, -0.013462866, -0.05015226, -0.03569624, 0.049505115, 0.011994855, -0.010969182, -0.0038046215, -0.004821639, 0.01422656, -0.05946822, -0.013812223, 0.039755587, 0.034921456, -0.05158028, -0.0008751564, -0.031674784, -0.002480392, 0.013109971, -0.017252844, 0.064675435, 0.07642624, 0.08362122, 0.030908048, 0.067052245, 0.021291262, 0.01784629, -0.0507172, 0.052007917, 0.04663132, 0.0064223176, -0.027726524, 0.08033194, 0.038676508, 0.018382965, 0.048913725, -0.022436062, 0.0056725373, -0.040102404, 0.037674494, -0.022307452, -0.03098931, 0.0577183, -0.022725038, -0.0055031423, 0.045162845, -0.014300147, -0.018093627, -0.040114313, -0.051383376, -0.030573318, -0.101557806, -0.008447289, 0.014637746, 0.050047614, -0.011550598, 0.027773034, -0.03317795, -0.048737925, -0.02800452, -0.016925864, -0.037572905, 0.025179392, 0.031473313, -0.010588548, -0.0119464, 0.0057186596, 0.049826983, -0.026282294, -0.00095309806, 0.04696705, -0.0444816, -0.04687481, -0.05711774, 0.07398202, -0.0066416007, -0.016446855, 0.051111717, -0.0419391, -0.013271554, 0.043318115, 0.0012680996, 0.037176434, -0.021031545, 0.03968714, 0.048614495, -0.0058204047, -0.010237752, 0.07029732, 0.018752169, -0.0616816, 0.008854898, 0.06205655, -0.009874518, -0.050585378, 0.012557405, 0.01626891, 0.017797807, -0.03568621, -0.007182635, 0.015247179, 0.02795279, 0.009831571, 0.045041207, -0.055870973, -0.025731718, 0.01907759, -0.034226514, 0.029678043, -0.021697098, -0.020734878, 0.057307053, -0.008900531, -0.019598745, -0.03082626, 0.014591779, 0.06420119, -0.059627317, -0.03732171, 0.016718497, -0.0027331563, 0.013793794, 0.06873449, 0.031878877, -0.025323479, 0.017207827, -0.00025769856, 0.01302832, -0.033877812, 0.1036087, -0.031368185, -0.0062403507, -0.020410763, 0.064998895, -0.049161144, 0.075556606, -0.005309279, 0.024778325, -0.055955246, -0.053952686, 0.04611469, -0.040877238, 0.0366899, 0.05907716, -0.023292458, -0.081198305, 0.078474045, 0.050623402, -0.06233864, 0.07453958, 0.0152983265, -0.04816594, 0.023196025, -0.03438517, -0.024680838, -0.04664079, 0.054698855, 0.0038191404, 0.0024043208, 0.0034349218, -0.03711057, 0.001107596, -0.0028691792, 0.00030419108, 0.037632354, 0.060571946, -0.0946064, 0.042204216, -0.037838906, 0.021439435, -0.076814726, 0.06236704, 0.012242562, -0.061841127, 0.016115433, -0.063648604, 0.025584254, 0.10527214, -0.079565875, 0.008840051, 0.06655628, -0.0051484755, -0.08278825, -0.023478502, 0.0713399, -0.018204115, 0.048147563, -0.12774643, -0.014040633, 0.052833144, 0.0025820592, 0.029898077, 0.09640923, 0.08246072, 0.02947083, -0.015254255, -0.05879318, -0.08034651, -0.03984985, -0.008921548, 0.0035848247, 0.01210673, 0.01669468, -0.011540037, 0.043646365, 0.12930681, 0.028525097, -0.033249676, 0.009854595, 0.020683004, -0.03317388, 0.030189851, -0.037221596, 0.056988247, 0.028217647, -0.09884985, 0.010463105, 0.052619364, -0.025229864, -0.0095943725, -0.0152116455, 0.050259188, 0.04650281, -0.07481224, -0.024553102, -0.00060233194, -0.054850005, 0.024833087, 0.029229235, -0.041785177, -0.07714764, -0.013403594, 0.030718219, 0.015469627, -0.0074155433, -0.02679301, 0.009519983, -0.059538018, -0.008628714, -0.0067284205, 0.010197514, -0.06606767, -0.005759551, -0.0022303548, -0.0028307706, 0.014501192, 0.025007654, 0.02578938, -0.0378708, 0.045471873, 0.046895593, 0.064339206, -0.028388325, 0.060857113, -0.020218765, 0.031644333, 0.0052066315, 0.019141829, 0.056266394, 0.009460299, -0.024507342, -0.007147454, -0.08706694, -0.040379945, 0.044624608, 0.0354123, -0.019891156, -0.07543022, 0.04300264, -0.057571575, -0.008736315, 0.027166944, -0.02620351, -0.06503468, 0.04547514, -0.06995108, 0.023360554, 0.0067407857, -0.07763636, 0.04539317, 0.022868318, -0.010696204, 0.096428476, -0.0098833935, 0.010394665, -0.053308632, -0.07989839, 0.0047803717, -0.008077739, -0.002149282, 0.03329656, 0.031331684, -0.041785568, -0.047738556, -0.06495552, 0.020175837, -0.03115513, -0.06061734, -0.002706623, -0.010334317, 0.00423277, 0.012610406, -0.035930026, 0.016086096, 0.0995368, -0.022022268, 0.0145803625, 0.055138133, -0.05336383, 0.064680666, -0.009677598, -0.054862097, 0.055777773, -0.06849751, -0.022308815, 0.04459878, 0.05018248, 0.07288731, 0.009007135, 0.09244995, -0.120825015, 0.06114768, 0.06042321, -0.007861768, -0.010927538, 0.04720156, 0.04455385, -0.03482649, -0.026552528, 0.043172978, 0.01093146, -0.015799692, 0.002202651, 0.010309535, 0.005310587, -0.11890363, -0.0795878, -0.0003631139, -0.027302552, -0.015855208, -0.018209826, -0.022755314, -0.013153738, 0.04345833, 0.03354373, 0.0105263805, 0.06194301, -0.032513645, 0.096333094, 0.005829615, 0.03347289, -0.07679508, -0.045443438, 0.030386887, -0.05020792, 0.0033663346, 0.05774469, -0.027640222, 0.044374026, 0.00033217962, -0.030820126, 0.05522514, 0.013675768, 0.0069077997, 0.04126497, 0.03151114, 0.02491263, -0.067820564, -0.0103627015, -0.07824549, -0.05266336, 0.013888292, 0.040954925, 0.034307495, -0.06418129, 0.0039767474, 0.024156764, 0.014469209, -0.0018970015, -0.07990409, 0.028226675, -0.026945848, -0.02464125, -0.050481487, 0.05450125, -0.025523432, -0.015445301, 0.0060901823, 0.012443802, 0.04673962, -0.018540293, -0.016265117, -0.031241901, 0.009048211, 0.054158207, -0.048130896, 0.09530002, 0.0099937515, -0.03540203, 0.025122656, -0.0856811, -0.06332409, 0.0068043796, 0.020160854, -0.06262762, 0.038287282, -0.06531139, 0.0063432995, 0.00087177445, -0.007837982, 0.050352592, -0.05995185, 0.063116044, 0.017331842, -0.0021170392, 0.0011423155, -0.023920225, -0.050662033, -0.015922869, -0.028740764},
}
func TestMarkers_Contains(t *testing.T) {
t.Run("Examples", func(t *testing.T) {
m1 := *NewMarker(FileFixtures.Get("exampleFileName.jpg"), cropArea1, "lt9k3pw1wowuy1c1", SrcImage, MarkerFace, 100, 65)
m2 := *NewMarker(FileFixtures.Get("exampleFileName.jpg"), cropArea2, "lt9k3pw1wowuy1c2", SrcImage, MarkerFace, 100, 65)
m3 := *NewMarker(FileFixtures.Get("exampleFileName.jpg"), cropArea3, "lt9k3pw1wowuy1c3", SrcImage, MarkerFace, 100, 65)
assert.Equal(t, 29, m1.OverlapPercent(m2))
assert.Equal(t, 100, m2.OverlapPercent(m1))
m := Markers{m2}
assert.True(t, m.Contains(m1))
assert.False(t, m.Contains(m3))
})
t.Run("Conflicting", func(t *testing.T) {
file := File{FileUID: "", FileHash: "cca7c46a4d39e933c30805e546028fe3eab361b5"}
markers := Markers{
*NewMarker(file, crop.Area{Name: "subj-1", X: 0.549479, Y: 0.179688, W: 0.393229, H: 0.294922}, "jqyzmgbquh1msz6o", SrcImage, MarkerFace, 100, 65),
*NewMarker(file, crop.Area{Name: "subj-2", X: 0.0833333, Y: 0.321289, W: 0.476562, H: 0.357422}, "jqyzml91cf2yyfi7", SrcImage, MarkerFace, 100, 65),
}
conflicting := *NewMarker(file, crop.Area{Name: "subj-2", X: 0.190104, Y: 0.40918, W: 0.31901, H: 0.239258}, "jqyzml91cf2yyfi7", SrcImage, MarkerFace, 100, 65)
assert.True(t, markers.Contains(conflicting))
})
t.Run("SameFace", func(t *testing.T) {
file := File{FileHash: "a6c46e43b83fc02309b1c49e1ed7273f1f414610"}
markers := Markers{
*NewMarker(file, crop.Area{Name: "subj-1", X: 0.388021, Y: 0.365234, W: 0.179688, H: 0.134766}, "jqyzmgbquh1msz6o", SrcImage, MarkerFace, 100, 65),
}
conflicting := *NewMarker(file, crop.Area{Name: "subj-1", X: 0.34375, Y: 0.291992, W: 0.266927, H: 0.200195}, "jqyzmgbquh1msz6o", SrcImage, MarkerFace, 100, 65)
assert.True(t, markers.Contains(conflicting))
})
t.Run("NoFace", func(t *testing.T) {
file := File{FileUID: "fqzuh672i9btq6gu", FileHash: "243cdbe99b865607f98a951e748d528bc22f3143"}
markers := Markers{
*NewMarker(file, crop.Area{Name: "no-face", X: 0.322656, Y: 0.3, W: 0.180469, H: 0.240625}, "jqyzmgbquh1msz6o", SrcImage, MarkerFace, 100, 65),
}
conflicting := *NewMarker(file, crop.Area{Name: "face", X: 0.325, Y: 0.0510417, W: 0.136719, H: 0.182292}, "jqyzmgbquh1msz6o", SrcImage, MarkerFace, 100, 65)
assert.False(t, markers.Contains(conflicting))
})
}
func TestMarkers_DetectedFaceCount(t *testing.T) {
m1 := *NewMarker(FileFixtures.Get("exampleFileName.jpg"), cropArea1, "lt9k3pw1wowuy1c1", SrcImage, MarkerFace, 100, 65)
m2 := *NewMarker(FileFixtures.Get("exampleFileName.jpg"), cropArea4, "lt9k3pw1wowuy1c2", SrcManual, MarkerFace, 100, 65)
m3 := *NewMarker(FileFixtures.Get("exampleFileName.jpg"), cropArea3, "lt9k3pw1wowuy1c3", SrcManual, MarkerFace, 100, 65)
m3.MarkerInvalid = true
m := Markers{m1, m2, m3}
assert.Equal(t, 1, m.DetectedFaceCount())
}
func TestMarkers_ValidFaceCount(t *testing.T) {
m1 := *NewMarker(FileFixtures.Get("exampleFileName.jpg"), cropArea1, "lt9k3pw1wowuy1c1", SrcImage, MarkerFace, 100, 65)
m2 := *NewMarker(FileFixtures.Get("exampleFileName.jpg"), cropArea4, "lt9k3pw1wowuy1c2", SrcManual, MarkerFace, 100, 65)
m3 := *NewMarker(FileFixtures.Get("exampleFileName.jpg"), cropArea3, "lt9k3pw1wowuy1c3", SrcManual, MarkerFace, 100, 65)
m3.MarkerInvalid = true
m := Markers{m1, m2, m3}
assert.Equal(t, 2, m.ValidFaceCount())
}
func TestMarkers_SubjectNames(t *testing.T) {
m1 := MarkerFixtures.Get("1000003-3")
m2 := MarkerFixtures.Get("1000003-4")
m3 := MarkerFixtures.Get("1000003-5")
m1.MarkerInvalid = true
m := Markers{m1, m2, m3}
assert.Equal(t, []string{"Jens Mander", "Corn McCornface"}, m.SubjectNames())
}
func TestMarkers_Labels(t *testing.T) {
t.Run("None", func(t *testing.T) {
m := Markers{}
result := m.Labels()
if len(result) > 0 {
t.Fatalf("unexpected result: %#v", result)
}
})
t.Run("One", func(t *testing.T) {
m1 := *NewMarker(FileFixtures.Get("exampleFileName.jpg"), cropArea1, "lt9k3pw1wowuy1c1", SrcImage, MarkerFace, 100, 12)
m2 := *NewMarker(FileFixtures.Get("exampleFileName.jpg"), cropArea4, "lt9k3pw1wowuy1c2", SrcImage, MarkerFace, 100, 300)
m2.MarkerInvalid = true
m := Markers{m1, m2}
result := m.Labels()
if len(result) == 1 {
t.Logf("labels: %#v", result)
assert.Equal(t, "portrait", result[0].Name)
assert.Equal(t, SrcImage, result[0].Source)
assert.Equal(t, 45, result[0].Uncertainty)
assert.Equal(t, 0, result[0].Priority)
assert.Len(t, result[0].Categories, 1)
if len(result[0].Categories) == 1 {
assert.Equal(t, "people", result[0].Categories[0])
}
} else {
t.Fatalf("unexpected result: %#v", result)
}
})
t.Run("Many", func(t *testing.T) {
m1 := *NewMarker(FileFixtures.Get("exampleFileName.jpg"), cropArea1, "lt9k3pw1wowuy1c1", SrcImage, MarkerFace, 100, 65)
m2 := *NewMarker(FileFixtures.Get("exampleFileName.jpg"), cropArea4, "lt9k3pw1wowuy1c2", SrcImage, MarkerFace, 100, 65)
m3 := *NewMarker(FileFixtures.Get("exampleFileName.jpg"), cropArea3, "lt9k3pw1wowuy1c3", SrcImage, MarkerFace, 100, 65)
m3.MarkerInvalid = true
m := Markers{m1, m2, m3}
result := m.Labels()
if len(result) == 1 {
t.Logf("labels: %#v", result)
assert.Equal(t, "people", result[0].Name)
assert.Equal(t, SrcImage, result[0].Source)
assert.Equal(t, 25, result[0].Uncertainty)
assert.Equal(t, 0, result[0].Priority)
assert.Len(t, result[0].Categories, 0)
} else {
t.Fatalf("unexpected result: %#v", result)
}
})
}
func TestMarkers_AppendWithEmbedding(t *testing.T) {
t.Run("Ok", func(t *testing.T) {
m1 := *NewMarker(FileFixtures.Get("exampleFileName.jpg"), cropArea1, "lt9k3pw1wowuy1c1", SrcImage, MarkerFace, 100, 65)
m2 := *NewMarker(FileFixtures.Get("exampleFileName.jpg"), cropArea3, "lt9k3pw1wowuy1c3", SrcImage, MarkerFace, 100, 65)
m := Markers{m1}
m.AppendWithEmbedding(m2)
assert.Len(t, m, 1)
assert.True(t, m.Contains(m1))
assert.True(t, m.Contains(m1))
assert.False(t, m.Contains(m2))
m2.SetEmbeddings(face.Embeddings{testEmbeddings[0], testEmbeddings[2]})
assert.Len(t, m, 1)
m.AppendWithEmbedding(m2)
assert.Len(t, m, 1)
assert.True(t, m.Contains(m1))
assert.False(t, m.Contains(m2))
m2.SetEmbeddings(face.Embeddings{testEmbeddings[0]})
m.AppendWithEmbedding(m2)
assert.Len(t, m, 2)
assert.True(t, m.Contains(m1))
assert.True(t, m.Contains(m2))
})
}