当我捕获图像时显示此错误并且 clarifai 没有提供任何结果,也没有任何预测答案。显示错误“[未处理的承诺拒绝:TypeError:未定义不是对象(评估'clarifai.GENERAL.MODEL')]”。请帮我解决这个问题,谢谢。
const Clarifai = require('clarifai');
const clarifai = new Clarifai.App({
apiKey: '851f7efad90241fc807252f3da705d6d'
});
process.nextTick = setImmediate;
state = {
hasCameraPermission: null,
predictions: [],
};
async componentWillMount() {
const { status } = await Permissions.askAsync(Permissions.CAMERA);
this.setState({ hasCameraPermission: status === 'granted' });
}
capturePhoto = async () => {
if (this.camera) {
var photo = await this.camera.takePictureAsync();
return photo.uri;
}
};
resize = async photo => {
let manipulatedImage = await ImageManipulator.manipulateAsync(
photo,
[{ resize: { height: 300, width: 300 } }],
{ base64: true }
);
return manipulatedImage.base64;
};
predict = async image => {
let predictions = await clarifai.models.predict(
clarifai.GENERAL.MODEL, // model need to get prediction from
image
);
return predictions;
};
objectDetection = async () => {
let photo = await this.capturePhoto();
let resized = await this.resize(photo);
let predictions = await this.predict(resized);
this.setState({ predictions: predictions.outputs[0].data.concepts });
console.log(this.state.predictions)
};