From f9e6a97c946c4e3b74817646c8528dec3965ba6c Mon Sep 17 00:00:00 2001 From: Hans Date: Tue, 31 Oct 2023 12:23:29 +0800 Subject: [PATCH] Tune scale size --- components/models/ObjectDetection.tsx | 2 +- utils/image.ts | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/components/models/ObjectDetection.tsx b/components/models/ObjectDetection.tsx index 602b8d3..82d1ee1 100644 --- a/components/models/ObjectDetection.tsx +++ b/components/models/ObjectDetection.tsx @@ -39,7 +39,7 @@ export function Interact({ settings: { model }, runPipe }: InteractProps): JSX.E setWIP(true); try { setInput(input); - const data = await getImageData(input); + const data = await getImageData(input, 128); const predicts = await runPipe('object-detection', model, createRawImage(data)); setResults(predicts); } catch {} diff --git a/utils/image.ts b/utils/image.ts index f95fea2..2c66998 100644 --- a/utils/image.ts +++ b/utils/image.ts @@ -1,8 +1,6 @@ import { RawImage } from '@xenova/transformers/src/utils/image'; -const maxSize = 768; - -export async function getImageData(uri: string): global.Image { +export async function getImageData(uri: string, maxSize: number = 512): global.Image { return await new Promise((resolve, reject) => { const image = new Image(); image.onload = () => {