photoprism/internal/query/faces_test.go

226 lines
70 KiB
Go
Raw Normal View History

package query
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/photoprism/photoprism/internal/entity"
"github.com/photoprism/photoprism/internal/face"
)
func TestFaces(t *testing.T) {
t.Run("known", func(t *testing.T) {
results, err := Faces(true, false, false)
if err != nil {
t.Fatal(err)
}
assert.GreaterOrEqual(t, len(results), 1)
for _, val := range results {
assert.IsType(t, entity.Face{}, val)
}
})
t.Run("Hidden", func(t *testing.T) {
results, err := Faces(false, false, true)
if err != nil {
t.Fatal(err)
}
assert.Empty(t, results)
})
t.Run("unmatched", func(t *testing.T) {
results, err := Faces(false, true, false)
if err != nil {
t.Fatal(err)
}
assert.GreaterOrEqual(t, len(results), 1)
for _, val := range results {
assert.IsType(t, entity.Face{}, val)
}
})
}
func TestManuallyAddedFaces(t *testing.T) {
t.Run("Ok", func(t *testing.T) {
results, err := ManuallyAddedFaces(false)
if err != nil {
t.Fatal(err)
}
assert.GreaterOrEqual(t, len(results), 1)
for _, val := range results {
assert.IsType(t, entity.Face{}, val)
}
})
t.Run("Hidden", func(t *testing.T) {
results, err := ManuallyAddedFaces(true)
if err != nil {
t.Fatal(err)
}
assert.Empty(t, results)
})
}
2021-08-19 23:12:51 +02:00
func TestMatchFaceMarkers(t *testing.T) {
const faceFixtureId = "mt9k3pw1wowuy444"
if m, err := MarkerByUID(faceFixtureId); err != nil {
t.Fatal(err)
} else if m == nil {
t.Fatal("marker is nil")
} else {
assert.Empty(t, m.SubjUID)
}
// Reset subj_uid.
if err := Db().Model(&entity.Marker{}).
Where("subj_src = ?", entity.SrcAuto).
Where("subj_uid = ?", "jqu0xs11qekk9jx8").
UpdateColumn("subj_uid", "").Error; err != nil {
t.Fatal(err)
}
2021-08-19 23:12:51 +02:00
affected, err := MatchFaceMarkers()
if err != nil {
t.Fatal(err)
}
assert.Equal(t, int64(2), affected)
if m, err := MarkerByUID(faceFixtureId); err != nil {
t.Fatal(err)
} else if m == nil {
t.Fatal("marker is nil")
} else {
assert.Equal(t, "jqu0xs11qekk9jx8", m.SubjUID)
}
}
func TestRemoveAnonymousFaceClusters(t *testing.T) {
removed, err := RemoveAnonymousFaceClusters()
if err != nil {
t.Fatal(err)
}
2021-08-30 17:20:39 +02:00
assert.Equal(t, int64(2), removed)
}
func TestCountNewFaceMarkers(t *testing.T) {
t.Run("all", func(t *testing.T) {
assert.GreaterOrEqual(t, CountNewFaceMarkers(0, 0), 1)
})
t.Run("score 10", func(t *testing.T) {
assert.GreaterOrEqual(t, CountNewFaceMarkers(0, 10), 1)
})
t.Run("size 160", func(t *testing.T) {
assert.GreaterOrEqual(t, CountNewFaceMarkers(160, 0), 1)
})
t.Run("score 50 and size 160", func(t *testing.T) {
assert.GreaterOrEqual(t, CountNewFaceMarkers(160, 50), 1)
})
}
func TestMergeFaces(t *testing.T) {
t.Run("SameSubjects", func(t *testing.T) {
face1 := entity.NewFace(
"jqynvsf28rhn6b0c",
entity.SrcManual,
face.Embeddings{
face.Embedding{0.10730543085474682, -0.007740289179353713, 0.04013410115400314, 0.01458170011165962, -0.033333988977870946, 0.06636234022813034, -0.00010941258007316575, 0.0266348918046072, -0.05017391628723953, 0.026034562221256254, -0.03388911566430759, -0.03461048494812202, 0.040559725024994844, 0.02683793627304573, -0.00972269717541027, -0.07836494561032105, -0.022470260049817198, 0.011276674801708603, -0.05526434009558201, 0.014401617237932205, -0.031258523568474236, -0.05416104192368187, -0.05567222379755878, 0.017950877029356768, -0.016397424193561935, 0.062346790423413276, -0.019043469394284057, 0.04085343435437774, -0.05627231374819698, 0.002355368169155769, 0.07268979656775187, -0.0015096598716884627, -0.030188596848975374, -0.030941932784964564, -0.02826790015985233, -0.05420075791573048, -0.015742074680253033, 0.019360258910790157, -0.008227027287290193, -0.08797317745792674, -0.07358703463505077, 0.09688007249803735, 0.015168583267354964, -0.034569315837825396, 0.054231690688333986, 0.018033145214487362, 0.01579093209709463, -0.09204238994311237, 0.08645247031890774, -0.10499936100221444, 0.022421303168151857, 0.005288450124515152, -0.017391072021601867, 0.011218363053184624, -0.08478270589438915, 0.0038618527485391615, -0.023381522484070015, -0.05428399272960853, -0.049397680150033, 0.04006855272634697, -0.056704127236808774, -0.00958812557516262, -0.024006645464504622, -0.0073450501057456975, -0.03138197361666756, -0.013765138786817361, 0.01162637563227787, 0.0023935177775817563, 0.08953138773108768, 0.05337418268588829, -0.012870218945196915, 0.03652425150877475, -0.027783526080406188, -0.019489638927241745, -0.01591402705199299, -0.005031992847164803, -0.014592982936285286, -0.03540697236418762, 0.015595597412254449, 0.004689344744109726, -0.009276015175478172, 0.0058068592886232374, 0.10480716412028504, 0.0169216338187767, -0.0159497901004467, 0.04574707649004688, -0.012214007484710122, -0.04849749380776977, 0.054958586523843764, 0.055898306713647844, -0.05052226642217827, 0.008803732924324036, 0.02326267119630642, 0.047305830959801676, 0.04497242295638694, 0.020850376996620942, 0.01314765746152954, -0.06768179592533874, 0.05844347174572754, -0.03379152370001783, 0.009412363744416903, 0.04876727547273407, 0.03299943491180715, 0.01981742466488743, 0.0547951049219265, 0.020208802772381018, -0.08163521584288311, -0.038910958658009524, -0.004049565234655952, -0.02227413252290535, -0.0176418922441086, 0.0568860088455925, -0.03240221023084612, 0.0018760896289435579, -0.03234445138420723, 0.007601825631139565, 0.004916589611196899, -0.07292478312312889, 0.021712048014592936, 0.008807552270011749, 0.0045489283733609, 0.018861112444398878, -0.0341377092368577, -0.06305481604926585, 0.039113288345403674, -0.01390809621003151, -0.04930861238819008, 0.02377057523982868, 0.019087416355893325, -0.013899296822125817, 0.02251690464443226, 0.08074113913260841, -0.018922226267959787, 0.07189693789385795, 0.060660045672045707, -0.023638294307546808, -0.006141792394255906, -0.06662582397409247, -0.013895529799502565, 0.016608829923953898, -0.00390724028582611, 0.05038048671591301, -0.015355035841564064, -0.0008532485082750321, -0.004694504582768126, -0.016610601585741958, 0.008180847821889228, -0.04035771976174698, 0.01847608156922703, 0.08409907464663602, -0.029978496458568385, -0.06499117178372192, 0.07448235046571827, 0.10142187900247382, -0.023405319141915855, 0.05237413796294822, 0.04315940939233541, -0.02349721355909328, 0.012594679585403442, -0.10457832859776592, 0.001468614040066719, 0.0165479676672657, -0.07708675453700256, -0.05102918249748802, 0.045642631412478735, -0.004785828004440499, 0.0203317336356945, -0.02006395174473057, 0.04201285855375195, 0.032883700123707296, 0.0477916040669878, 0.08070634492548084, -0.09245629058029556, 0.05112703265588493, -0.006224603994954872, -0.0005257819460310555, 0.005513055457300567, 0.02521921247766018, 0.012207323409280013, -0.009936333046208725, -0.007426916158089448, 0.027260071572856714, 0.006004036209329835, -0.039462719505699156, 0.04428369084658737, 0.0050210412
face.Embedding{0.20730543085474682, -0.006640289179353713, 0.03013410115400314, 0.01258170011165962, -0.023333988977870946, 0.05536234022813034, -0.00010941258007316575, 0.0266348918046072, -0.05017391628723953, 0.026034562221256254, -0.03388911566430759, -0.03461048494812202, 0.040559725024994844, 0.02683793627304573, -0.00972269717541027, -0.07836494561032105, -0.022470260049817198, 0.011276674801708603, -0.05526434009558201, 0.014401617237932205, -0.031258523568474236, -0.05416104192368187, -0.05567222379755878, 0.017950877029356768, -0.016397424193561935, 0.062346790423413276, -0.019043469394284057, 0.04085343435437774, -0.05627231374819698, 0.002355368169155769, 0.07268979656775187, -0.0015096598716884627, -0.030188596848975374, -0.030941932784964564, -0.02826790015985233, -0.05420075791573048, -0.015742074680253033, 0.019360258910790157, -0.008227027287290193, -0.08797317745792674, -0.07358703463505077, 0.09688007249803735, 0.015168583267354964, -0.034569315837825396, 0.054231690688333986, 0.018033145214487362, 0.01579093209709463, -0.09204238994311237, 0.08645247031890774, -0.10499936100221444, 0.022421303168151857, 0.005288450124515152, -0.017391072021601867, 0.011218363053184624, -0.08478270589438915, 0.0038618527485391615, -0.023381522484070015, -0.05428399272960853, -0.049397680150033, 0.04006855272634697, -0.056704127236808774, -0.00958812557516262, -0.024006645464504622, -0.0073450501057456975, -0.03138197361666756, -0.013765138786817361, 0.01162637563227787, 0.0023935177775817563, 0.08953138773108768, 0.05337418268588829, -0.012870218945196915, 0.03652425150877475, -0.027783526080406188, -0.019489638927241745, -0.01591402705199299, -0.005031992847164803, -0.014592982936285286, -0.03540697236418762, 0.015595597412254449, 0.004689344744109726, -0.009276015175478172, 0.0058068592886232374, 0.10480716412028504, 0.0169216338187767, -0.0159497901004467, 0.04574707649004688, -0.012214007484710122, -0.04849749380776977, 0.054958586523843764, 0.055898306713647844, -0.05052226642217827, 0.008803732924324036, 0.02326267119630642, 0.047305830959801676, 0.04497242295638694, 0.020850376996620942, 0.01314765746152954, -0.06768179592533874, 0.05844347174572754, -0.03379152370001783, 0.009412363744416903, 0.04876727547273407, 0.03299943491180715, 0.01981742466488743, 0.0547951049219265, 0.020208802772381018, -0.08163521584288311, -0.038910958658009524, -0.004049565234655952, -0.02227413252290535, -0.0176418922441086, 0.0568860088455925, -0.03240221023084612, 0.0018760896289435579, -0.03234445138420723, 0.007601825631139565, 0.004916589611196899, -0.07292478312312889, 0.021712048014592936, 0.008807552270011749, 0.0045489283733609, 0.018861112444398878, -0.0341377092368577, -0.06305481604926585, 0.039113288345403674, -0.01390809621003151, -0.04930861238819008, 0.02377057523982868, 0.019087416355893325, -0.013899296822125817, 0.02251690464443226, 0.08074113913260841, -0.018922226267959787, 0.07189693789385795, 0.060660045672045707, -0.023638294307546808, -0.006141792394255906, -0.06662582397409247, -0.013895529799502565, 0.016608829923953898, -0.00390724028582611, 0.05038048671591301, -0.015355035841564064, -0.0008532485082750321, -0.004694504582768126, -0.016610601585741958, 0.008180847821889228, -0.04035771976174698, 0.01847608156922703, 0.08409907464663602, -0.029978496458568385, -0.06499117178372192, 0.07448235046571827, 0.10142187900247382, -0.023405319141915855, 0.05237413796294822, 0.04315940939233541, -0.02349721355909328, 0.012594679585403442, -0.10457832859776592, 0.001468614040066719, 0.0165479676672657, -0.07708675453700256, -0.05102918249748802, 0.045642631412478735, -0.004785828004440499, 0.0203317336356945, -0.02006395174473057, 0.04201285855375195, 0.032883700123707296, 0.0477916040669878, 0.08070634492548084, -0.09245629058029556, 0.05112703265588493, -0.006224603994954872, -0.0005257819460310555, 0.005513055457300567, 0.02521921247766018, 0.012207323409280013, -0.009936333046208725, -0.007426916158089448, 0.027260071572856714, 0.006004036209329835, -0.039462719505699156, 0.04428369084658737, 0.0050210412
},
)
face2 := entity.NewFace(
"jqynvsf28rhn6b0c",
entity.SrcManual,
face.Embeddings{
face.Embedding{0.10230543085474682, -0.007840289179353713, 0.03013410115400314, 0.02458170011165962, -0.033333988977870946, 0.06636234022813034, -0.00010941258007316575, 0.0266348918046072, -0.05017391628723953, 0.026034562221256254, -0.03388911566430759, -0.03461048494812202, 0.040559725024994844, 0.02683793627304573, -0.00972269717541027, -0.07836494561032105, -0.022470260049817198, 0.011276674801708603, -0.05526434009558201, 0.014401617237932205, -0.031258523568474236, -0.05416104192368187, -0.05567222379755878, 0.017950877029356768, -0.016397424193561935, 0.062346790423413276, -0.019043469394284057, 0.04085343435437774, -0.05627231374819698, 0.002355368169155769, 0.07268979656775187, -0.0015096598716884627, -0.030188596848975374, -0.030941932784964564, -0.02826790015985233, -0.05420075791573048, -0.015742074680253033, 0.019360258910790157, -0.008227027287290193, -0.08797317745792674, -0.07358703463505077, 0.09688007249803735, 0.015168583267354964, -0.034569315837825396, 0.054231690688333986, 0.018033145214487362, 0.01579093209709463, -0.09204238994311237, 0.08645247031890774, -0.10499936100221444, 0.022421303168151857, 0.005288450124515152, -0.017391072021601867, 0.011218363053184624, -0.08478270589438915, 0.0038618527485391615, -0.023381522484070015, -0.05428399272960853, -0.049397680150033, 0.04006855272634697, -0.056704127236808774, -0.00958812557516262, -0.024006645464504622, -0.0073450501057456975, -0.03138197361666756, -0.013765138786817361, 0.01162637563227787, 0.0023935177775817563, 0.08953138773108768, 0.05337418268588829, -0.012870218945196915, 0.03652425150877475, -0.027783526080406188, -0.019489638927241745, -0.01591402705199299, -0.005031992847164803, -0.014592982936285286, -0.03540697236418762, 0.015595597412254449, 0.004689344744109726, -0.009276015175478172, 0.0058068592886232374, 0.10480716412028504, 0.0169216338187767, -0.0159497901004467, 0.04574707649004688, -0.012214007484710122, -0.04849749380776977, 0.054958586523843764, 0.055898306713647844, -0.05052226642217827, 0.008803732924324036, 0.02326267119630642, 0.047305830959801676, 0.04497242295638694, 0.020850376996620942, 0.01314765746152954, -0.06768179592533874, 0.05844347174572754, -0.03379152370001783, 0.009412363744416903, 0.04876727547273407, 0.03299943491180715, 0.01981742466488743, 0.0547951049219265, 0.020208802772381018, -0.08163521584288311, -0.038910958658009524, -0.004049565234655952, -0.02227413252290535, -0.0176418922441086, 0.0568860088455925, -0.03240221023084612, 0.0018760896289435579, -0.03234445138420723, 0.007601825631139565, 0.004916589611196899, -0.07292478312312889, 0.021712048014592936, 0.008807552270011749, 0.0045489283733609, 0.018861112444398878, -0.0341377092368577, -0.06305481604926585, 0.039113288345403674, -0.01390809621003151, -0.04930861238819008, 0.02377057523982868, 0.019087416355893325, -0.013899296822125817, 0.02251690464443226, 0.08074113913260841, -0.018922226267959787, 0.07189693789385795, 0.060660045672045707, -0.023638294307546808, -0.006141792394255906, -0.06662582397409247, -0.013895529799502565, 0.016608829923953898, -0.00390724028582611, 0.05038048671591301, -0.015355035841564064, -0.0008532485082750321, -0.004694504582768126, -0.016610601585741958, 0.008180847821889228, -0.04035771976174698, 0.01847608156922703, 0.08409907464663602, -0.029978496458568385, -0.06499117178372192, 0.07448235046571827, 0.10142187900247382, -0.023405319141915855, 0.05237413796294822, 0.04315940939233541, -0.02349721355909328, 0.012594679585403442, -0.10457832859776592, 0.001468614040066719, 0.0165479676672657, -0.07708675453700256, -0.05102918249748802, 0.045642631412478735, -0.004785828004440499, 0.0203317336356945, -0.02006395174473057, 0.04201285855375195, 0.032883700123707296, 0.0477916040669878, 0.08070634492548084, -0.09245629058029556, 0.05112703265588493, -0.006224603994954872, -0.0005257819460310555, 0.005513055457300567, 0.02521921247766018, 0.012207323409280013, -0.009936333046208725, -0.007426916158089448, 0.027260071572856714, 0.006004036209329835, -0.039462719505699156, 0.04428369084658737, 0.0050210412
},
)
if err := face1.Create(); err != nil {
t.Fatal(err)
}
if err := face2.Create(); err != nil {
t.Fatal(err)
}
faces := entity.Faces{*face1, *face2}
result, err := MergeFaces(faces)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, "5LH5E35ZGUMF5AYLM42BIZH4DGQHJDAV", result.ID)
assert.Equal(t, entity.SrcManual, result.FaceSrc)
assert.Equal(t, "jqynvsf28rhn6b0c", result.SubjUID)
assert.Equal(t, 2, result.Samples)
assert.Equal(t, 0.03948165743305488, result.SampleRadius)
assert.Equal(t, 0, result.Collisions)
assert.Equal(t, float64(0), result.CollisionRadius)
// t.Logf("merged: %#v", result)
})
t.Run("AmbiguousSubjects", func(t *testing.T) {
face1 := entity.NewFace(
"jqynvsf28rhn6b0c",
entity.SrcManual,
face.Embeddings{
face.Embedding{0.10730543085474682, -0.007740289179353713, 0.04013410115400314, 0.01458170011165962, -0.033333988977870946, 0.06636234022813034, -0.00010941258007316575, 0.0266348918046072, -0.05017391628723953, 0.026034562221256254, -0.03388911566430759, -0.03461048494812202, 0.040559725024994844, 0.02683793627304573, -0.00972269717541027, -0.07836494561032105, -0.022470260049817198, 0.011276674801708603, -0.05526434009558201, 0.014401617237932205, -0.031258523568474236, -0.05416104192368187, -0.05567222379755878, 0.017950877029356768, -0.016397424193561935, 0.062346790423413276, -0.019043469394284057, 0.04085343435437774, -0.05627231374819698, 0.002355368169155769, 0.07268979656775187, -0.0015096598716884627, -0.030188596848975374, -0.030941932784964564, -0.02826790015985233, -0.05420075791573048, -0.015742074680253033, 0.019360258910790157, -0.008227027287290193, -0.08797317745792674, -0.07358703463505077, 0.09688007249803735, 0.015168583267354964, -0.034569315837825396, 0.054231690688333986, 0.018033145214487362, 0.01579093209709463, -0.09204238994311237, 0.08645247031890774, -0.10499936100221444, 0.022421303168151857, 0.005288450124515152, -0.017391072021601867, 0.011218363053184624, -0.08478270589438915, 0.0038618527485391615, -0.023381522484070015, -0.05428399272960853, -0.049397680150033, 0.04006855272634697, -0.056704127236808774, -0.00958812557516262, -0.024006645464504622, -0.0073450501057456975, -0.03138197361666756, -0.013765138786817361, 0.01162637563227787, 0.0023935177775817563, 0.08953138773108768, 0.05337418268588829, -0.012870218945196915, 0.03652425150877475, -0.027783526080406188, -0.019489638927241745, -0.01591402705199299, -0.005031992847164803, -0.014592982936285286, -0.03540697236418762, 0.015595597412254449, 0.004689344744109726, -0.009276015175478172, 0.0058068592886232374, 0.10480716412028504, 0.0169216338187767, -0.0159497901004467, 0.04574707649004688, -0.012214007484710122, -0.04849749380776977, 0.054958586523843764, 0.055898306713647844, -0.05052226642217827, 0.008803732924324036, 0.02326267119630642, 0.047305830959801676, 0.04497242295638694, 0.020850376996620942, 0.01314765746152954, -0.06768179592533874, 0.05844347174572754, -0.03379152370001783, 0.009412363744416903, 0.04876727547273407, 0.03299943491180715, 0.01981742466488743, 0.0547951049219265, 0.020208802772381018, -0.08163521584288311, -0.038910958658009524, -0.004049565234655952, -0.02227413252290535, -0.0176418922441086, 0.0568860088455925, -0.03240221023084612, 0.0018760896289435579, -0.03234445138420723, 0.007601825631139565, 0.004916589611196899, -0.07292478312312889, 0.021712048014592936, 0.008807552270011749, 0.0045489283733609, 0.018861112444398878, -0.0341377092368577, -0.06305481604926585, 0.039113288345403674, -0.01390809621003151, -0.04930861238819008, 0.02377057523982868, 0.019087416355893325, -0.013899296822125817, 0.02251690464443226, 0.08074113913260841, -0.018922226267959787, 0.07189693789385795, 0.060660045672045707, -0.023638294307546808, -0.006141792394255906, -0.06662582397409247, -0.013895529799502565, 0.016608829923953898, -0.00390724028582611, 0.05038048671591301, -0.015355035841564064, -0.0008532485082750321, -0.004694504582768126, -0.016610601585741958, 0.008180847821889228, -0.04035771976174698, 0.01847608156922703, 0.08409907464663602, -0.029978496458568385, -0.06499117178372192, 0.07448235046571827, 0.10142187900247382, -0.023405319141915855, 0.05237413796294822, 0.04315940939233541, -0.02349721355909328, 0.012594679585403442, -0.10457832859776592, 0.001468614040066719, 0.0165479676672657, -0.07708675453700256, -0.05102918249748802, 0.045642631412478735, -0.004785828004440499, 0.0203317336356945, -0.02006395174473057, 0.04201285855375195, 0.032883700123707296, 0.0477916040669878, 0.08070634492548084, -0.09245629058029556, 0.05112703265588493, -0.006224603994954872, -0.0005257819460310555, 0.005513055457300567, 0.02521921247766018, 0.012207323409280013, -0.009936333046208725, -0.007426916158089448, 0.027260071572856714, 0.006004036209329835, -0.039462719505699156, 0.04428369084658737, 0.0050210412
face.Embedding{0.20730543085474682, -0.006640289179353713, 0.03013410115400314, 0.01258170011165962, -0.023333988977870946, 0.05536234022813034, -0.00010941258007316575, 0.0266348918046072, -0.05017391628723953, 0.026034562221256254, -0.03388911566430759, -0.03461048494812202, 0.040559725024994844, 0.02683793627304573, -0.00972269717541027, -0.07836494561032105, -0.022470260049817198, 0.011276674801708603, -0.05526434009558201, 0.014401617237932205, -0.031258523568474236, -0.05416104192368187, -0.05567222379755878, 0.017950877029356768, -0.016397424193561935, 0.062346790423413276, -0.019043469394284057, 0.04085343435437774, -0.05627231374819698, 0.002355368169155769, 0.07268979656775187, -0.0015096598716884627, -0.030188596848975374, -0.030941932784964564, -0.02826790015985233, -0.05420075791573048, -0.015742074680253033, 0.019360258910790157, -0.008227027287290193, -0.08797317745792674, -0.07358703463505077, 0.09688007249803735, 0.015168583267354964, -0.034569315837825396, 0.054231690688333986, 0.018033145214487362, 0.01579093209709463, -0.09204238994311237, 0.08645247031890774, -0.10499936100221444, 0.022421303168151857, 0.005288450124515152, -0.017391072021601867, 0.011218363053184624, -0.08478270589438915, 0.0038618527485391615, -0.023381522484070015, -0.05428399272960853, -0.049397680150033, 0.04006855272634697, -0.056704127236808774, -0.00958812557516262, -0.024006645464504622, -0.0073450501057456975, -0.03138197361666756, -0.013765138786817361, 0.01162637563227787, 0.0023935177775817563, 0.08953138773108768, 0.05337418268588829, -0.012870218945196915, 0.03652425150877475, -0.027783526080406188, -0.019489638927241745, -0.01591402705199299, -0.005031992847164803, -0.014592982936285286, -0.03540697236418762, 0.015595597412254449, 0.004689344744109726, -0.009276015175478172, 0.0058068592886232374, 0.10480716412028504, 0.0169216338187767, -0.0159497901004467, 0.04574707649004688, -0.012214007484710122, -0.04849749380776977, 0.054958586523843764, 0.055898306713647844, -0.05052226642217827, 0.008803732924324036, 0.02326267119630642, 0.047305830959801676, 0.04497242295638694, 0.020850376996620942, 0.01314765746152954, -0.06768179592533874, 0.05844347174572754, -0.03379152370001783, 0.009412363744416903, 0.04876727547273407, 0.03299943491180715, 0.01981742466488743, 0.0547951049219265, 0.020208802772381018, -0.08163521584288311, -0.038910958658009524, -0.004049565234655952, -0.02227413252290535, -0.0176418922441086, 0.0568860088455925, -0.03240221023084612, 0.0018760896289435579, -0.03234445138420723, 0.007601825631139565, 0.004916589611196899, -0.07292478312312889, 0.021712048014592936, 0.008807552270011749, 0.0045489283733609, 0.018861112444398878, -0.0341377092368577, -0.06305481604926585, 0.039113288345403674, -0.01390809621003151, -0.04930861238819008, 0.02377057523982868, 0.019087416355893325, -0.013899296822125817, 0.02251690464443226, 0.08074113913260841, -0.018922226267959787, 0.07189693789385795, 0.060660045672045707, -0.023638294307546808, -0.006141792394255906, -0.06662582397409247, -0.013895529799502565, 0.016608829923953898, -0.00390724028582611, 0.05038048671591301, -0.015355035841564064, -0.0008532485082750321, -0.004694504582768126, -0.016610601585741958, 0.008180847821889228, -0.04035771976174698, 0.01847608156922703, 0.08409907464663602, -0.029978496458568385, -0.06499117178372192, 0.07448235046571827, 0.10142187900247382, -0.023405319141915855, 0.05237413796294822, 0.04315940939233541, -0.02349721355909328, 0.012594679585403442, -0.10457832859776592, 0.001468614040066719, 0.0165479676672657, -0.07708675453700256, -0.05102918249748802, 0.045642631412478735, -0.004785828004440499, 0.0203317336356945, -0.02006395174473057, 0.04201285855375195, 0.032883700123707296, 0.0477916040669878, 0.08070634492548084, -0.09245629058029556, 0.05112703265588493, -0.006224603994954872, -0.0005257819460310555, 0.005513055457300567, 0.02521921247766018, 0.012207323409280013, -0.009936333046208725, -0.007426916158089448, 0.027260071572856714, 0.006004036209329835, -0.039462719505699156, 0.04428369084658737, 0.0050210412
},
)
face2 := entity.NewFace(
"jqynvt925h8c1asv",
entity.SrcManual,
face.Embeddings{
face.Embedding{0.10230543085474682, -0.007840289179353713, 0.03013410115400314, 0.02458170011165962, -0.033333988977870946, 0.06636234022813034, -0.00010941258007316575, 0.0266348918046072, -0.05017391628723953, 0.026034562221256254, -0.03388911566430759, -0.03461048494812202, 0.040559725024994844, 0.02683793627304573, -0.00972269717541027, -0.07836494561032105, -0.022470260049817198, 0.011276674801708603, -0.05526434009558201, 0.014401617237932205, -0.031258523568474236, -0.05416104192368187, -0.05567222379755878, 0.017950877029356768, -0.016397424193561935, 0.062346790423413276, -0.019043469394284057, 0.04085343435437774, -0.05627231374819698, 0.002355368169155769, 0.07268979656775187, -0.0015096598716884627, -0.030188596848975374, -0.030941932784964564, -0.02826790015985233, -0.05420075791573048, -0.015742074680253033, 0.019360258910790157, -0.008227027287290193, -0.08797317745792674, -0.07358703463505077, 0.09688007249803735, 0.015168583267354964, -0.034569315837825396, 0.054231690688333986, 0.018033145214487362, 0.01579093209709463, -0.09204238994311237, 0.08645247031890774, -0.10499936100221444, 0.022421303168151857, 0.005288450124515152, -0.017391072021601867, 0.011218363053184624, -0.08478270589438915, 0.0038618527485391615, -0.023381522484070015, -0.05428399272960853, -0.049397680150033, 0.04006855272634697, -0.056704127236808774, -0.00958812557516262, -0.024006645464504622, -0.0073450501057456975, -0.03138197361666756, -0.013765138786817361, 0.01162637563227787, 0.0023935177775817563, 0.08953138773108768, 0.05337418268588829, -0.012870218945196915, 0.03652425150877475, -0.027783526080406188, -0.019489638927241745, -0.01591402705199299, -0.005031992847164803, -0.014592982936285286, -0.03540697236418762, 0.015595597412254449, 0.004689344744109726, -0.009276015175478172, 0.0058068592886232374, 0.10480716412028504, 0.0169216338187767, -0.0159497901004467, 0.04574707649004688, -0.012214007484710122, -0.04849749380776977, 0.054958586523843764, 0.055898306713647844, -0.05052226642217827, 0.008803732924324036, 0.02326267119630642, 0.047305830959801676, 0.04497242295638694, 0.020850376996620942, 0.01314765746152954, -0.06768179592533874, 0.05844347174572754, -0.03379152370001783, 0.009412363744416903, 0.04876727547273407, 0.03299943491180715, 0.01981742466488743, 0.0547951049219265, 0.020208802772381018, -0.08163521584288311, -0.038910958658009524, -0.004049565234655952, -0.02227413252290535, -0.0176418922441086, 0.0568860088455925, -0.03240221023084612, 0.0018760896289435579, -0.03234445138420723, 0.007601825631139565, 0.004916589611196899, -0.07292478312312889, 0.021712048014592936, 0.008807552270011749, 0.0045489283733609, 0.018861112444398878, -0.0341377092368577, -0.06305481604926585, 0.039113288345403674, -0.01390809621003151, -0.04930861238819008, 0.02377057523982868, 0.019087416355893325, -0.013899296822125817, 0.02251690464443226, 0.08074113913260841, -0.018922226267959787, 0.07189693789385795, 0.060660045672045707, -0.023638294307546808, -0.006141792394255906, -0.06662582397409247, -0.013895529799502565, 0.016608829923953898, -0.00390724028582611, 0.05038048671591301, -0.015355035841564064, -0.0008532485082750321, -0.004694504582768126, -0.016610601585741958, 0.008180847821889228, -0.04035771976174698, 0.01847608156922703, 0.08409907464663602, -0.029978496458568385, -0.06499117178372192, 0.07448235046571827, 0.10142187900247382, -0.023405319141915855, 0.05237413796294822, 0.04315940939233541, -0.02349721355909328, 0.012594679585403442, -0.10457832859776592, 0.001468614040066719, 0.0165479676672657, -0.07708675453700256, -0.05102918249748802, 0.045642631412478735, -0.004785828004440499, 0.0203317336356945, -0.02006395174473057, 0.04201285855375195, 0.032883700123707296, 0.0477916040669878, 0.08070634492548084, -0.09245629058029556, 0.05112703265588493, -0.006224603994954872, -0.0005257819460310555, 0.005513055457300567, 0.02521921247766018, 0.012207323409280013, -0.009936333046208725, -0.007426916158089448, 0.027260071572856714, 0.006004036209329835, -0.039462719505699156, 0.04428369084658737, 0.0050210412
},
)
faces := entity.Faces{*face1, *face2}
result, err := MergeFaces(faces)
assert.EqualError(t, err, "faces: can't merge clusters with conflicting subjects jqynvsf28rhn6b0c <> jqynvt925h8c1asv")
assert.Nil(t, result)
})
t.Run("OneSubject", func(t *testing.T) {
result, err := MergeFaces(entity.Faces{entity.Face{ID: "5LH5E35ZGUMF5AYLM42BIZH4DGQHJDAV"}})
assert.EqualError(t, err, "faces: two or more clusters required for merging")
assert.Nil(t, result)
})
}
func TestResolveFaceCollisions(t *testing.T) {
c, r, err := ResolveFaceCollisions()
if err != nil {
t.Fatal(err)
}
assert.LessOrEqual(t, 3, c)
assert.LessOrEqual(t, 3, r)
}