浏览器中如何离线运行YOLO进行目标检测识别?
网友回复
使用transformer.js在浏览器中运行yolov9模型
安装
npm i @xenova/transformers代码
import { AutoModel, AutoProcessor, RawImage } from '@xenova/transformers';
// Load model
const model = await AutoModel.from_pretrained('Xenova/yolov9-c', {
// quantized: false, // (Optional) Use unquantized version.
})
// Load processor
const processor = await AutoProcessor.from_pretrained('Xenova/yolov9-c');
// processor.feature_extractor.do_resize = false; // (Optional) Disable resizing
// processor.feature_extractor.size = { width: 128, height: 128 } // (Optional) Update resize value
// Read image and run processor
const ur...点击查看剩余70%


