Add Yolo Pose to JS Example (#684)

* add support for yolo pose models

* fix copy
This commit is contained in:
Radamés Ajna
2023-08-30 22:32:57 -07:00
committed by GitHub
parent eaf760a751
commit 9bd486fb96
3 changed files with 117 additions and 23 deletions

View File

@ -1,5 +1,5 @@
//load the candle yolo wasm module
import init, { Model } from "./build/m.js";
import init, { Model, ModelPose } from "./build/m.js";
class Yolo {
static instance = {};
@ -14,7 +14,12 @@ class Yolo {
const modelRes = await fetch(modelURL);
const yoloArrayBuffer = await modelRes.arrayBuffer();
const weightsArrayU8 = new Uint8Array(yoloArrayBuffer);
this.instance[modelID] = new Model(weightsArrayU8, modelSize);
if (/pose/.test(modelID)) {
// if pose model, use ModelPose
this.instance[modelID] = new ModelPose(weightsArrayU8, modelSize);
} else {
this.instance[modelID] = new Model(weightsArrayU8, modelSize);
}
} else {
self.postMessage({ status: "model already loaded" });
}