移除cv,请使用@yizhi/cv包

This commit is contained in:
2025-03-17 12:24:30 +08:00
parent b48d2daffb
commit 6bf7db1f4c
22 changed files with 72 additions and 355 deletions

View File

@ -1,4 +1,4 @@
import { cv } from "../../cv";
import cv from "@yizhi/cv";
import { ImageCropOption, ImageSource, Model } from "../common/model";
import { convertImage } from "../common/processors";
@ -25,8 +25,8 @@ export class GenderAge extends Model {
private async doPredict(image: cv.Mat, option?: GenderAgePredictOption): Promise<GenderAgePredictResult> {
const input = this.input;
const output = this.output;
if (option?.crop) image = image.crop(option.crop.sx, option.crop.sy, option.crop.sw, option.crop.sh);
image = image.resize(input.shape[3], input.shape[2]);
if (option?.crop) image = cv.crop(image, option.crop);
image = cv.resize(image, input.shape[3], input.shape[2]);
const nchwImage = convertImage(image.data, { sourceImageFormat: "bgr", targetColorFormat: "rgb", targetShapeFormat: "nchw", targetNormalize: { mean: [0], std: [1] } });