未来全栈 3 сар өмнө
parent
commit
9275d62743

+ 14 - 8
rag-server/face-feat68/face.service.js

@@ -1,4 +1,4 @@
-const psqlDB = require("./psql.service");
+const psqlDB = require("../psql.service");
 
 class FaceService{
 
@@ -6,26 +6,32 @@ class FaceService{
         limit = limit || 10;
         // cosine_similarity
         let sql = `
-        select "objectId" as id,"photo","createdAt", array_agg(item)::vector(128) <=> $1::vector(128) as cos
+        select "objectId" as id,"title","photo","createdAt", array_agg(item)::vector(128) <=> $1::vector(128) as cos
          from (
           SELECT *, jsonb_array_elements("feat68")::float AS item from (
-            SELECT "objectId","photo","feat68","createdAt"
+            SELECT "objectId","photo","title","feat68","createdAt"
             FROM "FaceReport"
             WHERE "feat68" is not null
             ORDER BY "createdAt" DESC 
-            limit ${limit}
             ) as rt1
           ) as rt
-          GROUP BY "objectId",rt."photo","createdAt"
+          GROUP BY "objectId","title",rt."photo","createdAt"
+          ORDER BY cos limit ${limit};
         `
         let params = [feat68]
-        let result = await psqlDB.any(sql,params)
+        let result
+        try{
+          result = await psqlDB.any(sql,params)
+          console.log(result)
+        }catch(err){
+          console.error(err)
+        }
         // 人物不同 0.08 0.09 0.06 0.059 
         // 人物不同 长相像 0.046 0.045 0.043 0.039
         // 人物相同 仰角/光照有变化 0.03846
         // 人物相同 > 0.0214 0.0188 0.00218 0.038 0.023
-        result = result.filter(item=>item.cos<0.0385 && item.id!=report.id) 
-        result.sort((a,b)=>a.createdAt-b.createdAt)
+        // result = result.filter(item=>item.cos<0.0385 && item.id!=report.id) 
+        // result.sort((a,b)=>a.createdAt-b.createdAt)
         if(result?.length>0){
           console.log(result)
         }

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 6 - 0
rag-server/face-feat68/test.face.js


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 6 - 1124
rag-server/package-lock.json


+ 1 - 1
rag-server/package.json

@@ -9,6 +9,6 @@
   "license": "ISC",
   "description": "",
   "dependencies": {
-    "pg-promise": "^11.10.2",
+    "pg-promise": "^11.10.2"
   }
 }

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно