From 0e975569e5686138e52bdc554b3f0391f42aeead Mon Sep 17 00:00:00 2001
From: IEatChili <nanunguyen99@gmail.com>
Date: Thu, 15 Aug 2024 14:13:02 -0400
Subject: feat: added face recogntion box

---
 src/client/views/collections/collectionFreeForm/ImageLabelBox.tsx | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

(limited to 'src/client/views/collections/collectionFreeForm/ImageLabelBox.tsx')

diff --git a/src/client/views/collections/collectionFreeForm/ImageLabelBox.tsx b/src/client/views/collections/collectionFreeForm/ImageLabelBox.tsx
index af01d6cbc..421b5d0a6 100644
--- a/src/client/views/collections/collectionFreeForm/ImageLabelBox.tsx
+++ b/src/client/views/collections/collectionFreeForm/ImageLabelBox.tsx
@@ -179,6 +179,7 @@ export class ImageLabelBox extends ViewBoxBaseComponent<FieldViewProps>() {
                 const labels = imageInfo.labels.split('\n');
                 labels.forEach(label => {
                     label = label.replace(/^\d+\.\s*|-|\*/, '').trim();
+                    console.log(label);
                     imageInfo.doc[DocData][`${label}`] = true;
                     (imageInfo.doc[DocData].data_labels as List<string>).push(label);
                 });
@@ -198,7 +199,7 @@ export class ImageLabelBox extends ViewBoxBaseComponent<FieldViewProps>() {
             for (let index = 0; index < (doc[DocData].data_labels as List<string>).length; index++) {
                 const label = (doc[DocData].data_labels as List<string>)[index];
                 const embedding = await gptGetEmbedding(label);
-                doc[`data_labels_embedding_${index + 1}`] = new List<number>(embedding);
+                doc[DocData][`data_labels_embedding_${index + 1}`] = new List<number>(embedding);
             }
         }
 
@@ -209,7 +210,7 @@ export class ImageLabelBox extends ViewBoxBaseComponent<FieldViewProps>() {
         // For each image, loop through the labels, and calculate similarity. Associate it with the
         // most similar one.
         this._selectedImages.forEach(doc => {
-            const embedLists = numberRange((doc[DocData].data_labels as List<string>).length).map(n => Array.from(NumListCast(doc[`data_labels_embedding_${n + 1}`])));
+            const embedLists = numberRange((doc[DocData].data_labels as List<string>).length).map(n => Array.from(NumListCast(doc[DocData][`data_labels_embedding_${n + 1}`])));
             const bestEmbedScore = (embedding: Opt<number[]>) => Math.max(...embedLists.map((l, index) => (embedding && similarity(Array.from(embedding), l)!) || 0));
             const {label: mostSimilarLabelCollect} = 
                 this._labelGroups.map(label => ({ label, similarityScore: bestEmbedScore(labelToEmbedding.get(label)) }))
-- 
cgit v1.2.3-70-g09d2

