UNPKG

hookformers

Version:

Simple, performant React Hooks for running Transformers.js in your browser.

12 lines 523 B
import { pipeline } from "@huggingface/transformers"; import { useCallback } from "react"; // const foo = await pipeline("text-classification", "bla"); // const bar = await foo("sdsd"); export function useTransformer(task, model, modelOptions) { const predict = useCallback(async (input, options) => { const pipelineInstance = await pipeline(task, model, modelOptions); return pipelineInstance(input, options); }, [model, task]); return { predict }; } //# sourceMappingURL=useTransformers.js.map