remove formbody; add find_duplicate
parent
a710115c10
commit
5b45dc7fad
|
@ -11,7 +11,6 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/busboy": "^1.1.0",
|
"@fastify/busboy": "^1.1.0",
|
||||||
"@fastify/cors": "^8.0.0",
|
"@fastify/cors": "^8.0.0",
|
||||||
"@fastify/formbody": "^7.0.1",
|
|
||||||
"@fastify/multipart": "^7.1.0",
|
"@fastify/multipart": "^7.1.0",
|
||||||
"@fastify/reply-from": "^8.1.0",
|
"@fastify/reply-from": "^8.1.0",
|
||||||
"@types/node": "^18.0.5",
|
"@types/node": "^18.0.5",
|
||||||
|
@ -71,14 +70,6 @@
|
||||||
"fast-json-stringify": "^5.0.0"
|
"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": {
|
"node_modules/@fastify/multipart": {
|
||||||
"version": "7.1.0",
|
"version": "7.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@fastify/multipart/-/multipart-7.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@fastify/multipart/-/multipart-7.1.0.tgz",
|
||||||
|
@ -139,14 +130,6 @@
|
||||||
"node": ">= 0.8"
|
"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": {
|
"node_modules/@types/json-schema": {
|
||||||
"version": "7.0.9",
|
"version": "7.0.9",
|
||||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz",
|
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz",
|
||||||
|
@ -826,6 +809,14 @@
|
||||||
"node": ">=4.2.0"
|
"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": {
|
"node_modules/uri-js": {
|
||||||
"version": "4.4.1",
|
"version": "4.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
||||||
|
@ -913,14 +904,6 @@
|
||||||
"fast-json-stringify": "^5.0.0"
|
"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": {
|
"@fastify/multipart": {
|
||||||
"version": "7.1.0",
|
"version": "7.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@fastify/multipart/-/multipart-7.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@fastify/multipart/-/multipart-7.1.0.tgz",
|
||||||
|
@ -971,11 +954,6 @@
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
|
||||||
"integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ=="
|
"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",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz",
|
||||||
"integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ=="
|
"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": {
|
"uri-js": {
|
||||||
"version": "4.4.1",
|
"version": "4.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/busboy": "^1.1.0",
|
"@fastify/busboy": "^1.1.0",
|
||||||
"@fastify/cors": "^8.0.0",
|
"@fastify/cors": "^8.0.0",
|
||||||
"@fastify/formbody": "^7.0.1",
|
|
||||||
"@fastify/multipart": "^7.1.0",
|
"@fastify/multipart": "^7.1.0",
|
||||||
"@fastify/reply-from": "^8.1.0",
|
"@fastify/reply-from": "^8.1.0",
|
||||||
"@types/node": "^18.0.5",
|
"@types/node": "^18.0.5",
|
||||||
|
|
|
@ -281,7 +281,7 @@ async function get_similar_images(image: Buffer,find_duplicate:boolean) {
|
||||||
if(find_duplicate){
|
if(find_duplicate){
|
||||||
local_features_res = (await local_features_get_similar_images_by_image_buffer({
|
local_features_res = (await local_features_get_similar_images_by_image_buffer({
|
||||||
image: image, k: 5, k_clusters: 15,
|
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
|
use_smnn_matching: 1, use_ransac: 1
|
||||||
})).filter((el:any)=>el["matches"]>=8)
|
})).filter((el:any)=>el["matches"]>=8)
|
||||||
}else{
|
}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 }),
|
global_features_get_similar_images_by_image_buffer({ image: image, k: 200 }),
|
||||||
local_features_get_similar_images_by_image_buffer({
|
local_features_get_similar_images_by_image_buffer({
|
||||||
image: image, k: 200, k_clusters: 10,
|
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
|
use_smnn_matching: 1, use_ransac: 1
|
||||||
}),
|
}),
|
||||||
color_get_similar_images_by_image_buffer({ image: image, k: 200 }),
|
color_get_similar_images_by_image_buffer({ image: image, k: 200 }),
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import config from './../config/config'
|
import config from './../config/config'
|
||||||
import fastifyMultipart from '@fastify/multipart'
|
import fastifyMultipart from '@fastify/multipart'
|
||||||
import fastify from 'fastify'
|
import fastify from 'fastify'
|
||||||
import formBodyPlugin from '@fastify/formbody'
|
|
||||||
import fastifyReplyFrom from '@fastify/reply-from'
|
import fastifyReplyFrom from '@fastify/reply-from'
|
||||||
import fastifyCors from '@fastify/cors'
|
import fastifyCors from '@fastify/cors'
|
||||||
// import busboy from '@fastify/busboy'
|
// 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"
|
import reverse_search from "./routes/reverse_search"
|
||||||
|
|
||||||
server.register(async function (app) {
|
server.register(async function (app) {
|
||||||
app.register(formBodyPlugin)
|
|
||||||
app.register(fastifyMultipart, {
|
app.register(fastifyMultipart, {
|
||||||
attachFieldsToBody: true,
|
attachFieldsToBody: true,
|
||||||
limits: {
|
limits: {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { FastifyRequest, FastifyReply } from "fastify"
|
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"
|
import image_ops from "./../helpers/image_ops"
|
||||||
const body_schema_reverse_search = {
|
const body_schema_reverse_search = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
|
@ -7,13 +7,20 @@ const body_schema_reverse_search = {
|
||||||
image: {
|
image: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
encoding: { type: 'string' },
|
encoding: { type: 'string' },
|
||||||
filename: { type: 'string' },
|
filename: { type: 'string' },
|
||||||
limit: { type: 'boolean' },
|
limit: { type: 'boolean' },
|
||||||
mimetype: { type: 'string' }
|
mimetype: { type: 'string' }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
find_duplicate: {type: 'string'}
|
find_duplicate: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
fieildname: { type: 'string' },
|
||||||
|
encoding: { type: 'string' },
|
||||||
|
value: { type: 'string' }
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
required: ['image'],
|
required: ['image'],
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -25,7 +32,7 @@ async function reverse_search(req: FastifyRequest<{ Body: FromSchema<typeof body
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return res.status(500).send()
|
return res.status(500).send()
|
||||||
}
|
}
|
||||||
const results = await image_ops.get_similar_images(image_buffer,Boolean(parseInt(req.body?.find_duplicate||"0")))
|
const results = await image_ops.get_similar_images(image_buffer, Boolean(parseInt(req.body?.find_duplicate?.value || "0")))
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue