InferenceSession

InferenceSession

基础库 2.30.0 开始支持,低版本需做兼容处理

推理 Session 实例,通过wx.createInferenceSession 接口获取该实例。使用前可参考AI指南文档

方法

InferenceSession.onLoad(function callback)

监听模型加载完成事件

InferenceSession.offLoad(function callback)

取消监听模型加载完成事件

InferenceSession.onError(function callback)

监听模型加载失败事件

InferenceSession.offError(function callback)

取消监听模型加载失败事件

Promise InferenceSession.run(Object tensors)

运行推断。需要在 session.onLoad 回调后使用。接口参数为 Tensors 对象,返回 Promise。一个 InferenceSession 被创建完成后可以重复多次调用 InferenceSession.run(), 直到调用 session.destroy() 进行销毁。

InferenceSession.destroy()

销毁 InferenceSession 实例

posted on 2025-01-12 20:32  AtlasLapetos  阅读(151)  评论(0)    收藏  举报