问题描述
我最近一直在使用 GCP 来训练对象检测模型。我将模型导出为 tensorflow.js 包,以便在我的 React 应用程序上运行客户端。我用相同的数据训练了 5 个不同的模型。所有 5 个模型都在本地主机上完美运行,但是当部署到应用引擎 3 时,模型在进行预测时会引发以下错误。
Error: Expected len(indices) == tensor.shape[0],but saw: 0 vs. 1
at e.value (tensor_array.ts:254)
at control_executor.ts:199
at u (runtime.js:63)
at Generator._invoke (runtime.js:293)
at Generator.next (runtime.js:118)
at r (asyncToGenerator.js:3)
at s (asyncToGenerator.js:25)
at asyncToGenerator.js:32
at new Promise (<anonymous>)
at asyncToGenerator.js:21
const [modelLoaded,setModelLoaded] = useState(false);
const [modelUrl,setModelUrl] = useState("");
const [model,setModel] = useState(null);
const loadModel = async () => {
if(!modelLoaded){
setModelLoaded(true);
if(process.env.REACT_APP_API_URL != "http://localhost:8080") {
setModelUrl(process.env.REACT_APP_API_URL);
} else {
setModelUrl("http://localhost:3000")
}
const loadedModel = await automl.loadobjectDetection(modelUrl + "/model/model.json");
setModel(loadedModel);
}
}
const makePrediction = async (imageData) => {
const options = {score: 0.5,IoU: 0.5,topk: 1};
return await model.detect(imageData,options);
}
有关此错误含义的任何信息将不胜感激。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)