ONNX Runtime for Webで画像認識 – Rest Term
DRANK

<template>  <divclass="hello">    <h1>{{msg}}</h1>    <canvaswidth="32"height="32"ref="canvas"></canvas>    <buttontype="button"@click="inference">inference</button>    <span>{{ infoLabel }}</span>  </div></template><scriptlang="ts">import{defineComponent}from'vue';import{InferenceSession,Tensor}from'onnxruntime-web';interfaceDataType{  modelPath:string,  imagePath:string,  imageData:ImageData null,  ctx:CanvasRenderingContext2D null,  session:InferenceSession null,  infoLabel:string}exportdefaultdefineComponent({  name:'HelloONNX',  props:{    msg:String,  },  data():DataType{    return{      modelPath:'cifar10_net.onnx',  // ONNXモデルファイル名      imagePath:require("@/assets/cat9.png"),  // テスト画像を埋め込み      imageData:null,      ctx:null,      session:null,      infoLabel:""    };  },  asyncmounted(){    constoption={executionProviders:['wasm','webgl']};    this.session=awaitInferenceSession.create(this.modelPath,option);    this.infoLabel="loading model complete."    con…

rest-term.com
Related Topics: