# JavaScript computer vision libraries

JavaScript computer vision libraries analyze images and video frames to find faces, objects, poses, and regions. Detection runs a pretrained model in the browser or in Node.js after the library loads its weight files. These libraries add face filters, background removal, document scanning, and camera-based input to web apps.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [@mediapipe/tasks-vision](#mediapipe-tasks-vision) | 31.4M | 37.7K | Nov 2026 | Apache-2.0 |
| [@huggingface/transformers](#huggingface-transformers) | 19.1M | 16.4K | Oct 2026 | Apache-2.0 |
| [@tensorflow/tfjs](#tensorflow-tfjs) | 2.4M | 19.2K | Oct 2024 | Apache-2.0 |
| [@techstark/opencv-js](#opencv-js-techstark) | 1.5M | 790 | Jun 2026 | Apache-2.0 |
| [@vladmandic/face-api](#faceapi-vladmandic) | 669.7K | 1.1K | Feb 2025 | MIT |
| [@vladmandic/human](#vladmandic-human) | 430.3K | 3.4K | Aug 2025 | MIT |
| [@tensorflow-models/blazeface](#tensorflow-models-blazeface) | 305.0K | 14.8K | Aug 2023 | Apache-2.0 |
| [@tensorflow-models/face-detection](#tensorflow-models-face-detection) | 287.3K | 14.8K | Oct 2024 | Apache-2.0 |

Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[MediaPipe Tasks Vision](#mediapipe-tasks-vision) has the most monthly downloads in this comparison, at 31.4M.

## Capabilities

| Library | Face keypoint task | Image segmentation API | Face descriptor pipeline |
| --- | --- | --- | --- |
| [@mediapipe/tasks-vision](#mediapipe-tasks-vision) | Yes | Yes | No |
| [@huggingface/transformers](#huggingface-transformers) | No | Yes | No |
| [@tensorflow/tfjs](#tensorflow-tfjs) | No | No | No |
| [@techstark/opencv-js](#opencv-js-techstark) | Yes | Yes | No |
| [@vladmandic/face-api](#faceapi-vladmandic) | Yes | No | Yes |
| [@vladmandic/human](#vladmandic-human) | Yes | Yes | Yes |
| [@tensorflow-models/blazeface](#tensorflow-models-blazeface) | Yes | No | No |
| [@tensorflow-models/face-detection](#tensorflow-models-face-detection) | Yes | No | No |

## Libraries

### @mediapipe/tasks-vision

[GitHub](https://github.com/google-ai-edge/mediapipe) · [npm](https://www.npmjs.com/package/@mediapipe/tasks-vision) · [Docs](https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@1.2.3/vision.d.ts)

Provides JavaScript vision tasks for MediaPipe.

- Downloads / mo: 31.4M
- Stars: 37.7K
- Last release: 1.2.3
- License: Apache-2.0
- Capabilities: [From the @mediapipe/tasks-vision docs](https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@1.2.3/vision.d.ts)

**Strengths**

- **Locates facial keypoints.** Use FaceLandmarker on images or decoded video frames.
- **Returns segmentation masks.** Choose ImageSegmenter for labeled regions instead of detection boxes.

**Watch out for**

- **Inference can block the interface.** Move detection into a Web Worker to keep the interface responsive.
- **Face smoothing requires one face.** Set FaceLandmarker's numFaces to one to enable smoothing.

```sh
npm install @mediapipe/tasks-vision
```

**google-ai-edge/mediapipe-samples-web** (113 stars)

[google-ai-edge/mediapipe-samples-web](https://github.com/google-ai-edge/mediapipe-samples-web) 

```typescript
protected async handleCustomMessage(data: any): Promise<void> {
    if (data.type === 'DETECT_IMAGE' || data.type === 'DETECT_VIDEO') {
      const { bitmap, timestampMs } = data;
      const requiredMode = data.type === 'DETECT_IMAGE' ? 'IMAGE' : 'VIDEO';

      if (!this.taskInstance) {
        console.warn('FaceLandmarker not initialized yet.');
        bitmap.close();
        self.postMessage({ type: 'DETECT_ERROR', error: 'Not initialized' });
        return;
      }

      if (this.currentOptions.runningMode !== requiredMode) {
        this.currentOptions.runningMode = requiredMode;
        await this.updateOptions();
      }

      const startTimeMs = performance.now();
      let result: FaceLandmarkerResult;

      try {
        if (requiredMode === 'VIDEO') {
          result = this.taskInstance.detectForVideo(bitmap, timestampMs);
        } else {
          result = this.taskInstance.detect(bitmap);
        }
      } catch (e: any) {
        console.error('Worker detection error:', e);
        bitmap.close();
        self.postMessage({ type: 'DETECT_ERROR', error: e.message || 'Detection failed' });
        return;
      }

      const inferenceTime = performance.now() - startTimeMs;
      bitmap.close();

      self.postMessage({
        type: 'DETECT_RESULT',
        mode: requiredMode,
        result: result,
        inferenceTime: inferenceTime,
      });
    }
  }
```

[src/workers/face-landmarker.worker.ts](https://github.com/google-ai-edge/mediapipe-samples-web/blob/64ecdefb2a0f0d97e175e4d8fdeeff0f73b29ab5/src/workers/face-landmarker.worker.ts#L53-L96) · [More projects using @mediapipe/tasks-vision →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20application%20%40mediapipe/tasks-vision%20image%20video%20inference%20geometry%20landmarks%20detection%20SDK&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
import { FaceLandmarker, FilesetResolver } from '@mediapipe/tasks-vision';

const vision = await FilesetResolver.forVisionTasks('/mediapipe/wasm');
const detector = await FaceLandmarker.createFromOptions(vision, {
  baseOptions: { modelAssetPath: '/models/face_landmarker.task' },
  runningMode: 'IMAGE'
});
const image = document.getElementById('image');
await image.decode();
const result = detector.detect(image);
detector.close();

```

From [face-landmarker.worker.ts](https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@1.2.3/vision.d.ts)

### @huggingface/transformers

[GitHub](https://github.com/huggingface/transformers.js) · [npm](https://www.npmjs.com/package/@huggingface/transformers) · [Docs](https://huggingface.co/docs/transformers.js/api/pipelines)

Runs pretrained Hugging Face models in the browser with an API close to the Python transformers library.

- Downloads / mo: 19.1M
- Stars: 16.4K
- Last release: 4.3.2
- License: Apache-2.0
- Capabilities: [From the @huggingface/transformers docs](https://huggingface.co/docs/transformers.js/api/pipelines)

**Strengths**

- **Covers common vision tasks.** Pipelines handle image classification, object detection, segmentation, and depth estimation.
- **Runs models through ONNX Runtime.** PyTorch, TensorFlow, and JAX models convert to ONNX before they run.

```sh
npm install @huggingface/transformers
```

**huggingface/transformers.js-examples** (2.1K stars)

[huggingface/transformers.js-examples](https://github.com/huggingface/transformers.js-examples) 

```javascript
async function predict(url) {
  imageContainer.innerHTML = "";
  const image = await RawImage.fromURL(url);

  // Set up scene and slider controls
  const { canvas, setDisplacementMap } = setupScene(
    url,
    image.width,
    image.height,
  );

  imageContainer.append(canvas);

  status.textContent = "Analysing...";
  const { depth } = await depth_estimator(image);

  setDisplacementMap(depth.toCanvas());
  status.textContent = "";

  // Add slider control
  const slider = document.createElement("input");
  slider.type = "range";
  slider.min = 0;
  slider.max = 1;
  slider.step = 0.01;
  slider.addEventListener("input", (e) => {
    onSliderChange(parseFloat(e.target.value));
  });
  slider.defaultValue = DEFAULT_SCALE;
  imageContainer.append(slider);
}

```

[depth-anything/main.js](https://github.com/huggingface/transformers.js-examples/blob/204b0948e88cd2bdc046316e78b754359653caea/depth-anything/main.js#L47-L77) · [More projects using @huggingface/transformers →](https://dashboard.exa.ai/playground/search?q=%40huggingface/transformers%20GitHub%20projects)

**Quickstart**

```javascript
import { pipeline } from '@huggingface/transformers';

const estimateDepth = await pipeline(
  'depth-estimation', 'onnx-community/depth-anything-v2-small'
);
const { depth } = await estimateDepth('/input.jpg');

```

From [depth-estimation.d.ts](https://cdn.jsdelivr.net/npm/@huggingface/transformers@4.3.2/types/pipelines/depth-estimation.d.ts)

### @tensorflow/tfjs

[GitHub](https://github.com/tensorflow/tfjs) · [npm](https://www.npmjs.com/package/@tensorflow/tfjs) · [Docs](https://github.com/tensorflow/tfjs/blob/master/tfjs-core/src/ops/ops.ts)

Trains and deploys machine learning models in JavaScript with hardware acceleration.

- Downloads / mo: 2.4M
- Stars: 19.2K
- Last release: 4.22.0
- License: Apache-2.0
- Capabilities: [From the @tensorflow/tfjs docs](https://github.com/tensorflow/tfjs/blob/master/tfjs-core/src/ops/ops.ts)

**Strengths**

- **Runs converted TensorFlow models.** Model converters bring existing TensorFlow models into the browser.
- **Same API in Node.js.** Server code runs native TensorFlow through the same API.

```sh
npm install @tensorflow/tfjs
```

**googlecreativelab/teachablemachine-community** (1.8K stars)

[googlecreativelab/teachablemachine-community](https://github.com/googlecreativelab/teachablemachine-community) 

```javascript
export async function loadTruncatedMobileNet(modelOptions?: ModelOptions) {
    const [checkpointUrl, trainingLayer] = parseModelOptions(modelOptions);
    const mobilenet = await tf.loadLayersModel(checkpointUrl);

    if (modelOptions && modelOptions.version === 1){
        const layer = mobilenet.getLayer(trainingLayer);
        const truncatedModel = tf.model({ inputs: mobilenet.inputs, outputs: layer.output });
        const model = tf.sequential();
        model.add(truncatedModel);
        model.add(tf.layers.flatten());
        return model;
    }
    else {
        const layer = mobilenet.getLayer(trainingLayer);
        const truncatedModel = tf.model({ inputs: mobilenet.inputs, outputs: layer.output });
        const model = tf.sequential();
        model.add(truncatedModel);
        model.add(tf.layers.globalAveragePooling2d({})); // go from shape [7, 7, 1280] to [1280]
        return model;
    }
}
```

[libraries/image/src/custom-mobilenet.ts](https://github.com/googlecreativelab/teachablemachine-community/blob/55aa0bb84acaa9efcbb9a2068eaefbb72cddae2c/libraries/image/src/custom-mobilenet.ts#L289-L309) · [More projects using @tensorflow/tfjs →](https://dashboard.exa.ai/playground/search?q=%40tensorflow/tfjs%20GitHub%20projects)

**Quickstart**

```javascript
import * as tf from '@tensorflow/tfjs';

const image = tf.zeros([2, 2, 3]);
const resized = tf.image.resizeBilinear(image, [4, 4]);
console.log(resized.shape);
image.dispose();
resized.dispose();

```

From [resize_bilinear.d.ts](https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-core@4.22.0/dist/ops/image/resize_bilinear.d.ts)

### @techstark/opencv-js

[GitHub](https://github.com/TechStark/opencv-js) · [npm](https://www.npmjs.com/package/@techstark/opencv-js) · [Docs](https://github.com/TechStark/opencv-js/blob/main/README.md)

Packages OpenCV.js for Node.js and browser applications.

- Downloads / mo: 1.5M
- Stars: 790
- Last release: 5.0.0-release.1
- License: Apache-2.0
- Capabilities: [From the @techstark/opencv-js docs](https://github.com/TechStark/opencv-js/blob/main/README.md)

**Strengths**

- **Directly converts image colors.** Use cvtColor before a later detection or measurement step.
- **Supports Node and browser hosts.** Load the packaged runtime in Node or a browser.

**Watch out for**

- **Native matrices need cleanup.** Delete Mat objects after processing to release their native memory.
- **Types can differ from runtime.** Check cvKeys.json before relying on a declared method.

```sh
npm install @techstark/opencv-js
```

**aleqsio/screenmap** (253 stars)

[aleqsio/screenmap](https://github.com/aleqsio/screenmap) 

```typescript
async function compute(headUrl, baseUrl) {
  const [head, base] = await Promise.all([loadImage(headUrl), loadImage(baseUrl)])
  const w = Math.min(head.naturalWidth, base.naturalWidth)
  const h = Math.min(head.naturalHeight, base.naturalHeight)
  const ctxOf = (img) => {
    const c = document.createElement('canvas')
    c.width = w
    c.height = h
    const ctx = c.getContext('2d', { willReadFrequently: true })
    ctx.drawImage(img, 0, 0, w, h)
    return ctx
  }
  const headCtx = ctxOf(head)
  const baseCtx = ctxOf(base)
  const headData = headCtx.getImageData(0, 0, w, h)
  const baseData = baseCtx.getImageData(0, 0, w, h)

  const maskData = new ImageData(w, h)
  pixelmatch(baseData.data, headData.data, maskData.data, w, h, {
    threshold: 0.12,
    includeAA: false,
    diffMask: true, // only diff pixels are drawn → alpha channel IS the mask
  })

  const cv = await loadCv()
  const islands = []
  // cluster the mask into islands
  const maskMat = cv.matFromImageData(maskData)
  const gray = new cv.Mat()
  cv.cvtColor(maskMat, gray, cv.COLOR_RGBA2GRAY)
  cv.threshold(gray, gray, 1, 255, cv.THRESH_BINARY)
  const kernel = cv.getStructuringElement(cv.MORPH_RECT, new cv.Size(9, 9))
  const fused = new cv.Mat()
  cv.dilate(gray, fused, kernel)
  const labels = new cv.Mat()
  const stats = new cv.Mat()
  const centroids = new cv.Mat()
  const n = cv.connectedComponentsWithStats(fused, labels, stats, centroids)
  const changedFraction = cv.countNonZero(gray) / (w * h)
  const headGray = cv.matFromImageData(headData)
  const baseGray = cv.matFromImageData(baseData)
  cv.cvtColor(headGray, headGray, cv.COLOR_RGBA2GRAY)
  cv.cvtColor(baseGray, baseGray, cv.COLOR_RGBA2GRAY)

  for (let i = 1; i < n; i++) {
    const s = stats.data32S.subarray(i * 5, i * 5 + 5)
    const [x, y, bw, bh, area] = s
    if (area < MIN_ISLAND_AREA) continue
    const island = { x, y, w: bw, h: bh, kind: 'changed', dx: 0, dy: 0 }
    // motion analysis is pointless when most of the screen changed, and
    // template matching on huge islands is slow — treat those as changed
    const feasible = changedFraction < 0.5 && bw * bh < w * h * 0.35 && bw > 16 && bh > 10
    if (feasible) {
      const sx = Math.max(0, x - SEARCH_PAD)
      const sy = Math.max(0, y - SEARCH_PAD)
      const sw = Math.min(w, x + bw + SEARCH_PAD) - sx
      const sh = Math.min(h, y + bh + SEARCH_PAD) - sy
      const templ = baseGray.roi(new cv.Rect(x, y, bw, bh))
      const mean = new cv.Mat()
      const stddev = new cv.Mat()
      cv.meanStdDev(templ, mean, stddev)
      const texture = stddev.data64F[0]
      mean.delete(); stddev.delete()
      if (texture >= MIN_TEXTURE) {
        const search = headGray.roi(new cv.Rect(sx, sy, sw, sh))
        const result = new cv.Mat()
        cv.matchTemplate(search, templ, result, cv.TM_CCOEFF_NORMED)
        const mm = cv.minMaxLoc(result)
        const dx = sx + mm.maxLoc.x - x
        const dy = sy + mm.maxLoc.y - y
        // "moved" needs a confident match that clearly BEATS staying put —
        // otherwise textured-but-generic patches (avatar rows) match anywhere
        const stayScore = result.data32F[(y - sy) * result.cols + (x - sx)] ?? -1
        if (
          mm.maxVal >= MATCH_SCORE &&
          mm.maxVal - stayScore >= MATCH_MARGIN &&
          Math.abs(dx) + Math.abs(dy) >= MIN_SHIFT
        ) {
          island.kind = 'moved'
          island.dx = dx
          island.dy = dy
        }
        search.delete(); result.delete()
      }
      templ.delete()
    }
    islands.push(island)
  }
  for (const m of [maskMat, gray, kernel, fused, labels, stats, centroids, headGray, baseGray]) m.delete()

  // merge overlapping/touching same-kind boxes so fragmented regions read as one
  const overlaps = (a, b, pad) =>
    a.x < b.x + b.w + pad && b.x < a.x + a.w + pad && a.y < b.y + b.h + pad && b.y < a.y + a.h + pad
  let merged = true
  while (merged) {
    merged = false
    outer: for (let i = 0; i < islands.length; i++) {
      for (let j = i + 1; j < islands.length; j++) {
        const a = islands[i]
        const b = islands[j]
        if (a.kind !== b.kind || !overlaps(a, b, 8)) continue
        if (a.kind === 'moved' && (Math.abs(a.dx - b.dx) > 6 || Math.abs(a.dy - b.dy) > 6)) continue
        const x2 = Math.max(a.x + a.w, b.x + b.w)
        const y2 = Math.max(a.y + a.h, b.y + b.h)
        a.x = Math.min(a.x, b.x)
        a.y = Math.min(a.y, b.y)
        a.w = x2 - a.x
        a.h = y2 - a.y
        islands.splice(j, 1)
        merged = true
        break outer
      }
    }
  }

  // a moved island's destination box already marks its landing spot — drop
  // changed islands whose center sits inside one (they're the same event)
  const movedDests = islands.filter((r) => r.kind === 'moved').map((r) => ({ x: r.x + r.dx, y: r.y + r.dy, w: r.w, h: r.h }))
  const covered = (r) => {
    const cx = r.x + r.w / 2
    const cy = r.y + r.h / 2
    return movedDests.some((d) => cx >= d.x && cx <= d.x + d.w && cy >= d.y && cy <= d.y + d.h)
  }
  for (let i = islands.length - 1; i >= 0; i--) {
    if (islands[i].kind === 'changed' && covered(islands[i])) islands.splice(i, 1)
  }

  // ---- render: dimmed grayscale head + island annotations ----
  const out = document.createElement('canvas')
  out.width = w
  out.height = h
  const ctx = out.getContext('2d')
  ctx.filter = 'grayscale(1) brightness(0.5)'
  ctx.drawImage(head, 0, 0, w, h)
  ctx.filter = 'none'

  // red tint for genuinely-changed pixels — only inside changed islands, so
  // the annotation layer stays quiet everywhere else
  const tint = new ImageData(w, h)
  const changedRects = islands.filter((r) => r.kind === 'changed')
  const inChanged = (px, py) =>
    changedRects.some((r) => px >= r.x && px < r.x + r.w && py >= r.y && py < r.y + r.h)
  for (let i = 0; i < maskData.data.length; i += 4) {
    if (maskData.data[i + 3] === 0) continue
    const px = (i / 4) % w
    const py = Math.floor(i / 4 / w)
    if (!inChanged(px, py)) continue
    tint.data[i] = 248; tint.data[i + 1] = 56; tint.data[i + 2] = 56; tint.data[i + 3] = 230
  }
  const tintCanvas = document.createElement('canvas')
  tintCanvas.width = w
  tintCanvas.height = h
  tintCanvas.getContext('2d').putImageData(tint, 0, 0)
  ctx.drawImage(tintCanvas, 0, 0)

  const L = Math.max(1.5, w / 260) // line weight scales with capture size
  let moved = 0
  let changed = 0
  for (const r of islands) {
    if (r.kind === 'moved') {
      moved++
      // dashed box where it was, solid box where it is now, arrow between
      const nx = r.x + r.dx
      const ny = r.y + r.dy
      ctx.strokeStyle = 'rgba(103,232,249,0.55)'
      ctx.lineWidth = L
      ctx.setLineDash([5, 4])
      ctx.strokeRect(r.x, r.y, r.w, r.h)
      ctx.setLineDash([])
      ctx.strokeStyle = '#67e8f9'
      ctx.strokeRect(nx, ny, r.w, r.h)
      const cx1 = r.x + r.w / 2
      const cy1 = r.y + r.h / 2
      const cx2 = nx + r.w / 2
      const cy2 = ny + r.h / 2
      const ang = Math.atan2(cy2 - cy1, cx2 - cx1)
      const headLen = 5 * L
      ctx.beginPath()
      ctx.moveTo(cx1, cy1)
      ctx.lineTo(cx2, cy2)
      ctx.stroke()
      ctx.beginPath()
      ctx.moveTo(cx2, cy2)
      ctx.lineTo(cx2 - headLen * Math.cos(ang - 0.4), cy2 - headLen * Math.sin(ang - 0.4))
      ctx.lineTo(cx2 - headLen * Math.cos(ang + 0.4), cy2 - headLen * Math.sin(ang + 0.4))
      ctx.closePath()
      ctx.fillStyle = '#67e8f9'
      ctx.fill()
    } else {
      changed++
      ctx.strokeStyle = 'rgba(248,113,113,0.9)'
      ctx.lineWidth = L
      ctx.strokeRect(r.x, r.y, r.w, r.h)
    }
  }
  return { url: out.toDataURL(), moved, changed }
}

```

[apps/visualiser/src/lib/visualDiff.js](https://github.com/aleqsio/screenmap/blob/7e1004fdd99bd0e15c1d5adc06e593a46981e41f/apps/visualiser/src/lib/visualDiff.js#L57-L253) · [More projects using @techstark/opencv-js →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20application%20%40techstark/opencv-js%20image%20video%20inference%20geometry%20landmarks%20detection%20SDK&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
import cvModule from '@techstark/opencv-js';

let cv = cvModule;
if (cvModule instanceof Promise) {
  cv = await cvModule;
} else if (!cvModule.Mat) {
  await new Promise(resolve => { cvModule.onRuntimeInitialized = resolve; });
}
const matrix = cv.imread(document.getElementById('image'));
console.log(matrix.rows, matrix.cols);
matrix.delete();

```

From [README.md](https://github.com/TechStark/opencv-js/blob/main/README.md)

### @vladmandic/face-api

[GitHub](https://github.com/vladmandic/face-api) · [npm](https://www.npmjs.com/package/@vladmandic/face-api) · [Docs](https://github.com/vladmandic/face-api/blob/master/README.md)

Provides face detection, landmark, and face-description APIs using TensorFlow.js.

- Downloads / mo: 669.7K
- Stars: 1.1K
- Last release: 1.7.15
- License: MIT
- Capabilities: [From the @vladmandic/face-api docs](https://github.com/vladmandic/face-api/blob/master/README.md)

**Strengths**

- **Extracts face landmarks and descriptors.** Chain landmark and descriptor methods after detecting faces.
- **Chooses between face detectors.** Select TinyFaceDetector or SSD Mobilenet through the detector options.

**Watch out for**

- **Upstream repository is archived.** The original repository is now read-only.
- **Recent Node releases are unsupported.** Use Node 22 or an earlier supported release for server inference.
- **Models need manifest and weights.** Serve each model manifest beside its weight shard files.

```sh
npm install @vladmandic/face-api @tensorflow/tfjs-node
```

**nextcloud/recognize** (701 stars)

[nextcloud/recognize](https://github.com/nextcloud/recognize) 

```typescript
async function main() {
	const getStdin = (await import('get-stdin')).default
	let paths
	if (process.argv[2] === '-') {
		paths = (await getStdin()).split('\n')
	} else {
		paths = process.argv.slice(2)
	}

	await faceapi.nets.ssdMobilenetv1.loadFromDisk(path.resolve(__dirname, '..', 'node_modules/@vladmandic/face-api/model'))
	await faceapi.nets.faceLandmark68Net.loadFromDisk(path.resolve(__dirname, '..', 'node_modules/@vladmandic/face-api/model'))
	await faceapi.nets.faceRecognitionNet.loadFromDisk(path.resolve(__dirname, '..', 'node_modules/@vladmandic/face-api/model'))

	for (const path of paths) {
		try {
			let tensor
			if (PUREJS) {
				tensor = await createTensor(await Jimp.read(path), 3)
			} else {
				tensor = await tf.node.decodeImage(await fs.readFile(path), 3)
			}
			const results = await faceapi.detectAllFaces(tensor).withFaceLandmarks().withFaceDescriptors()
			tensor.dispose()
			const vectors = results
				.map(result => ({
					angle: result.angle,
					vector: result.descriptor,
					x: result.detection.relativeBox.x,
					y: result.detection.relativeBox.y,
					height: result.detection.relativeBox.height,
					width: result.detection.relativeBox.width,
					score: result.detection.score,
				}))

			console.log(JSON.stringify(vectors))
		} catch (e) {
			console.error(e)
			console.log('[]')
		}
	}
}

```

[src/classifier_faces.js](https://github.com/nextcloud/recognize/blob/71f7e5c4bd24ca3cd9238de5c84f3a7def68fbaf/src/classifier_faces.js#L37-L77) · [More projects using @vladmandic/face-api →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20application%20%40vladmandic/face-api%20image%20video%20inference%20geometry%20landmarks%20detection%20SDK&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
const fs = require('node:fs');
const faceapi = require('@vladmandic/face-api');

(async () => {
  await faceapi.nets.ssdMobilenetv1.loadFromDisk('node_modules/@vladmandic/face-api/model');
  const image = faceapi.tf.node.decodeImage(fs.readFileSync('input.jpg'), 3);
  const faces = await faceapi.detectAllFaces(image);
  image.dispose();
})();

```

From [node-simple.js](https://github.com/vladmandic/face-api/blob/master/demo/node-simple.js)

### @vladmandic/human

[GitHub](https://github.com/vladmandic/human) · [npm](https://www.npmjs.com/package/@vladmandic/human) · [Docs](https://github.com/vladmandic/human/blob/main/README.md)

Detects faces and tracks their rotation, with face description for recognition.

- Downloads / mo: 430.3K
- Stars: 3.4K
- Last release: 3.3.6
- License: MIT
- Capabilities: [From the @vladmandic/human docs](https://github.com/vladmandic/human/blob/main/README.md)

**Strengths**

- **Runs only the models needed.** Frame-change detection triggers only the models a frame needs.
- **Handles video and webcam input.** Images, video, and webcam streams feed the pipeline directly.

**Watch out for**

- **Chromium comes first.** Firefox and Safari are secondary platforms.

```sh
npm install @vladmandic/human
```

**jitsi/jitsi-meet** (30.3K stars)

[jitsi/jitsi-meet](https://github.com/jitsi/jitsi-meet) 

```javascript
async getDetections(image: ImageBitmap | ImageData): Promise<Array<FaceResult>> {
    if (!this.human || !this.faceDetectionTypes.length) {
        return [];
    }

    this.human.tf.engine().startScope();

    const imageTensor = this.human.tf.browser.fromPixels(image);
    const { face: detections } = await this.human.detect(imageTensor, this.config);

    this.human.tf.engine().endScope();

    return detections.filter(detection => detection.score > FACE_DETECTION_SCORE_THRESHOLD);
}

```

[react/features/face-landmarks/FaceLandmarksHelper.ts](https://github.com/jitsi/jitsi-meet/blob/ec8f4416bb16fa9d1ef269f6bb612cd4c040e8a2/react/features/face-landmarks/FaceLandmarksHelper.ts#L183-L196) · [More projects using @vladmandic/human →](https://dashboard.exa.ai/playground/search?q=%40vladmandic/human%20GitHub%20projects)

**Quickstart**

```javascript
import { Human } from '@vladmandic/human';

const human = new Human({ modelBasePath: '/models/' });
const image = document.getElementById('image');
await image.decode();
const result = await human.detect(image);

```

From [README.md](https://github.com/vladmandic/human/blob/main/README.md)

### @tensorflow-models/blazeface

[GitHub](https://github.com/tensorflow/tfjs-models) · [npm](https://www.npmjs.com/package/@tensorflow-models/blazeface) · [Docs](https://github.com/tensorflow/tfjs-models/blob/master/blazeface/README.md)

Detects faces with a pretrained model in TensorFlow.js.

- Downloads / mo: 305.0K
- Stars: 14.8K
- Last release: 0.1.0
- License: Apache-2.0
- Capabilities: [From the @tensorflow-models/blazeface docs](https://github.com/tensorflow/tfjs-models/blob/master/blazeface/README.md)

**Watch out for**

- **Deprecated.** New code uses the face-detection package instead.

```sh
npm install @tensorflow-models/blazeface @tensorflow/tfjs
```

**Quickstart**

```javascript
import '@tensorflow/tfjs';
import * as blazeface from '@tensorflow-models/blazeface';

const image = document.getElementById('image');
await image.decode();
const detector = await blazeface.load();
const faces = await detector.estimateFaces(image, false);
detector.dispose();

```

From [index.d.ts](https://cdn.jsdelivr.net/npm/@tensorflow-models/blazeface@0.1.0/dist/index.d.ts) · [Find projects using @tensorflow-models/blazeface →](https://dashboard.exa.ai/playground/search?q=%40tensorflow-models/blazeface%20GitHub%20projects)

### @tensorflow-models/face-detection

[GitHub](https://github.com/tensorflow/tfjs-models) · [npm](https://www.npmjs.com/package/@tensorflow-models/face-detection) · [Docs](https://github.com/tensorflow/tfjs-models/blob/master/face-detection/README.md)

Provides models for running real-time face detection in JavaScript.

- Downloads / mo: 287.3K
- Stars: 14.8K
- Last release: 1.0.3
- License: Apache-2.0
- Capabilities: [From the @tensorflow-models/face-detection docs](https://github.com/tensorflow/tfjs-models/blob/master/face-detection/README.md)

**Strengths**

- **Returns keypoints per face.** Each detected face carries a bounding box and an array of keypoints.
- **Chooses its runtime.** The detector config selects the MediaPipe or TensorFlow.js runtime.

**Watch out for**

- **Offers a single model.** MediaPipe FaceDetection is the only model the package provides.

```sh
npm install @tensorflow-models/face-detection @tensorflow/tfjs-core @tensorflow/tfjs-converter @tensorflow/tfjs-backend-webgl
```

**aws-amplify/amplify-ui** (1.1K stars)

[aws-amplify/amplify-ui](https://github.com/aws-amplify/amplify-ui) 

```javascript
async detectFaces(videoEl: HTMLVideoElement): Promise<Face[]> {
  const flipHorizontal = true;
  const predictions = await this._model.estimateFaces(videoEl, {
    flipHorizontal,
  });

  const timestampMs = Date.now();

  const faces: Face[] = predictions.map((prediction) => {
    const { box, keypoints } = prediction;
    const { xMin: left, yMin: top, width, height } = box;
    const rightEye = this._getCoordinate(keypoints, 'rightEye');
    const leftEye = this._getCoordinate(keypoints, 'leftEye');
    const nose = this._getCoordinate(keypoints, 'noseTip');
    const mouth = this._getCoordinate(keypoints, 'mouthCenter');
    const rightEar = this._getCoordinate(keypoints, 'rightEarTragion');
    const leftEar = this._getCoordinate(keypoints, 'leftEarTragion');
    const probability = [90];

    return {
      top,
      left,
      width,
      height,
      timestampMs,
      probability: (probability as unknown as [number])[0], // probability in reality is [number] but is typed as number | Tensor.1d
      rightEye,
      leftEye,
      mouth,
      nose,
      rightEar,
      leftEar,
    };
  });

  return faces;
}

```

[packages/react-liveness/src/components/FaceLivenessDetector/service/utils/blazefaceFaceDetection.ts](https://github.com/aws-amplify/amplify-ui/blob/07a1df5262ce3c2ec79a22244c582ff38fdb8e6f/packages/react-liveness/src/components/FaceLivenessDetector/service/utils/blazefaceFaceDetection.ts#L66-L102) · [More projects using @tensorflow-models/face-detection →](https://dashboard.exa.ai/playground/search?q=%40tensorflow-models/face-detection%20GitHub%20projects)

**Quickstart**

```javascript
import '@tensorflow/tfjs-backend-webgl';
import * as faceDetection from '@tensorflow-models/face-detection';

const detector = await faceDetection.createDetector(
  faceDetection.SupportedModels.MediaPipeFaceDetector, { runtime: 'tfjs' }
);
const image = document.getElementById('image');
await image.decode();
const faces = await detector.estimateFaces(image);
detector.dispose();

```

From [README.md](https://github.com/tensorflow/tfjs-models/blob/master/face-detection/README.md)

## FAQ

### What is TensorFlow.js?

[TensorFlow.js](#tensorflow-tfjs) is a hardware-accelerated JavaScript library for training and deploying machine learning models in the browser and in Node.js. Its model converters run existing TensorFlow models in the browser.

### What is Transformers.js?

[Transformers.js](#huggingface-transformers) runs pretrained Hugging Face models in the browser through ONNX Runtime. Its vision pipelines cover image classification, object detection, segmentation, and depth estimation.

### What is MediaPipe Face Landmarker?

FaceLandmarker is a task in [MediaPipe Tasks Vision](#mediapipe-tasks-vision) that locates facial keypoints in images and decoded video frames. The face-landmarker detect and detectForVideo methods run synchronously and block the interface thread; a worker can move that work away from it.

### Is BlazeFace deprecated?

Yes. [BlazeFace](#tensorflow-models-blazeface) is deprecated in favor of the [face-detection](#tensorflow-models-face-detection) package from the same TensorFlow.js models repository.

### MediaPipe vs OpenCV: which should I use?

[MediaPipe Tasks Vision](#mediapipe-tasks-vision) runs task-specific models for face landmarks, detection, and segmentation. [OpenCV.js](#opencv-js-techstark) exposes OpenCV's matrix and image-processing operations through WebAssembly.

### How should OpenCV matrix memory be released?

OpenCV's own image-processing example deletes each allocated matrix after use.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best JavaScript computer vision libraries OpenCV MediaPipe COCO SSD FaceAPI code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
