lgonda1998 commited on
Commit
ce7ca2d
·
verified ·
1 Parent(s): e94595f

Add Faster R-CNN, YOLOv8n, and RT-DETR models

Browse files
Files changed (1) hide show
  1. classifier.js +31 -0
classifier.js CHANGED
@@ -25,6 +25,32 @@ export const MODEL_OPTIONS = [
25
  note: 'A vision-language model that ranks your own candidate descriptions.',
26
  dtype: 'q8',
27
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  ];
29
 
30
  const classifierCache = new Map();
@@ -57,6 +83,11 @@ export async function classifyImage(imageDataUrl, options = {}) {
57
  predictions = await classifier(imageDataUrl, options.candidateLabels, {
58
  hypothesis_template: 'a photo of {}',
59
  });
 
 
 
 
 
60
  } else {
61
  predictions = await classifier(imageDataUrl, { top_k: topK });
62
  }
 
25
  note: 'A vision-language model that ranks your own candidate descriptions.',
26
  dtype: 'q8',
27
  },
28
+ {
29
+ key: 'faster-rcnn',
30
+ label: 'Faster R-CNN (R50-FPN)',
31
+ modelId: 'onnxmodelzoo/FasterRCNN-10',
32
+ task: 'object-detection',
33
+ note: 'A two-stage detector that proposes regions, then classifies and refines each detected object.',
34
+ dtype: 'fp32',
35
+ experimental: true,
36
+ },
37
+ {
38
+ key: 'yolov8n',
39
+ label: 'YOLOv8n',
40
+ modelId: 'webnn/yolov8n',
41
+ task: 'object-detection',
42
+ note: 'A compact one-stage detector designed for fast object detection.',
43
+ dtype: 'fp32',
44
+ experimental: true,
45
+ },
46
+ {
47
+ key: 'rtdetr-r18',
48
+ label: 'RT-DETR R18',
49
+ modelId: 'onnx-community/rtdetr_r18vd',
50
+ task: 'object-detection',
51
+ note: 'A real-time Detection Transformer with a lightweight ResNet-18-style backbone.',
52
+ dtype: 'q8',
53
+ },
54
  ];
55
 
56
  const classifierCache = new Map();
 
83
  predictions = await classifier(imageDataUrl, options.candidateLabels, {
84
  hypothesis_template: 'a photo of {}',
85
  });
86
+ } else if (option.task === 'object-detection') {
87
+ predictions = await classifier(imageDataUrl, {
88
+ threshold: options.threshold ?? 0.25,
89
+ percentage: false,
90
+ });
91
  } else {
92
  predictions = await classifier(imageDataUrl, { top_k: topK });
93
  }