JSPM

use-media-models

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q25935F
  • License MIT

A toolset to use AI models in React

Package Exports

  • use-media-models
  • use-media-models/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (use-media-models) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

A toolset to use AI media models in React.

Install

yarn add use-media-models or npm install use-media-models --save.

Use a model (example: useFaceLandmarker)

useFaceLandmarker

import React from "react";
import { useCamera, useFaceLandmarker } from "use-media-models";

export default function ExamplePage() {
  const videoRef = React.useRef<HTMLVideoElement | null>(null);
  const { startCamera } = useCamera(videoRef);
  const { startModel, } = useFaceLandmarker({
    onResults: (results, stream) => {
      console.log('Got results.', results.faceLandmarks);
    },
  });
  React.useEffect(() => {
    startCamera().then(({ stream }) => startModel({ stream }));
  }, []);
  return (
    <video
      ref={videoRef}
      style={{
        position: 'fixed',
        top: 0,
        left: 0,
        width: '100%',
        height: '100%',
        objectFit: 'contain',
        backgroundColor: 'black',
      }}
    />
  );
}