资源:{
实例:[“B64”:data.imagedata]
但他们的表现似乎都一样。
results.predictions
总是空的,当我字符串化时results


您还可以在ML发动机型号仪表板上看到,Last use time
当我调用云函数时进行反射。

以下是我为设置云功能所遵循的指南:https://github.com/GoogleCloudPlatform/ml-functions-helpdesk/blob/master/functions/index.js
data.imageData
const functions = require('firebase-functions');
const {google} = require('googleapis');
exports.analyzeDetection = functions.https.onCall((data, context) => {
if (data.imageData) {
// Auth
google.auth.getApplicationDefault((err, authClient) => {
if (err) {
console.error("getApplicationDefault err " + err);
return {
prediction: "error"
}
}
//[START ml_engine_auth]
if (authClient.createScopedRequired && authClient.createScopedRequired()) {
// https://developers.google.com/identity/protocols/googlescopes#mlv1
authClient = authClient.createScoped(['https://www.googleapis.com/auth/cloud-platform']);
}
//Create authenticated ml engine client
var ml = google.ml({
version: 'v1',
auth: authClient
});
//[END ml_engine_auth]
// Prediction
ml.projects.predict({
name: `projects/my_project_name/models/my_model_name`,
resource: {
instances: [{"b64": data.imageData}]
}
}, (err, result) => {
// The problem is that result is always null
if (err){
console.error('ERROR ', err);
return {
prediction: "error"
}
}
return {
prediction: "add this after the prediction requests are working"//result.predictions[0].predicted
}
});
});
}
});
my_project_name
my_model_name
name: 'projects/my_project_name/models/my_model_name',
resource: {
instances: [{"image_bytes": {"b64": data.imageData}, "key": "0"}]
}
和
name: 'projects/my_project_name/models/my_model_name',
resource: {
name: 'projects/my_project_name/models/my_model_name',
instances: [{"b64": data.imageData}]
}