rtmlib-ts 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -1
- package/.gitattributes +0 -1
- package/docs/ANIMAL_DETECTOR.md +0 -450
- package/docs/CUSTOM_DETECTOR.md +0 -568
- package/docs/OBJECT_DETECTOR.md +0 -373
- package/docs/POSE3D_DETECTOR.md +0 -458
- package/docs/POSE_DETECTOR.md +0 -442
- package/examples/README.md +0 -119
- package/examples/index.html +0 -746
- package/playground/README.md +0 -114
- package/playground/app/favicon.ico +0 -0
- package/playground/app/globals.css +0 -17
- package/playground/app/layout.tsx +0 -19
- package/playground/app/page.tsx +0 -1338
- package/playground/eslint.config.mjs +0 -18
- package/playground/next.config.ts +0 -34
- package/playground/package-lock.json +0 -6723
- package/playground/package.json +0 -27
- package/playground/postcss.config.mjs +0 -7
- package/playground/tsconfig.json +0 -34
- package/src/core/base.ts +0 -66
- package/src/core/file.ts +0 -141
- package/src/core/modelCache.ts +0 -189
- package/src/core/posePostprocessing.ts +0 -91
- package/src/core/postprocessing.ts +0 -93
- package/src/core/preprocessing.ts +0 -127
- package/src/index.ts +0 -69
- package/src/models/rtmpose.ts +0 -265
- package/src/models/rtmpose3d.ts +0 -289
- package/src/models/yolo12.ts +0 -220
- package/src/models/yolox.ts +0 -214
- package/src/solution/animalDetector.ts +0 -955
- package/src/solution/body.ts +0 -89
- package/src/solution/bodyWithFeet.ts +0 -89
- package/src/solution/customDetector.ts +0 -474
- package/src/solution/hand.ts +0 -52
- package/src/solution/index.ts +0 -10
- package/src/solution/objectDetector.ts +0 -816
- package/src/solution/pose3dDetector.ts +0 -890
- package/src/solution/poseDetector.ts +0 -892
- package/src/solution/poseTracker.ts +0 -172
- package/src/solution/wholebody.ts +0 -130
- package/src/solution/wholebody3d.ts +0 -125
- package/src/types/index.ts +0 -62
- package/src/visualization/draw.ts +0 -543
- package/src/visualization/skeleton/coco133.ts +0 -131
- package/src/visualization/skeleton/coco17.ts +0 -49
- package/src/visualization/skeleton/halpe26.ts +0 -71
- package/src/visualization/skeleton/hand21.ts +0 -52
- package/src/visualization/skeleton/index.ts +0 -10
- package/src/visualization/skeleton/openpose134.ts +0 -125
- package/src/visualization/skeleton/openpose18.ts +0 -48
- package/tsconfig.json +0 -32
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rtmlib-ts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "High-performance browser-based AI library for real-time object detection (YOLO12) and pose estimation (RTMW) using ONNX Runtime Web",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"playground": "npm i && cd playground && npm run build"
|
|
12
12
|
|
|
13
13
|
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
14
17
|
"keywords": [
|
|
15
18
|
"pose-estimation",
|
|
16
19
|
"rtmpose",
|
package/.gitattributes
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"models/rtmpose/end2end.onnx" filter=lfs diff=lfs merge=lfs -text
|
package/docs/ANIMAL_DETECTOR.md
DELETED
|
@@ -1,450 +0,0 @@
|
|
|
1
|
-
# AnimalDetector API
|
|
2
|
-
|
|
3
|
-
Animal detection and pose estimation API supporting 30 animal species.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
`AnimalDetector` combines object detection with pose estimation specifically designed for animals. It supports 30 different animal species and provides both bounding box detection and 17 keypoints pose estimation (COCO format).
|
|
8
|
-
|
|
9
|
-
## Installation
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm install rtmlib-ts
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Quick Start
|
|
16
|
-
|
|
17
|
-
### Basic Usage
|
|
18
|
-
|
|
19
|
-
```typescript
|
|
20
|
-
import { AnimalDetector } from 'rtmlib-ts';
|
|
21
|
-
|
|
22
|
-
// Initialize with default models
|
|
23
|
-
const detector = new AnimalDetector();
|
|
24
|
-
await detector.init();
|
|
25
|
-
|
|
26
|
-
// Detect animals
|
|
27
|
-
const animals = await detector.detectFromCanvas(canvas);
|
|
28
|
-
console.log(`Found ${animals.length} animals`);
|
|
29
|
-
|
|
30
|
-
animals.forEach(animal => {
|
|
31
|
-
console.log(`${animal.className}: ${animal.bbox.confidence * 100}%`);
|
|
32
|
-
});
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### Detect Specific Animals
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
const detector = new AnimalDetector({
|
|
39
|
-
classes: ['dog', 'cat', 'horse'], // Only detect these
|
|
40
|
-
});
|
|
41
|
-
await detector.init();
|
|
42
|
-
|
|
43
|
-
const animals = await detector.detectFromCanvas(canvas);
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### From Video
|
|
47
|
-
|
|
48
|
-
```typescript
|
|
49
|
-
const video = document.getElementById('video') as HTMLVideoElement;
|
|
50
|
-
|
|
51
|
-
video.addEventListener('play', async () => {
|
|
52
|
-
while (!video.paused && !video.ended) {
|
|
53
|
-
const animals = await detector.detectFromVideo(video);
|
|
54
|
-
|
|
55
|
-
animals.forEach(animal => {
|
|
56
|
-
console.log(`${animal.className} detected`);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
await new Promise(resolve => requestAnimationFrame(resolve));
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Supported Animal Classes
|
|
65
|
-
|
|
66
|
-
| ID | Class | ID | Class |
|
|
67
|
-
|----|-------|----|-------|
|
|
68
|
-
| 0 | gorilla | 15 | polar-bear |
|
|
69
|
-
| 1 | spider-monkey | 16 | antelope |
|
|
70
|
-
| 2 | howling-monkey | 17 | fox |
|
|
71
|
-
| 3 | zebra | 18 | buffalo |
|
|
72
|
-
| 4 | elephant | 19 | cow |
|
|
73
|
-
| 5 | hippo | 20 | wolf |
|
|
74
|
-
| 6 | raccon | 21 | dog |
|
|
75
|
-
| 7 | rhino | 22 | sheep |
|
|
76
|
-
| 8 | giraffe | 23 | cat |
|
|
77
|
-
| 9 | tiger | 24 | horse |
|
|
78
|
-
| 10 | deer | 25 | rabbit |
|
|
79
|
-
| 11 | lion | 26 | pig |
|
|
80
|
-
| 12 | panda | 27 | chimpanzee |
|
|
81
|
-
| 13 | cheetah | 28 | monkey |
|
|
82
|
-
| 14 | black-bear | 29 | orangutan |
|
|
83
|
-
|
|
84
|
-
## API Reference
|
|
85
|
-
|
|
86
|
-
### Constructor
|
|
87
|
-
|
|
88
|
-
```typescript
|
|
89
|
-
new AnimalDetector(config?: AnimalDetectorConfig)
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
**Configuration Options:**
|
|
93
|
-
|
|
94
|
-
| Option | Type | Default | Description |
|
|
95
|
-
|--------|------|---------|-------------|
|
|
96
|
-
| `detModel` | `string` | optional | Path to detection model |
|
|
97
|
-
| `poseModel` | `string` | optional | Path to pose model |
|
|
98
|
-
| `detInputSize` | `[number, number]` | `[640, 640]` | Detection input size |
|
|
99
|
-
| `poseInputSize` | `[number, number]` | `[256, 192]` | Pose input size |
|
|
100
|
-
| `detConfidence` | `number` | `0.5` | Detection confidence threshold |
|
|
101
|
-
| `nmsThreshold` | `number` | `0.45` | NMS IoU threshold |
|
|
102
|
-
| `poseConfidence` | `number` | `0.3` | Keypoint visibility threshold |
|
|
103
|
-
| `backend` | `'wasm' \| 'webgpu'` | `'wasm'` | Execution backend |
|
|
104
|
-
| `cache` | `boolean` | `true` | Enable model caching |
|
|
105
|
-
| `classes` | `string[] \| null` | `null` | Animal classes to detect |
|
|
106
|
-
|
|
107
|
-
### Default Models
|
|
108
|
-
|
|
109
|
-
If models are not specified, the following defaults are used:
|
|
110
|
-
|
|
111
|
-
- **Detector**: `https://huggingface.co/demon2233/rtmlib-ts/resolve/main/yolo/yolov12n.onnx`
|
|
112
|
-
- **Pose**: `https://huggingface.co/JunkyByte/easy_ViTPose/resolve/main/onnx/apt36k/vitpose-b-apt36k.onnx` (ViTPose++-b)
|
|
113
|
-
|
|
114
|
-
### Available Pose Models
|
|
115
|
-
|
|
116
|
-
| Model | Input Size | AP (AP10K) | URL |
|
|
117
|
-
|-------|------------|------------|-----|
|
|
118
|
-
| ViTPose++-s | 256×192 | 74.2 | [vitpose-s-apt36k.onnx](https://huggingface.co/JunkyByte/easy_ViTPose/resolve/main/onnx/apt36k/vitpose-s-apt36k.onnx) |
|
|
119
|
-
| ViTPose++-b | 256×192 | 75.9 | [vitpose-b-apt36k.onnx](https://huggingface.co/JunkyByte/easy_ViTPose/resolve/main/onnx/apt36k/vitpose-b-apt36k.onnx) |
|
|
120
|
-
| ViTPose++-l | 256×192 | 80.8 | [vitpose-h-apt36k.onnx](https://huggingface.co/JunkyByte/easy_ViTPose/resolve/main/onnx/apt36k/vitpose-h-apt36k.onnx) |
|
|
121
|
-
|
|
122
|
-
All ViTPose++ models are trained on 6 datasets and support the 30 animal classes.
|
|
123
|
-
|
|
124
|
-
### Methods
|
|
125
|
-
|
|
126
|
-
#### `init()`
|
|
127
|
-
|
|
128
|
-
Initialize both detection and pose models.
|
|
129
|
-
|
|
130
|
-
```typescript
|
|
131
|
-
await detector.init();
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
#### `detectFromCanvas()`
|
|
135
|
-
|
|
136
|
-
Detect animals from HTMLCanvasElement.
|
|
137
|
-
|
|
138
|
-
```typescript
|
|
139
|
-
async detectFromCanvas(canvas: HTMLCanvasElement): Promise<DetectedAnimal[]>
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
#### `detectFromVideo()`
|
|
143
|
-
|
|
144
|
-
Detect animals from HTMLVideoElement.
|
|
145
|
-
|
|
146
|
-
```typescript
|
|
147
|
-
async detectFromVideo(
|
|
148
|
-
video: HTMLVideoElement,
|
|
149
|
-
targetCanvas?: HTMLCanvasElement
|
|
150
|
-
): Promise<DetectedAnimal[]>
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
#### `detectFromImage()`
|
|
154
|
-
|
|
155
|
-
Detect animals from HTMLImageElement.
|
|
156
|
-
|
|
157
|
-
```typescript
|
|
158
|
-
async detectFromImage(
|
|
159
|
-
image: HTMLImageElement,
|
|
160
|
-
targetCanvas?: HTMLCanvasElement
|
|
161
|
-
): Promise<DetectedAnimal[]>
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
#### `detectFromFile()`
|
|
165
|
-
|
|
166
|
-
Detect animals from File object.
|
|
167
|
-
|
|
168
|
-
```typescript
|
|
169
|
-
async detectFromFile(
|
|
170
|
-
file: File,
|
|
171
|
-
targetCanvas?: HTMLCanvasElement
|
|
172
|
-
): Promise<DetectedAnimal[]>
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
#### `detectFromBlob()`
|
|
176
|
-
|
|
177
|
-
Detect animals from Blob.
|
|
178
|
-
|
|
179
|
-
```typescript
|
|
180
|
-
async detectFromBlob(
|
|
181
|
-
blob: Blob,
|
|
182
|
-
targetCanvas?: HTMLCanvasElement
|
|
183
|
-
): Promise<DetectedAnimal[]>
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
#### `setClasses()`
|
|
187
|
-
|
|
188
|
-
Set which animal classes to detect.
|
|
189
|
-
|
|
190
|
-
```typescript
|
|
191
|
-
detector.setClasses(['dog', 'cat', 'horse']);
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
#### `getAvailableClasses()`
|
|
195
|
-
|
|
196
|
-
Get list of all supported animal classes.
|
|
197
|
-
|
|
198
|
-
```typescript
|
|
199
|
-
const classes = detector.getAvailableClasses();
|
|
200
|
-
console.log(classes); // ['gorilla', 'spider-monkey', ...]
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
#### `dispose()`
|
|
204
|
-
|
|
205
|
-
Release resources.
|
|
206
|
-
|
|
207
|
-
```typescript
|
|
208
|
-
detector.dispose();
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
### Types
|
|
212
|
-
|
|
213
|
-
#### `DetectedAnimal`
|
|
214
|
-
|
|
215
|
-
```typescript
|
|
216
|
-
interface DetectedAnimal {
|
|
217
|
-
bbox: {
|
|
218
|
-
x1: number;
|
|
219
|
-
y1: number;
|
|
220
|
-
x2: number;
|
|
221
|
-
y2: number;
|
|
222
|
-
confidence: number;
|
|
223
|
-
};
|
|
224
|
-
classId: number;
|
|
225
|
-
className: string;
|
|
226
|
-
keypoints: AnimalKeypoint[];
|
|
227
|
-
scores: number[];
|
|
228
|
-
}
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
#### `AnimalKeypoint`
|
|
232
|
-
|
|
233
|
-
```typescript
|
|
234
|
-
interface AnimalKeypoint {
|
|
235
|
-
x: number;
|
|
236
|
-
y: number;
|
|
237
|
-
score: number;
|
|
238
|
-
visible: boolean;
|
|
239
|
-
name: string;
|
|
240
|
-
}
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
**Keypoint Names (17 COCO format):**
|
|
244
|
-
0. `nose`
|
|
245
|
-
1. `left_eye`
|
|
246
|
-
2. `right_eye`
|
|
247
|
-
3. `left_ear`
|
|
248
|
-
4. `right_ear`
|
|
249
|
-
5. `left_shoulder`
|
|
250
|
-
6. `right_shoulder`
|
|
251
|
-
7. `left_elbow`
|
|
252
|
-
8. `right_elbow`
|
|
253
|
-
9. `left_wrist`
|
|
254
|
-
10. `right_wrist`
|
|
255
|
-
11. `left_hip`
|
|
256
|
-
12. `right_hip`
|
|
257
|
-
13. `left_knee`
|
|
258
|
-
14. `right_knee`
|
|
259
|
-
15. `left_ankle`
|
|
260
|
-
16. `right_ankle`
|
|
261
|
-
|
|
262
|
-
#### `AnimalDetectionStats`
|
|
263
|
-
|
|
264
|
-
Statistics attached to results:
|
|
265
|
-
|
|
266
|
-
```typescript
|
|
267
|
-
interface AnimalDetectionStats {
|
|
268
|
-
animalCount: number;
|
|
269
|
-
classCounts: Record<string, number>;
|
|
270
|
-
detTime: number;
|
|
271
|
-
poseTime: number;
|
|
272
|
-
totalTime: number;
|
|
273
|
-
}
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
Access via: `(animals as any).stats`
|
|
277
|
-
|
|
278
|
-
## Complete Example
|
|
279
|
-
|
|
280
|
-
```typescript
|
|
281
|
-
import { AnimalDetector } from 'rtmlib-ts';
|
|
282
|
-
|
|
283
|
-
async function main() {
|
|
284
|
-
// Initialize
|
|
285
|
-
const detector = new AnimalDetector({
|
|
286
|
-
classes: ['dog', 'cat', 'horse', 'zebra', 'elephant'],
|
|
287
|
-
detConfidence: 0.5,
|
|
288
|
-
poseConfidence: 0.3,
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
console.log('Loading models...');
|
|
292
|
-
await detector.init();
|
|
293
|
-
console.log('Models loaded!');
|
|
294
|
-
console.log('Available classes:', detector.getAvailableClasses());
|
|
295
|
-
|
|
296
|
-
// Load image
|
|
297
|
-
const img = new Image();
|
|
298
|
-
img.src = 'animals.jpg';
|
|
299
|
-
await new Promise(resolve => img.onload = resolve);
|
|
300
|
-
|
|
301
|
-
const canvas = document.createElement('canvas');
|
|
302
|
-
canvas.width = img.width;
|
|
303
|
-
canvas.height = img.height;
|
|
304
|
-
const ctx = canvas.getContext('2d')!;
|
|
305
|
-
ctx.drawImage(img, 0, 0);
|
|
306
|
-
|
|
307
|
-
// Detect animals
|
|
308
|
-
const startTime = performance.now();
|
|
309
|
-
const animals = await detector.detectFromCanvas(canvas);
|
|
310
|
-
const endTime = performance.now();
|
|
311
|
-
|
|
312
|
-
const stats = (animals as any).stats;
|
|
313
|
-
console.log(`Detected ${stats.animalCount} animals in ${stats.totalTime}ms`);
|
|
314
|
-
console.log(` Detection: ${stats.detTime}ms`);
|
|
315
|
-
console.log(` Pose: ${stats.poseTime}ms`);
|
|
316
|
-
console.log(` By class:`, stats.classCounts);
|
|
317
|
-
|
|
318
|
-
// Draw results
|
|
319
|
-
animals.forEach((animal, i) => {
|
|
320
|
-
const color = `hsl(${i * 60}, 80%, 50%)`;
|
|
321
|
-
|
|
322
|
-
// Draw bounding box
|
|
323
|
-
ctx.strokeStyle = color;
|
|
324
|
-
ctx.lineWidth = 2;
|
|
325
|
-
ctx.strokeRect(
|
|
326
|
-
animal.bbox.x1,
|
|
327
|
-
animal.bbox.y1,
|
|
328
|
-
animal.bbox.x2 - animal.bbox.x1,
|
|
329
|
-
animal.bbox.y2 - animal.bbox.y1
|
|
330
|
-
);
|
|
331
|
-
|
|
332
|
-
// Draw label
|
|
333
|
-
ctx.fillStyle = color;
|
|
334
|
-
ctx.font = '14px sans-serif';
|
|
335
|
-
ctx.fillText(
|
|
336
|
-
`${animal.className} ${(animal.bbox.confidence * 100).toFixed(0)}%`,
|
|
337
|
-
animal.bbox.x1,
|
|
338
|
-
animal.bbox.y1 - 5
|
|
339
|
-
);
|
|
340
|
-
|
|
341
|
-
// Draw keypoints
|
|
342
|
-
animal.keypoints.forEach(kp => {
|
|
343
|
-
if (!kp.visible) return;
|
|
344
|
-
|
|
345
|
-
ctx.fillStyle = '#00ff00';
|
|
346
|
-
ctx.beginPath();
|
|
347
|
-
ctx.arc(kp.x, kp.y, 4, 0, Math.PI * 2);
|
|
348
|
-
ctx.fill();
|
|
349
|
-
});
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
// Cleanup
|
|
353
|
-
detector.dispose();
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
main();
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
## Performance Optimization
|
|
360
|
-
|
|
361
|
-
### 1. Use WebGPU Backend
|
|
362
|
-
|
|
363
|
-
```typescript
|
|
364
|
-
const detector = new AnimalDetector({
|
|
365
|
-
backend: 'webgpu', // Faster than WASM
|
|
366
|
-
});
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
### 2. Adjust Input Sizes
|
|
370
|
-
|
|
371
|
-
```typescript
|
|
372
|
-
const detector = new AnimalDetector({
|
|
373
|
-
detInputSize: [416, 416], // Faster detection
|
|
374
|
-
poseInputSize: [192, 256], // Faster pose
|
|
375
|
-
});
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
### 3. Filter Classes
|
|
379
|
-
|
|
380
|
-
```typescript
|
|
381
|
-
const detector = new AnimalDetector({
|
|
382
|
-
classes: ['dog', 'cat'], // Only detect specific animals
|
|
383
|
-
});
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
### 4. Tune Confidence Thresholds
|
|
387
|
-
|
|
388
|
-
```typescript
|
|
389
|
-
const detector = new AnimalDetector({
|
|
390
|
-
detConfidence: 0.6, // Higher = fewer false positives
|
|
391
|
-
poseConfidence: 0.4, // Only show confident keypoints
|
|
392
|
-
});
|
|
393
|
-
```
|
|
394
|
-
|
|
395
|
-
## Browser Support
|
|
396
|
-
|
|
397
|
-
| Browser | Version | Backend |
|
|
398
|
-
|---------|---------|---------|
|
|
399
|
-
| Chrome | 94+ | WASM, WebGPU |
|
|
400
|
-
| Edge | 94+ | WASM, WebGPU |
|
|
401
|
-
| Firefox | 95+ | WASM |
|
|
402
|
-
| Safari | 16.4+ | WASM |
|
|
403
|
-
|
|
404
|
-
## Performance Benchmarks
|
|
405
|
-
|
|
406
|
-
Typical inference times on M1 MacBook Pro:
|
|
407
|
-
|
|
408
|
-
| Configuration | Detection | Pose (per animal) | Total (3 animals) |
|
|
409
|
-
|--------------|-----------|------------------|-------------------|
|
|
410
|
-
| WASM, 640×640 + 256×192 | 100ms | 30ms | 190ms |
|
|
411
|
-
| WASM, 416×416 + 192×256 | 50ms | 20ms | 110ms |
|
|
412
|
-
| WebGPU, 640×640 + 256×192 | 40ms | 15ms | 85ms |
|
|
413
|
-
|
|
414
|
-
## Troubleshooting
|
|
415
|
-
|
|
416
|
-
### "No animals detected"
|
|
417
|
-
|
|
418
|
-
- Lower `detConfidence` threshold
|
|
419
|
-
- Ensure animal is visible and reasonably sized
|
|
420
|
-
- Check if animal class is in the supported list
|
|
421
|
-
|
|
422
|
-
### "Slow inference"
|
|
423
|
-
|
|
424
|
-
- Switch to WebGPU backend
|
|
425
|
-
- Reduce input sizes
|
|
426
|
-
- Filter to fewer animal classes
|
|
427
|
-
- Process every Nth frame in video
|
|
428
|
-
|
|
429
|
-
### "Model loading failed"
|
|
430
|
-
|
|
431
|
-
- Ensure models are accessible via HTTP
|
|
432
|
-
- Use a local server: `python -m http.server 8080`
|
|
433
|
-
- Check CORS headers
|
|
434
|
-
|
|
435
|
-
## Custom Models
|
|
436
|
-
|
|
437
|
-
You can use custom models trained on animal datasets:
|
|
438
|
-
|
|
439
|
-
```typescript
|
|
440
|
-
const detector = new AnimalDetector({
|
|
441
|
-
detModel: 'path/to/yolox_animal.onnx',
|
|
442
|
-
poseModel: 'path/to/vitpose_animal.onnx',
|
|
443
|
-
detInputSize: [640, 640],
|
|
444
|
-
poseInputSize: [256, 192],
|
|
445
|
-
});
|
|
446
|
-
```
|
|
447
|
-
|
|
448
|
-
## License
|
|
449
|
-
|
|
450
|
-
Apache 2.0
|