From 5b45dc7fad3a11a4476f85d48b716862f08d17eb Mon Sep 17 00:00:00 2001 From: qwertyforce Date: Tue, 30 Aug 2022 13:19:44 +0300 Subject: [PATCH] remove formbody; add find_duplicate --- package-lock.json | 43 ++++++++++----------------------- package.json | 1 - server/helpers/image_ops.ts | 4 +-- server/index.ts | 2 -- server/routes/reverse_search.ts | 23 ++++++++++++------ 5 files changed, 30 insertions(+), 43 deletions(-) diff --git a/package-lock.json b/package-lock.json index c8cbe06..5770f89 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,6 @@ "dependencies": { "@fastify/busboy": "^1.1.0", "@fastify/cors": "^8.0.0", - "@fastify/formbody": "^7.0.1", "@fastify/multipart": "^7.1.0", "@fastify/reply-from": "^8.1.0", "@types/node": "^18.0.5", @@ -71,14 +70,6 @@ "fast-json-stringify": "^5.0.0" } }, - "node_modules/@fastify/formbody": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/@fastify/formbody/-/formbody-7.0.1.tgz", - "integrity": "sha512-CY6IfzdtidHbZezyyXv7u9dzmb2Lv92HyOZDqANuFb++5ojsqoqIb8bJz11bSgPK0MDoqww/dH6DxZDMM8N4ng==", - "dependencies": { - "fastify-plugin": "^3.0.0" - } - }, "node_modules/@fastify/multipart": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/@fastify/multipart/-/multipart-7.1.0.tgz", @@ -139,14 +130,6 @@ "node": ">= 0.8" } }, - "node_modules/@fastify/reply-from/node_modules/undici": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.7.0.tgz", - "integrity": "sha512-ORgxwDkiPS+gK2VxE7iyVeR7JliVn5DqhZ4LgQqYLBXsuK+lwOEmnJ66dhvlpLM0tC3fC7eYF1Bti2frbw2eAA==", - "engines": { - "node": ">=12.18" - } - }, "node_modules/@types/json-schema": { "version": "7.0.9", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", @@ -826,6 +809,14 @@ "node": ">=4.2.0" } }, + "node_modules/undici": { + "version": "5.10.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.10.0.tgz", + "integrity": "sha512-c8HsD3IbwmjjbLvoZuRI26TZic+TSEe8FPMLLOkN1AfYRhdjnKBU6yL+IwcSCbdZiX4e5t0lfMDLDCqj4Sq70g==", + "engines": { + "node": ">=12.18" + } + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -913,14 +904,6 @@ "fast-json-stringify": "^5.0.0" } }, - "@fastify/formbody": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/@fastify/formbody/-/formbody-7.0.1.tgz", - "integrity": "sha512-CY6IfzdtidHbZezyyXv7u9dzmb2Lv92HyOZDqANuFb++5ojsqoqIb8bJz11bSgPK0MDoqww/dH6DxZDMM8N4ng==", - "requires": { - "fastify-plugin": "^3.0.0" - } - }, "@fastify/multipart": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/@fastify/multipart/-/multipart-7.1.0.tgz", @@ -971,11 +954,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==" - }, - "undici": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.7.0.tgz", - "integrity": "sha512-ORgxwDkiPS+gK2VxE7iyVeR7JliVn5DqhZ4LgQqYLBXsuK+lwOEmnJ66dhvlpLM0tC3fC7eYF1Bti2frbw2eAA==" } } }, @@ -1502,6 +1480,11 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz", "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==" }, + "undici": { + "version": "5.10.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.10.0.tgz", + "integrity": "sha512-c8HsD3IbwmjjbLvoZuRI26TZic+TSEe8FPMLLOkN1AfYRhdjnKBU6yL+IwcSCbdZiX4e5t0lfMDLDCqj4Sq70g==" + }, "uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", diff --git a/package.json b/package.json index 196470c..def4ef4 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "dependencies": { "@fastify/busboy": "^1.1.0", "@fastify/cors": "^8.0.0", - "@fastify/formbody": "^7.0.1", "@fastify/multipart": "^7.1.0", "@fastify/reply-from": "^8.1.0", "@types/node": "^18.0.5", diff --git a/server/helpers/image_ops.ts b/server/helpers/image_ops.ts index 49d0e39..c88fce1 100644 --- a/server/helpers/image_ops.ts +++ b/server/helpers/image_ops.ts @@ -281,7 +281,7 @@ async function get_similar_images(image: Buffer,find_duplicate:boolean) { if(find_duplicate){ local_features_res = (await local_features_get_similar_images_by_image_buffer({ image: image, k: 5, k_clusters: 15, - knn_min_matches: 1, matching_threshold: 0.8, + knn_min_matches: 4, matching_threshold: 0.8, use_smnn_matching: 1, use_ransac: 1 })).filter((el:any)=>el["matches"]>=8) }else{ @@ -290,7 +290,7 @@ async function get_similar_images(image: Buffer,find_duplicate:boolean) { global_features_get_similar_images_by_image_buffer({ image: image, k: 200 }), local_features_get_similar_images_by_image_buffer({ image: image, k: 200, k_clusters: 10, - knn_min_matches: 1, matching_threshold: 0.8, + knn_min_matches: 4, matching_threshold: 0.8, use_smnn_matching: 1, use_ransac: 1 }), color_get_similar_images_by_image_buffer({ image: image, k: 200 }), diff --git a/server/index.ts b/server/index.ts index 6f69412..265cc47 100644 --- a/server/index.ts +++ b/server/index.ts @@ -1,7 +1,6 @@ import config from './../config/config' import fastifyMultipart from '@fastify/multipart' import fastify from 'fastify' -import formBodyPlugin from '@fastify/formbody' import fastifyReplyFrom from '@fastify/reply-from' import fastifyCors from '@fastify/cors' // import busboy from '@fastify/busboy' @@ -48,7 +47,6 @@ import delete_all_image_features from "./routes/delete_all_image_features" import reverse_search from "./routes/reverse_search" server.register(async function (app) { - app.register(formBodyPlugin) app.register(fastifyMultipart, { attachFieldsToBody: true, limits: { diff --git a/server/routes/reverse_search.ts b/server/routes/reverse_search.ts index fa5c29d..edde634 100644 --- a/server/routes/reverse_search.ts +++ b/server/routes/reverse_search.ts @@ -1,5 +1,5 @@ import { FastifyRequest, FastifyReply } from "fastify" -import { FromSchema } from "json-schema-to-ts"; +import { FromSchema } from "json-schema-to-ts" import image_ops from "./../helpers/image_ops" const body_schema_reverse_search = { type: 'object', @@ -7,13 +7,20 @@ const body_schema_reverse_search = { image: { type: 'object', properties: { - encoding: { type: 'string' }, - filename: { type: 'string' }, - limit: { type: 'boolean' }, - mimetype: { type: 'string' } + encoding: { type: 'string' }, + filename: { type: 'string' }, + limit: { type: 'boolean' }, + mimetype: { type: 'string' } } - }, - find_duplicate: {type: 'string'} + }, + find_duplicate: { + type: 'object', + properties: { + fieildname: { type: 'string' }, + encoding: { type: 'string' }, + value: { type: 'string' } + } + }, }, required: ['image'], } as const; @@ -25,7 +32,7 @@ async function reverse_search(req: FastifyRequest<{ Body: FromSchema